[Bf-python] NMesh module :problem when i try to link a uv material to a mesh
jms
jmsoler at free.fr
Sun Jan 2 01:48:06 CET 2005
#this seems to work
DONOT=0
# But if we set DONOT to1 the material is correctely addde but
# the mesh is not display whe, we try to render the picture.
import Blender
from Blender import *
me=NMesh.GetRaw()
v=NMesh.Vert(1.0,0.0,0.0)
me.verts.append(v)
v=NMesh.Vert(1.0,1.0,0.0)
me.verts.append(v)
v=NMesh.Vert(0.0,1.0,0.0)
me.verts.append(v)
v=NMesh.Vert(0.0,0.0,0.0)
me.verts.append(v)
f=NMesh.Face()
f.v.append(me.verts[0])
f.v.append(me.verts[1])
f.v.append(me.verts[2])
f.v.append(me.verts[3])
uv=[]
uv.append( (0.0,0.0))
uv.append( (1.0,0.0))
uv.append( (1.0,1.0))
uv.append( (0.0,1.0))
f.uv=uv
im=Image.Load('f:/maincrystalpalace3.jpg')
f.image = im
if Blender.Get('version')>=228:
C = NMesh.FaceModes
else:
C = NMesh.Const
f.mode=C['LIGHT']+C['TEX']+C['TWOSIDE']
me.faces.append(f)
if DONOT:
newmat = Material.New('newmat')
newmat.mode = newmat.mode | 2048
#me.materials.append(newmat)
me.setMaterials([newmat])
f.materials=1
tex = Texture.New()
tex.setType('Image')
tex.image = im
newmat.setTexture(0, tex)
mtex = newmat.getTextures()
mtex[0].texco=Texture.TexCo.UV
NMesh.PutRaw(me,"Plane.002")
Blender.Redraw()
More information about the Bf-python
mailing list