Jump to content

BodyRagDoll Problems


photo

Recommended Posts

Hello,

 

Here is a .node file containing the bones for a BodyRagDoll, exported from the unigine editor.

<?xml version="1.0" encoding="utf-8"?>
<nodes version="1.11">
<node type="NodeDummy" id="51">
	<transform>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</transform>
	<node type="ObjectDummy" id="52" name="bn_r_sword01">
		<body type="BodyRigid" id="28" name="bn_r_sword01">
			<shape type="ShapeBox" id="23">
				<size>0.2 1 8.8</size>
				<collision_mask>2</collision_mask>
			</shape>
		</body>
		<transform>1 6.93887e-018 0 0 5.36028e-016 1 0 0 0 -1.77636e-015 1 0 -4.76837e-007 -1.49012e-008  2.10662e-009 1</transform>
	</node>
	<node type="ObjectDummy" id="53" name="bn_l_shield01">
		<body type="BodyRigid" id="29" name="bn_l_shield01">
			<shape type="ShapeConvex" id="24">
				<vertex num_vertex="112"> /*abbreviated*/ </vertex>
				<faces num_faces="220">
					<num_vertex>/* abbreviated */</num_vertex>
					<vertex>/*abbreviated*/</vertex>
				</faces>
				<collision_mask>2</collision_mask>
			</shape>
		</body>
		<transform>1 0 4.44089e-016 0 0 1 3.55271e-015 0 5.55112e-017 0 1 0 0 -1.43842e-008 -9.53674e-007 1</transform>
	</node>
</node>
</nodes>

Here is some code that should add above bones as the bones of a ragdoll attached to a mesh.

ragdoll = new BodyRagDoll(character.mesh);
Node node = node_load("ragdolls/xsiman_ragdoll.node");
log.message("num childs" + string(node.getNumChilds())+ "\n");             // prints 2
ragdoll.setBones(node);
log.message(" ragdoll transform" + string(ragdoll.getTransform())+ "\n"); // prints identity
log.message("num Bones:" + string(ragdoll.getNumBones()) + "\n");          // prints 0 ! Why!?

 

 

 

Here we have a .node for a character, which already contains the ragdoll as specified through the unigine editor:

<?xml version="1.0" encoding="utf-8"?>
<nodes version="1.11">
<materials>
	<library>core/materials/unigine_meshes.mat</library>
	<library>demos/genesis/materials/genesis.mat</library>
</materials>
<properties>
	<library>core/properties/unigine.prop</library>
</properties>
<node type="ObjectMeshSkinned" id="34" name="xsiman_0">
	<mesh>demos/genesis/meshes/xsiman_eb.smesh</mesh>
	<surface name="GladiatorShape" collision="0" decal_mask="0" material="xsiman" property="surface_base"/>
	<body type="BodyRagDoll" id="14">
		<frame_based>1</frame_based>
		<bone>
			<body type="BodyRigid" id="20" name="bn_r_sword01">
				<shape type="ShapeBox" id="17">
					<size>0.2 1 8.8</size>
					<collision_mask>2</collision_mask>
				</shape>
			</body>
			<bone>56</bone>
			<num_childs>0</num_childs>
			<frame_based>1</frame_based>
			<transform>1 9.31323e-010 2.09548e-009 0 -7.82311e-008 1 -7.45058e-008 0 1.02562e-007 -2.98023e-008 1 0 -7.68412 -0.244391 14.8044 1</transform>
		</bone>
		<bone>
			<body type="BodyRigid" id="21" name="bn_l_shield01">
				<shape type="ShapeConvex" id="18">
					<vertex num_vertex="112"> /*abbreviated*/ </vertex>
				        <faces num_faces="220">
					<num_vertex>/* abbreviated */</num_vertex>
					<vertex>/*abbreviated*/</vertex>
					<collision_mask>2</collision_mask>
				</shape>
			</body>
			<bone>26</bone>
			<num_childs>0</num_childs>
			<frame_based>1</frame_based>
			<transform>1 0 -5.12227e-009 0 2.468e-008 9.31323e-010 1 0 5.96046e-008 -1 5.96046e-008 0 5.88709 2.13276 15.445 1</transform>
		</bone>
	</body>
	<transform>1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</transform>
</node>
</nodes>

 

Attempts to render and access this BodyRagDoll as loaded from the .node WITH body rag doll specified are unsuccessful:

Body ragdollBody = mesh.getBody();
log.message(string(is_base_class("BodyRagDoll", ragdollBody))); // prints "0" : it is only a Body, not a BodyRagDoll
log.message(typeof(ragdollBody));                                // prints "Body"
ragdollBody.renderShapes();                                      // nothing rendered

 

Attempts to construct a BodyRagDoll automatically in script as follows are unsuccessful:

ragdoll = new BodyRagDoll(mesh);
ragdoll.createBones(0.01, 0.2, 1); 
// generate the following errors:
ShapeConvex::setVertex(): can't create convex hull
// even though, the third paramter == 1, should be generating capsules, not convex hulls?
// If, the mesh provided already has a body specified in the .node file it is loaded from, 
// attempts to do this code cause crash.

 

 

Please help me with this ASAP, thank you.

Link to comment
  • 2 weeks later...

Body should be cast into the BodyRigid by body_cast() function from unigine.h:

 

Body ragdollBody = body_cast(mesh.getBody());

 

There are no such problems with samples/physics/ragdoll_ examples.

We can't check your nodes without character.mesh and demos/genesis/meshes/xsiman_eb.smesh files.

Link to comment

xsiman_rd.node already has an assigned body ragdoll.

You should delete it before new body construction.

 

ObjectMeshSkinned mesh = add_editor(node_load("xsiman_rd.node"));
mesh.setMaterial("mesh_base","*");
delete class_append(mesh.getBody());					// delete objects body
BodyRagDoll ragdoll = new BodyRagDoll(mesh);
Node node = node_load("ragdolls/xsiman_ragdoll.node");
log.message("num childs" + string(node.getNumChilds())+ "\n");             // prints 2
ragdoll.setBones(node);
node_delete(node);							// we should cleanup loaded node
log.message(" ragdoll transform" + string(ragdoll.getTransform())+ "\n"); // prints identity
log.message("num Bones:" + string(ragdoll.getNumBones()) + "\n");          // prints 2

00000.png

Link to comment

You couldn't generate ragdoll automatically, because of wrong assigned body.

 

Hi Frustum,

 

Thanks for looking into this issue.

Could you send the correctly configured files back to me by e-mail?

It is easier to see what I did incorrectly if I can see the correct version beside it.

 

 

 

Thanks,

Michael

Link to comment

Thanks for looking into this issue.

Could you send the correctly configured files back to me by e-mail?

It is easier to see what I did incorrectly if I can see the correct version beside it.

 

I didn't change node files.

The main thing was:

delete class_append(mesh.getBody());

 

You can remove body from xsiman_rd.node file via editor or by removing <body>...</body> section.

Link to comment
×
×
  • Create New...