Jump to content

Animation with LODs


Matthew Nicholls
 Share

Recommended Posts

Can anyone please help with getting all the levels of detail to animate at the right time. I have 4 LOD models and an animation in an other gmf file. If I only have the one model in the folder and load the animation in to it, it animates fine. But when I have the 4 LOD models in the folder only the LOD4 animates. The main model and the LODs 1-3 all show at the right distance but they do not animate. :unsure:

 

require("scripts/class")

local class=CreateClass(...)

function class:InitDialog(grid)
self.super:InitDialog(grid)
end

function class:CreateObject(model)
local object=self.super:CreateObject(model)

       object.model:SetLODDistance(5,0)
object.model:SetLODDistance(10,1)
object.model:SetLODDistance(20,2)
object.model:SetLODDistance(30,3)
object.model:SetLODDistance(40,4)

--Walk
object.frame_Walk = 1
object.sequence_Walk = LoadAnimation(object.model,"abstract::Animation_Walk_Normal.gmf")
object.framebegin_Walk = 1
object.frameend_Walk =31
object.blend_Walk = 1.0
object.animspeed_Walk = 50.0
object.recursive_Walk = 1


    function object:Update()
--Walk
self.frame_Walk  = AppTime()/self.animspeed_Walk
self.frame_Walk  = mod(self.frame_Walk , (self.frameend_Walk - self.framebegin_Walk)) + self.framebegin_Walk
self.model:Animate(self.frame_Walk,self.blend_Walk,self.sequence_Walk,self.recursive_Walk)

    end


function object:Free(model)	

	self.super:Free()
end

function mod(a,
	return a % b
       end
end



Link to comment
Share on other sites

You actually want to load the animation onto each of the LOD meshes of the model. You can get them with the model:CountLodEntities() and model:GetLodEntity(i) commands. LOD meshes get removed from the model's children dynamically, so going through the children won't do it.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Thanks for the reply Josh. Would it look something like this?

 

for lod = 0 ,object.model:CountLodEntities() do 
	object.sequence_Walk = LoadAnimation(object.model:GetLodEntity(lod), object.animFilename)
end

 

Whatever I do with those two methods I get 'Index for object is not a valid field or method.' when I try to save the file

Link to comment
Share on other sites

Also, for those who want to see the new commands in action - I have updated Masterxilo's soldier script to include the change from 'object:Render()' to 'object:Draw()' and the new LE2.5 LOD commands shown above. The soldier.lua script is the only thing changed. The soldierGame.lua gamescript still is the same.

soldier.lua

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...