Changing textures

Blitz3D Forums/Blitz3D Beginners Area/Changing textures

Trigger1000(Posted 2015) [#1]
Hello,
I've been trying to teach myself on Blitz3d, and I wanted to change a texture on my 3d object, but I'm experiencing a problem, i can't find where to.
My 3d model already does have a texture, but i would like to be able to change it, and I would like to be able to in-game.

Here is the code:

x = 40
y = 40

plane1=CreatePlane()
texture1=LoadTexture("blah.jpg")

ScaleTexture texture1,x,y
EntityTexture plane1,texture1
EntityAlpha plane1, .6
PositionEntity plane1, 0, -1, 0

mesh=LoadMesh( "jacob2.3ds" )

PositionEntity mesh,+0,2,0
ScaleEntity mesh, .01,.01,.01
RotateEntity mesh, 0,180,0

EntityParent(cam1,mesh,True)

pivot=CreatePivot()

RotateEntity mesh,0,180,0

lit=CreateLight()
RotateEntity lit,45,45,0

:Also, I set up my game so this is the loading world folder, just so no one asks about the lack of certain codes.

Thank you for helping


Matty(Posted 2015) [#2]
You can just apply a new texture by using the entity texture command.

However - sometimes it is not as simple as that....

Sometimes the handle you get from LoadAnimMesh is actually a pivot, and the mesh which is textured is a child of the pivot which means if you call entitytexture on the entity returned from LoadAnimMesh then it won't texture it...in that case you need to find the child (either by name with findchild()) or by parsing through the parent/child structure of the entity (using countchildren/getchild)

Another thing - sometimes a mesh has multiple textures applied to different parts of the mesh - usually this is with separate surfaces which means you need to find the appropriate surface and "paintsurface()" the relevant surface (use countsurfaces/getsurface commands) .


Blitzplotter(Posted 2015) [#3]
Hi Trigger, will try your code this weekend and try to give you some feedback ;)