About Store Forum Documentation Contact



Post Reply 
Animated object on world
Author Message
gilbert Offline
Member

Post: #1
Animated object on world
Hi,

I created an animated windmill from the tutorial video and it work well with no world.

Now I am trying to add the windmill in a world and have it turn all the time when in visible range.

So I add the Windmill object to the world and indicated its class OBJ_WM which contains element ID:MyName:drop animation path.

Here my code: (WMs.elem() is true when I try accessing any propertyor method of WMs[0] it compiles but crashes )

******************************************************************************/
Game.ObjMap<Game.Animatable > WMs;
Game.ObjMap<Player > Players;
/******************************************************************************/
void InitPre()
{
EE_INIT();
App.flag=APP_MS_EXCLUSIVE;
D.viewRange(30).shadowSoft(1);

Cam.at.set(16, 0, 16);
Cam.yaw =-PI_4;
Cam.pitch =-0.5;
Cam.dist =1.4;
}
/******************************************************************************/
bool Init()
{
Physics.create(EE_PHYSX_DLL_PATH);

Game.World.activeRange(D.viewRange())
.setObjType (Players, OBJ_CHR)
.setObjType (WMs, OBJ_WM)
.New (UID(3199326727, 1331546700, 2335466931, 1420158981));

if(Game.World.settings().environment)Game.World.settings().environment->set();


return true;
}
(This post was last modified: 11-16-2014 10:03 PM by gilbert.)
11-16-2014 10:02 PM
Visit this user's website Find all posts by this user Quote this message in a reply
gilbert Offline
Member

Post: #2
RE: Animated object on world
Got it working with the code above plus this in the update function:


if(WMs.elms())
{
WMs[0].cskel.clear();
WMs[0].cskel.animate(UID(3359781711, 1168152733, 2036380578, 3681155399), Time.time());
WMs[0].cskel.updateMatrix (WMs[0].matrix());
}

Do not know if it is the wright way but it works smile

Also the OBJ_WM Class object can be left without parameters.

GT

it work for all element of same object class too. Added 5 wind mill on map and they are all turning smile

if(WMs.elms())
{
for(int i=0; i<WMs.elms(); i++)
{
WMs[i].cskel.clear();
WMs[i].cskel.animate(UID(3359781711, 1168152733, 2036380578, 3681155399), Time.time());
WMs[i].cskel.updateMatrix (WMs[i].matrix());
}
}
(This post was last modified: 11-17-2014 12:59 PM by gilbert.)
11-17-2014 12:36 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply