Matthew Nicholls Posted November 7, 2011 Share Posted November 7, 2011 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. 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 Quote Link to comment Share on other sites More sharing options...
Josh Posted November 7, 2011 Share Posted November 7, 2011 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. Quote 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 More sharing options...
Matthew Nicholls Posted November 7, 2011 Author Share Posted November 7, 2011 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 Quote Link to comment Share on other sites More sharing options...
Matthew Nicholls Posted November 8, 2011 Author Share Posted November 8, 2011 solved with macklebee's help for lod = 0 , CountModelLODEntities(object.model) - 1 do object.sequence_Walk = LoadAnimation(GetModelLODEntity(object.model,lod), object.animFilename) end Quote Link to comment Share on other sites More sharing options...
macklebee Posted November 8, 2011 Share Posted November 8, 2011 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 Quote 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 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.