Dan22 Posted February 3, 2015 Share Posted February 3, 2015 If anyone is able to help me make a way to get animated textures/gifs to work it would make the snoop dogg game amazing! I am very bad at coding so I will either need every step explained or something of that nature. Thanks! Quote Link to comment Share on other sites More sharing options...
f13rce Posted February 3, 2015 Share Posted February 3, 2015 For every frame, save it as a material (just like how water is done). After that make an array with all the materials. From there you only need a few variables to loop through the array and assign it to the model. Example of how I'd do it (C++ though, Lua should be similar): Material aMaterials[10]; // For example 10 frames float fCurrentFrame = 0.f; // Start at frame 0 int iMaxFrame = 10; // Amount of frames the array has float fFrameSpeed = 1.0f; // Set desired speed here void Start(){ aMaterials[0] = Material::Load("./Materials/Animation/00.mat"); aMaterials[1] = Material::Load("./Materials/Animation/01.mat"); // etc } void Update(){ // Animate fCurrentFrame += fFrameSpeed; // Note: Deltatime is not applied here // Did we reach our limit? if (fCurrentFrame >= iMaxFrame) fCurrentFrame = 0; // Reset // Assign material model->SetMaterial( aMaterials[ Math::Floor( fCurrentFrame ) ] ); } Quote Using Leadwerks Professional Edition (Beta), mainly using C++. Windows 10 / Linux Mint, Visual Studio 2017. GPU: NVidia GeForce GTX970, CPU: Intel i7 7700K @ 4.20 GHz Previously known as Evayr. Link to comment Share on other sites More sharing options...
shadmar Posted February 3, 2015 Share Posted February 3, 2015 Or just cycle textures in one material, something like : in start() for i=1,numberfortextures,1 do tableoftextures[i]=Texture:Load("/path/to/texture"..i..".tex") done then in update() i=i+Time:GetSpeed() if i>numberfortextures then i=1 end material:SetTexture(tableoftextures[math.floor(i)]) Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Russell Posted October 6, 2020 Share Posted October 6, 2020 Is it possible adapt this to LUA?? I'm trying to do it with my own pack of textures to make an animation, and i don't know how code or use it to obtain the effect... Quote Link to comment Share on other sites More sharing options...
Russell Posted October 6, 2020 Share Posted October 6, 2020 I'm learning from here too: Your Firepit from the workshop is a good point from start... Thanks Shadmar!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.