ShiVa3D
sensor and animation
All about the StoneScriptsensor and animation
by 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
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

- Posts: 55
Re: sensor and animation
by 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
http://www.shivaengine.com/developer/242-the-hunt-the-making-of#_Toc243907714
Re: sensor and animation
by 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 ?
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

- Posts: 55
Re: sensor and animation
by 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.
Re: sensor and animation
by 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 ?
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

- Posts: 55
Re: sensor and animation
by DarkSoul » 10 Jun 2012, 13:17
You can use something like this:
For make it, you need to attach this script in your animated object. You can create these sensors into the scene viewer.
- 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.
Re: sensor and animation
by 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.
Re: sensor and animation
by 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
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

- Posts: 55
Re: sensor and animation
by 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 ?
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

- Posts: 55
Re: sensor and animation
by 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
http://www.stonetrip.com/developer/forum/viewtopic.php?f=42&t=25369&p=43588&hilit=door+animation#p43588
Platform: interactive visual art
Tools: polyglot-dialogue editor
Scripts: rmi xml network example, dialogue example
Tools: polyglot-dialogue editor
Scripts: rmi xml network example, dialogue example
- Cheramu
- Senior Boarder

- Posts: 58
Re: sensor and animation
by Lourdez » 16 Jun 2012, 16:48
Right, this post works if you don't use any bones animation if I understand correctly.
Thanks.
Thanks.
- Lourdez
- Senior Boarder

- Posts: 55
Re: sensor and animation
by 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
By using different objects for the sensors, you can get a "no code" solution using:
http://www.stonetrip.com/developer/doc/api/object-bindTransformToParentSkeletonJoint
-

NiCoX - Platinum Boarder

- Posts: 5626
- Location: France
13 posts
• Page 1 of 1
