Applying texture on LoadMesh/LoadAnimMesh model
Blitz3D Forums/Blitz3D Programming/Applying texture on LoadMesh/LoadAnimMesh model
| ||
It seems to have a small problem here with applying a texture on an entity. I load the 3DS model using LoadAnimMesh() function then I use the EntityTexture() function, but the entity remains untextured. If I use the LoadMesh() function for loading the model, then it is fine. I cannot decide which function should I use before loading the model, because it is a kind of a model viewer and I always load them with LoadAnimMesh(). Is there any major difference between LoadAnimMesh() and LoadMesh() concerning with the textures? Thanks. Graphics3D 800, 600, 32, 2 SetBuffer BackBuffer() camera = CreateCamera() PositionEntity camera, 0, 0, -30 cube = LoadAnimMesh("cube.3ds") texture = LoadTexture("texture.jpg") EntityTexture cube, texture While Not KeyHit(1) TurnEntity cube, 1, 2, 3 RenderWorld Flip Wend End |
| ||
Yes, when using LoadAnimMesh, the hierarchy of the object is retained. In this case, you cube is attached to a 'root' pivot. In order to use EntityTexture the same way as with a LoadMesh-model, use this function: Function RecEntityTexture(ent, tex) If EntityClass(ent) = "Mesh" Then EntityTexture ent, tex For i = 1 To CountChildren(ent) RecEntityTexture GetChild(ent, i), tex Next End Function It recursively scans the hierarchy and applies the texture to each mesh in it. |
| ||
Excellent! Thanks a lot. |