I can't get LightMesh to work with a cube (or any entity) that is made using the CreateMesh/Surface etc. commands. Any ideas on what I'm doing wrong? By the way, the function is NOT mine - I found it on the forum somewhere and am just using it here as an example.
Any help or insight would be much appreciated! Also, an explanation as to how LightMesh actually works (when it does work...) would be great.
Graphics3D 640,480,16,2 camera = CreateCamera() Function CreateCube6sfc() m=CreateMesh() sfc=CreateSurface(m) AddVertex sfc,-1,1,-1,0,0 : AddVertex sfc,1,1,-1,1,0 AddVertex sfc,1,-1,-1,1,1 : AddVertex sfc,-1,-1,-1,0,1 VertexNormal sfc,0,0,0,-1 : VertexNormal sfc,1,0,0,-1 VertexNormal sfc,2,0,0,-1 : VertexNormal sfc,3,0,0,-1 AddTriangle sfc,0,1,2 : AddTriangle sfc,2,3,0 sfc=CreateSurface(m) AddVertex sfc,-1,1,-1,0,0 : AddVertex sfc,-1,1,1,1,0 AddVertex sfc,1,1,1,1,1 : AddVertex sfc,1,1,-1,0,1 VertexNormal sfc,0,0,1,0 : VertexNormal sfc,1,0,1,0 VertexNormal sfc,2,0,1,0 : VertexNormal sfc,3,0,1,0 AddTriangle sfc,0,1,2 : AddTriangle sfc,2,3,0 sfc=CreateSurface(m) AddVertex sfc,-1,1,1,0,0 : AddVertex sfc,-1,-1,1,1,0 AddVertex sfc,1,-1,1,1,1 : AddVertex sfc,1,1,1,0,1 VertexNormal sfc,0,0,0,1 : VertexNormal sfc,1,0,0,1 VertexNormal sfc,2,0,0,1 : VertexNormal sfc,3,0,0,1 AddTriangle sfc,0,1,2 : AddTriangle sfc,2,3,0 sfc=CreateSurface(m) AddVertex sfc,-1,-1,-1,0,0 : AddVertex sfc,1,-1,-1,1,0 AddVertex sfc,1,-1,1,1,1 : AddVertex sfc,-1,-1,1,0,1 VertexNormal sfc,0,0,-1,0 : VertexNormal sfc,1,0,-1,0 VertexNormal sfc,2,0,-1,0 : VertexNormal sfc,3,0,-1,0 AddTriangle sfc,0,1,2 : AddTriangle sfc,2,3,0 sfc=CreateSurface(m) AddVertex sfc,-1,1,1,0,0 : AddVertex sfc,-1,1,-1,1,0 AddVertex sfc,-1,-1,-1,1,1 : AddVertex sfc,-1,-1,1,0,1 VertexNormal sfc,0,-1,0,0 : VertexNormal sfc,1,-1,0,0 VertexNormal sfc,2,-1,0,0 : VertexNormal sfc,3,-1,0,0 AddTriangle sfc,0,1,2 : AddTriangle sfc,2,3,0 sfc=CreateSurface(m) AddVertex sfc,1,1,-1,0,0 : AddVertex sfc,1,1,1,1,0 AddVertex sfc,1,-1,1,1,1 : AddVertex sfc,1,-1,-1,0,1 VertexNormal sfc,0,1,0,0 : VertexNormal sfc,1,1,0,0 VertexNormal sfc,2,1,0,0 : VertexNormal sfc,3,1,0,0 AddTriangle sfc,0,1,2 : AddTriangle sfc,2,3,0 UpdateNormals m Return m End Function mycube = CreateCube6sfc() EntityFX mycube,2 ; light it red - but doesn't work LightMesh mycube,255,0,0 PositionEntity mycube,0,0,5 While Not KeyDown(1) TurnEntity mycube,0,1,0 UpdateWorld RenderWorld Flip Wend FreeEntity mycube End
Any help or insight would be much appreciated! Also, an explanation as to how LightMesh actually works (when it does work...) would be great.