FANDOM


Created by 7Kings on the original RealmCrafter: Standard forums.

Hello at the request of some users on here, Here is a tutorial on how to have animated textures on meshes.

A few things to note before we begin, there are a few ways to do this, mine is probably not the most efficient way of doing it, but it gets the job done. this tutorial will be explained with images and I will try my best to fully explain what is going on. 

Preparations Edit

The first few files you will need for this edit are:

Client.bb
ClientAreas.bb
Filmstrip texture

Step 1 Edit

First you should open up your Client.bb and go to where all the globals are set up.

You will be setting up 4 Globals which consist of:

Global (insert variable)tex = 0
Global (insert variable)PlaneLastFrame = (number of frames in filmstrip texture)
Global (insert variable)PlaneAnimationSpeed = (Animation speed in miliseconds)
Global (insert variable)PlaneFrame% = MilliSecs()/(timing of each frame in miliseconds) Mod (Number of frames in filmstrip texture)

When you are done with that it should look simalair to mine.

Wacky guide

My code is set up for an engine gubbin mesh for a spaceship with an animated texture slapped on it. I have 24 frames and each frame runs for a second.

Step 2 Edit

Next move on to ClientAreas.bb

In between

;Scenery

but before

If S\EN <> 0


You will be placing a few lines of code.

If S\MeshID = INSERT GUE MESH ID NUMBER ;put in mesh ID 

If (Your global variablename)tex= 0 Then (Your global variablename)tex = LoadAnimTexture("Path for your image.jpg", "Add filters to your desire", "width of each frame", "Height of each frame", 0 ,"total number of frames minus one") 

EntityTexture S\EN, (Your global variablename)tex, frame <-- keep this code like this, it will be explained in section 3 

EndIf

When you are complete, it should look like this:

Look like this

Alright now you will realize that this is done on a mesh by mesh basis. There are again probably much better ways of doing this, but this way does work, just involves writing more code.

Step 3Edit

Alright, now its time to update all animated scenery in the main loop. Now you have it defined when an area is loaded if that mesh exists it will put the animated texture on and start it at the first frame.
Now to make it move!

Open back up your client.bb

Inside the function

Function UpdateAnimatedScenery()

You will be placing the following code: 

If S\MeshID = ID OF DESIRED MESH
frame = MilliSecs()/(Speed desired) Mod (Number of total frames in your filmstrip minus one)
EntityTexture(S\EN, (Your variable name)tex,frame)

EndIf

The code should look like this when you are finished:

Finished code

Now to top this all off, a working video of animated textures showing that my code works.


View 7Kings's Video of Animated Textures