Refresh the Texture????

Blitz3D Forums/Blitz3D Programming/Refresh the Texture????

NotAGamer(Posted 2014) [#1]
I'm making a tool(program) that will preview the 3d model while you texture it in another 2d image editor...

example:

*i load the mesh in my 3d program and apply the texture pattern(UV)
*then i'll open the texture map in photoshop(or any of the same kind)
*i save everytime i make change in my texture
* then REFRESH the progam to view changes in texture applied in the model

the problem is i cant arrive with an idea to refresh the texture.. :)


stayne(Posted 2014) [#2]
Just my opinion but to prevent loading it multiple times I would just create a small little routine that frees the texture from memory and reloads it when you hit Refresh.

If Refresh = 1
  FreeTexture(oldtexturename)
  LoadTexture(newtexturename)
  EntityTexture(entity,newtexturename)
  Refresh = 0
EndIf


Disclaimer: I suck at programming.


NotAGamer(Posted 2014) [#3]
stayne >> tried what you suggested but not working, i dont kwnow why..


here's the code

;;;; mesh.3ds is the mesh to texture
;;;; meshtexture is the texture


Graphics3D 800,600,32,2
SetBuffer BackBuffer()


mesh=LoadMesh("mesh.3ds")
meshtexture=LoadTexture("texture.png")
EntityTexture mesh,meshtexture,0,0
PositionEntity mesh,0,0,0
EntityFX mesh,1

light=CreateLight()
PositionEntity light,EntityX(mesh),EntityY(Mesh)+MeshHeight(mesh),EntityZ(mesh)


cam=CreateCamera()
PositionEntity cam,EntityX(mesh),EntityY(Mesh),EntityZ(mesh) - MeshDepth(mesh) -20

turnspeed#=1

While Not KeyHit(1)
x#=0
y#=0
z#=0

If KeyDown(17) Then x#=x#+.01*MeshDepth(mesh)
If KeyDown(31) Then x#=x#-.01*MeshDepth(mesh)
If KeyDown(32) Then y#=y#+.01*MeshDepth(mesh)
If KeyDown(30) Then y#=y#-.01*MeshDepth(mesh)
TurnEntity mesh,x#*turnspeed,y#*turnspeed,z#*turnspeed

If KeyDown(42) Then turnspeed#=3

If Not KeyDown(42) Then turnspeed#=1


If KeyHit(57) Then
FreeTexture(meshtexture)
meshtexture=LoadTexture("texture.png")
EntityTexture(mesh,meshtexture)
EndIf



RenderWorld
UpdateWorld



Flip
Wend
End


stayne(Posted 2014) [#4]
Read the last post here. It's old but probably still applies.

http://www.blitzmax.com/Community/posts.php?topic=34673#378333


NotAGamer(Posted 2014) [#5]
thanks stayne!!!