Home Tutorials Download Beta Store Forum Documentation KnowledgeBase Wiki Blog

ShiVa3D

Return to Game programming

sensor and animation

All about the StoneScript

sensor and animation

Postby Lourdez » 09 Jun 2012, 18:18

Hi !

I loaded a model with an animation which works correctly. I attached a sensor to the model but the sensor doesn't follow the model during the animation. It stays at the initial place.

Need help
Lourdez
Senior Boarder
Senior Boarder
 
Posts: 55

Re: sensor and animation

Postby broozar » 09 Jun 2012, 21:01

you have to attach he sensors to your joints/bones, like so:
http://www.shivaengine.com/developer/242-the-hunt-the-making-of#_Toc243907714
User avatar
broozar
Platinum Boarder
Platinum Boarder
 
Posts: 3341
Location: Berlin - Germany

Re: sensor and animation

Postby Lourdez » 10 Jun 2012, 10:37

Thanks !


If I understand well this example, the zombie model has already its own skeleton from the imported model and another skeleton (rag doll) is created with sensors and attached to the zombie model by coding ? Is it right ?

Is there a way to attach the sensor to an existing bone of the imported model ?
Lourdez
Senior Boarder
Senior Boarder
 
Posts: 55

Re: sensor and animation

Postby redmotion » 10 Jun 2012, 11:43

Open up your model in the scene viewer, drag a sensor onto the screen, position how you want. Then select the sensor with one click, the bone you want to parent it to with a second click (holding ctrl). Right click and choose parent to last selected object. The sensor should follow the bone.
User avatar
redmotion
Platinum Boarder
Platinum Boarder
 
Posts: 573

Re: sensor and animation

Postby Lourdez » 10 Jun 2012, 13:01

I tried but didn't achieve. I have the standard version. Does it work for that version ?

What I did :

1 - Open the model in the scene viewer by double click on it
2 - Drag a sensor in the scene viewer. It asks "The object is not a group, converts it ?". I say yes and the sensor appears in the scene viewer grouped with the object model
3 - I select fisrt sensor then model (holding ctrl). I don't find how to select a bone
4 - click right, then group, then "Parent to last selected object"

When I play agin, the animation is still working but the sensor doesn't follow.

I also tried doing steps inside the game scene but still I don't find how to select a bone and get the same result.

Any idea ?
Lourdez
Senior Boarder
Senior Boarder
 
Posts: 55

Re: sensor and animation

Postby DarkSoul » 10 Jun 2012, 13:17

You can use something like this:

Code: Select all
--Save your main object in the variable
local hObject = this.getObject ( )
--Save the bones position
local HeadX, HeadY, HeadZ = shape.getSkeletonJointTranslation (hObject, "Head_Bone_Name", object.kGlobalSpace)
local BodyX, BodyY, BodyZ = shape.getSkeletonJointTranslation (hObject, "Body_Bone_Name", object.kGlobalSpace)
--Position sensors at the bones position
sensor.setBoxCenterAt (hObject, TheFirstSensorIndex, HeadX, HeadY, HeadZ, object.kGlobalSpace)
sensor.setBoxCenterAt (hObject, TheSecondSensorIndex, BodyX, BodyY, BodyZ, object.kGlobalSpace)


For make it, you need to attach this script in your animated object. You can create these sensors into the scene viewer.
http://www.lastvisiongames.com
Do not dream, do it.
User avatar
DarkSoul
Gold Boarder
Gold Boarder
 
Posts: 221
Location: Spain

Re: sensor and animation

Postby redmotion » 10 Jun 2012, 21:44

I don't find how to select a bone


You need to open up the scene explorer and use that to work out which bone you need to select and select it using that. I forgot to mention, you need to change the selection mode from "group" to "single" selection too.
User avatar
redmotion
Platinum Boarder
Platinum Boarder
 
Posts: 573

Re: sensor and animation

Postby Lourdez » 11 Jun 2012, 07:40

I changed the selection to single but I can't select any bone even in the scene explorer.
I'm using Shiva Editor 1.9.1.0 over parallel emulation.

Could you add screen shots, so I could figure out where is the problem ?

Thanks
Lourdez
Senior Boarder
Senior Boarder
 
Posts: 55

Re: sensor and animation

Postby Lourdez » 16 Jun 2012, 08:48

Hi !

Finally, I defined a sensor directly on the model and used DarkSoul's code to update the sensor position in OnEnterFrame Handler.

So it works.

I also would like to know if there is a solution without any code ?
Lourdez
Senior Boarder
Senior Boarder
 
Posts: 55

Re: sensor and animation

Postby Cheramu » 16 Jun 2012, 16:36

I think this post has the solution that moves the sensor with the animation.
http://www.stonetrip.com/developer/forum/viewtopic.php?f=42&t=25369&p=43588&hilit=door+animation#p43588
Cheramu
Senior Boarder
Senior Boarder
 
Posts: 60

Re: sensor and animation

Postby Lourdez » 16 Jun 2012, 16:48

Right, this post works if you don't use any bones animation if I understand correctly.

Thanks.
Lourdez
Senior Boarder
Senior Boarder
 
Posts: 55

Re: sensor and animation

Postby NiCoX » 16 Jun 2012, 17:26

Hi,

By using different objects for the sensors, you can get a "no code" solution using:
http://www.stonetrip.com/developer/doc/api/object-bindTransformToParentSkeletonJoint
User avatar
NiCoX
Platinum Boarder
Platinum Boarder
 
Posts: 5627
Location: France

Re: sensor and animation

Postby Lourdez » 17 Jun 2012, 08:53

Thanks !

It works nicely.
Lourdez
Senior Boarder
Senior Boarder
 
Posts: 55


Return to Game programming