something similar to an animiated gif ?

Blitz3D Forums/Blitz3D Beginners Area/something similar to an animiated gif ?

timmport(Posted 2006) [#1]
I would like to take a sequence of images files and map them to a polygon one at a time for about .1 seconds each in a way similar to an animated gif. I have looked through the command refernce and none of the commands seem to address this explicity. Some of he commands are as well described. I also did a searh. Could someone point me to some information or the command, if it exists, that actually addresses this.


Matty(Posted 2006) [#2]
Create your polygon, either in a modeling tool, or with code using the 'addvertex/create surface/create mesh' commands. Set the uv coordinates appropriately of each vertex so that when a texture is mapped to it it will look the way you want it. Then simply use 'loadanimtexture' which takes an image strip and apply the texture to the polygon in any order you choose - specifying the appropriate frame for the anim texture. Alternatively you could load each texture in and store their texture handle in either a type or a bank and cycle through them applying the texture to the mesh as required.


markcw(Posted 2006) [#3]
i think you can use entitytexture for this, i was confused too.

this example creates a texture with 10 frames and then changes the frame index every second.
Graphics3D 640,480,0,2
SetBuffer BackBuffer()

cam=CreateCamera()
light=CreateLight()
cube=CreateCube()
PositionEntity cube,0,0,5

tex=CreateTexture(128,128,1+4,10)
EntityTexture cube,tex

;create anim texture
For i=0 To 9
 SetBuffer(TextureBuffer(tex,i))
 ClsColor 255,255,255 : Cls
 Color 0,0,0 : Text 0,0,"Texture frame "+(i+1)
 ClsColor 0,0,0 : Color 255,255,255
 SetBuffer BackBuffer()
Next

While Not KeyHit(1)
 RenderWorld

 ;fps counter
 If MilliSecs()-settime>1000
  getfps=setfps : setfps=0 : settime=MilliSecs()
  frame=frame+1 : If frame>9 Then frame=0
  EntityTexture cube,tex,frame ;change the frame
 Else
  setfps=setfps+1
 EndIf

 TurnEntity cube,0.4,0.3,0.2

 Text 0,0,"FPS="+getfps+" Tris="+TrisRendered()

 Flip
Wend



timmport(Posted 2006) [#4]
The example was useful but what I cant really figure out is how and where in the code do you place seperate image files so that you can then cycle through them. I have a sequence of 8 png files that I am using. Any help would still be appreciated.
P.S.I also tried the LoadAnimTexture() method but it seemed intended more for animating a single textures UV's. Am I just using the command wrongly?


b32(Posted 2006) [#5]
I think you need to replace this part:
tex=CreateTexture(128,128,1+4,10)
EntityTexture cube,tex

;create anim texture
For i=0 To 9
 SetBuffer(TextureBuffer(tex,i))
 ClsColor 255,255,255 : Cls
 Color 0,0,0 : Text 0,0,"Texture frame "+(i+1)
 ClsColor 0,0,0 : Color 255,255,255
 SetBuffer BackBuffer()
Next

with the LoadAnimTexture command:
tex = LoadAnimTexture("file.png",1,128,128,0,8)
Where 128 and 128 are the width and height of a single png.

Then in a graphical editor, you should create an imagestrip. That is a large image that contains all 8 pngs, in a row (left->right, 8x1) or a matrix. (left->right, top->down, 3x3)
If you want to keep the 8 images separate, you can load them separately (into a Dim for instance) and use EntityTexture to apply them to the mesh one by one. However I think LoadAnimTexture is faster.


timmport(Posted 2006) [#6]
I got it to work. I think the thing that threw me off was the term film strip. Once I realised that all the images in the sequence were really contained in one image file (i.e. the image sequence) I got it to work with the loadanimtexture command and the timer. I have to say being a Torque forum refugee the Blitz community is way more helpful.