Hello every one,
I will ask here really simple questions you will may be think,
but I am not a familiar at all to programming.
In order to progress I fix myself simple tasks and I try, using the API, to write a simple script that do it
First task: create a primitive cube and assign it a color.
from Blender import *
me = Mesh.Primitives.Cube(2.0) # create a new cube of size 2
sc = Scene.GetCurrent() # get current scene
sc.objects.new(me,'Mesh') # add a new mesh-type object to the scene
mat = Material.New('newMat') # create a new Material called 'newMat'
print mat.rgbCol # print its rgb color triplet sequence
mat.rgbCol = [0.8, 0.2, 0.2] # change its color
mat.setAlpha(0.2) # mat.alpha = 0.2 -- almost transparent
mat.emit = 0.7 # equivalent to mat.setEmit(0.8)
mat.setName('colorA') # change its name
me.materials.append(mat)
Window.RedrawAll() # update windows
from Blender import *
from Blender import Noise
from Blender import Object
me = Mesh.Primitives.Cube(4.0) # create a new cube of size 2
sc = Scene.GetCurrent() # get current scene
sc.objects.new(me,'Mesh') # add a new mesh-type object to the scene
mat= Material.New('newMat') # create a new Material called 'newMat'
mat.rgbCol = [0.8, 0.2, 0.2] # change its color
mat.setAlpha(0.2) # mat.alpha = 0.2 -- almost transparent
mat.emit = 0.7 # equivalent to mat.setEmit(0.8)
mat.setName('colorA') # change its name
me.materials=[mat]
Window.RedrawAll() # update windows
states that "The list that’s returned is not linked to the original mesh. mesh.materials.append(material) won’t do anything. Use mesh.materials += [material] instead. " Although this is odd, you have to use this:
Hello every one,
new question, about the ipo curve
I want to create a camera and to make it move using a curve.
Down in the code I let the mistake.
The Ipo for the camera are not about mouvement,
and the object curve wont want to be connected to the camera.
still the is Action ipo…
still testing…
I copied some part from here http://blenderartists.org/forum/showthread.php?t=102510
am I in the right direction?
from Blender import *
from Blender import Camera
from Blender import Object
from Blender import Scene
from Blender import Ipo
#creation du cube
me = Mesh.Primitives.Cube(4.0) # create a new cube of size 2
sc = Scene.GetCurrent() # get current scene
sc.objects.new(me,'Mesh') # add a new mesh-type object to the scene
#camera
cam = Camera.New('ortho') # create new ortho camera data
cam.scale = 6.0 # set scale value for ortho view
ob=sc.objects.new(cam) # add a new camera object from the data
sc.setCurrentCamera(ob) # make this camera the active
#ipo
ipo = Ipo.New('Object','deplacement')
cam.setIpo(ipo)
locx = ipo.addCurve('LocX')
locx.interpolation = Blender.IpoCurve.InterpTypes.LINEAR
locy = ipo.addCurve('LocY')
locy.interpolation = Blender.IpoCurve.InterpTypes.LINEAR
locz = ipo.addCurve('LocZ')
locz.interpolation = Blender.IpoCurve.InterpTypes.LINEAR
#materiel pour l'objet cube
mat= Material.New('newMat') # create a new Material called 'newMat'
mat.rgbCol = [0.8, 1, 0.2] # change its color
mat.setAlpha(0.2) # mat.alpha = 0.2 -- almost transparent
mat.emit = 0.7 # equivalent to mat.setEmit(0.8)
mat.setName('colorA') # change its name
me.materials+=[mat]
Window.RedrawAll() # update windows
I’d suggest looking at the ‘Outliner’ Window. It’ll show you the Hierarchy of your Scene. For instance, you’ll see that you have a Scene, and below that you have Objects, and each object can have different data linked to it ranging from the raw Mesh, Curve, or Lamp Data to Ipo Data and Constraints. It might help to clear up how the various data types in Blender are linked together and interact.
A brief explanation of library linking can be found here.
This will change quite a bit in Blender 2.5 with the introduction of RNA more here, but the basic principles of data reuse and linking will be the same.
Thank you FunkyWyrm and forTe,
I will print all this and have some good scons, and a stong cup of tea…
to help the intergration of the concepts.
I am trying something else,
I am trying to make wall with randomly disposed bricks on the y Axe.
The wall is built but without taking in concideration any randomnity on y axe.
Also
I have to make a indentation at
cube.setLocation (x,y,z)
if not it is not working
Why ?
Edit:
I see
y= Mathutils.Rand(0.0,10.0)
is just not in the Boucle
…
Will try
Edit2:
It is working!
The indentation problem disapeared
copy past problem I guess.
from Blender import *
from Blender import Camera
from Blender import Object
from Blender import Scene
from Blender import Noise
#valeur a utiliser /value to use later
a=0
b=0
c=5
x=0
z=0
while a<5:
while b<c:
me = Mesh.Primitives.Cube(2.0) # create a new cube of size 2
sc = Scene.GetCurrent() # get current scene
cube=sc.objects.new(me,'Mesh') # add a new mesh-type object to the scen
y= Noise.random()
cube.setLocation (x,y,z) #a random position is setteled
Window.RedrawAll() # update windows
b=b+1
x=x+2.25
a=a+1
b=0
x=0
z=z+2.25
Window.RedrawAll() # update windows
Hello Every one,
I just post the sript in order for beginners to study a bit.
from Blender import *
from Blender import Camera
from Blender import Object
from Blender import Scene
from Blender import Noise
from Blender import Mathutils
#valeur a utiliser /value to use later
a=0
b=0
c=10
x=0
z=0
while a<10:
while b<c:
me = Mesh.Primitives.Cube(2.0) # create a new cube of size 2
sc = Scene.GetCurrent() # get current scene
cube=sc.objects.new(me,'Mesh') # add a new mesh-type object to the scen
y= Mathutils.Rand(0.0,2.0)
t= Noise.random()
t2= Noise.random()
t3= Noise.random()
cube.setLocation (x,y,z) #a random position is setteled
Window.RedrawAll() # update windows
b=b+1
x=x+2.25
#materiel pour l'objet cube/Material for the cube
mat= Material.New('newMat') # create a new Material called 'newMat'
mat.rgbCol = [t,y,t2] # change its color
mat.setMode( "RayMirr")
mat.setRayMirr(t3) # mat.alpha = 0.2 -- almost transparent
#mat.emit = 0.7 # equivalent to mat.setEmit(0.8)
mat.setName('colorA') # change its name
me.materials+=[mat]
a=a+1
b=0
x=0
z=z+2.25
Window.RedrawAll() # update windows
What is laking me the most is the thinking process.
for example, http://cubemine.com/2006/02/fractal-sculpture-1-light-blue/
nice work…
I just don’t know how the looping is written in the python script, hard to figure for this one.
Is this Just array??
There are many different methods of making fractals. The overarching methods are iteration and recursion.
Iteration is just looping of course, and for instance you can plot the mandelbrot set using iteration and the escape time algorithm. There’s also just deriving an equation and plugging in points for that (its helpful if they’re differential equations that can be solved using Euler’s or Runge-Kutta or some other iterative solver).
Recursion on the other hand, is a little bit different. Things like the Sierpinski triangle are recursive. The one you’ve linked to with the spheres looks recursive. The basic method is you make a function and give it an initial point, it then generates the basic fractal for each of those given points. At each of those generated points, you then once again generate the fractal, and for each point generated from that one you do the same, and so on and so on. So in pseudo-code:
def genFractal(point):
# Terminating condition
# Logic to generate points of fractal
points = [...the newly generated points]
for pt in points:
genFractal(pt)
return
Would sort of be the way you’d go. There’s also things called strange attractors which fit into that general category of artistic fractals (although not the strict definition of self-repetitious structures).
ForTe, you got it right: the method I used is a recursive one. The first call is special as it generates three identical branches. Then the rest of the calls just creates two more smaller branches and another bigger one, all rotated by a fixed angle.
The rest of the code deals with two things:
-giving a different color for each sphere, according to its level in the recursion.
-assigning a different mesh to each sphere, according to its size.
This last one was needed because the triangle count would be too high otherwise.
To generate the fractal, select the 4 meshes that will be used and run the script. It’s old and probably there is some new API I could use, but works. I hope you find it useful.
Here again
Thanks to Ratow and forTe for the precious help.
RickyBlender I didn’t try the algo you were pointing me out,
It is quite difficule.
I will have more time to see some theory tomorrow…
perhaps…
here is what I made so fare…
This is WIP.
I am not “satisfait”(satisfied) by it but any ways,
good to see for beginners.
don’t know can you check
you should use tab instead of space easeir to follow code
i’m surprise that we don’t get more on fractals on forum
it’s a strange world but interesting
i just saw a NOVA sepcail last week on this and it’s inmpressive where you can find theses
I will give later the complete code here is just about what I want to do.
The simplest way to insert Japanese text in Blender.
Is to load a Japanese font.
and after that load the text saved in UTF-8 in edit mode.
I am trying to do that…
without success.
Text3d have no load attribute
I used setFont() fonction that I found in a forum but no sign of it in the API.
setText only accept string but I was thinking we can use a path.
???
A bit lost,
will strongly appreciate any help.
from Blender import *
sc = Scene.GetCurrent()
txt=Text.Load('H:/test.txt') # I have the text in this driver in simpletext format saved in UTF-8
txt3d = Text3d.New("MyText3d")
ob = sc.objects.new(txt3d)
myfont= Text3d.Font.Load('C:/WINDOWS/Fonts/MSMINCHO.TTC')
txt3d.setFont(myfont)
txt3d.setWidth(1)
txt3d.setExtrudeDepth(0.1)
txt3d.setExtrudeBevelDepth(0.05)
#txt3d.setText(txt)