Jump to content

[SOLVED] Need more document about WorldExpression


photo

Recommended Posts

WorldExpression seems to be very easy, but I can not find any document about how to use it, and what internal functions will be avalible. So far, I only know the getNode function can get reference to the worldexpression node, are there any more functions?

Link to comment

getNode() returns WorldExpression.

getParent() returns parent of WorldExpression node.

getNumChilds() returns number of WorldExpression children.

getChild(int num) returns specified WorldExpression child.

Link to comment

WorldExpression seems to be very easy, but I can not find any document about how to use it, and what internal functions will be avalible. So far, I only know the getNode function can get reference to the worldexpression node, are there any more functions?

 

Maybe small WorldExpression sample usage for time-based animation of ObjectMeshSkinned child node bone animation is helpful. Sample simply gets access to ObjectMeshSkinned via getChild() and animates different parts of the vehicle. time variable value is globally availabe within expressions.

 

post-82-020239100 1289032897_thumb.jpg

 

World expression code

{
Node node = getChild(0);
ObjectMeshSkinned mesh = class_cast(node.getTypeName(),node);	

int numLayers = mesh.getNumLayers();
int numBones  = mesh.getNumBones();

for( int j=0; j<numLayers; j++ )
{
for( int i=0; i<numBones; i++ )
{
	string boneName = mesh.getBoneName(i);

	mat4 boneTransform = mesh.getFrameBoneTransform(i);
	vec3 bonePivot = boneTransform.m03m13m23;

	if( strcmp( boneName,"wheel_left_0" ) == 0 || strcmp( boneName,"wheel_right_0" ) == 0 )
	{
		boneTransform =  translate( bonePivot ) * rotateZ( 20.0 * sin(3*time) ) * rotateX( -300 * time ) ;
	}
	else if( strncmp( boneName,"wheel",5 ) == 0 )
	{
		boneTransform =  translate( bonePivot ) * rotateX( -300 * time );
	}
	else if( strcmp( boneName, "hatch" ) == 0 )
	{
		boneTransform =  translate( bonePivot ) * rotateY( -60.0 * ( 1 + sin( time )  ) );
	}
	else if( strcmp( boneName, "engine_hood" ) == 0 )
	{
		boneTransform =  translate( bonePivot ) * rotateX( -35.0 * ( 1 + sin( time + 1.0 )  ) );
	}
	else if( strcmp( boneName, "mg_1" ) == 0 )
	{
		boneTransform =  translate( bonePivot ) * rotateZ( 30.0 * sin( time + 1.0 ) );
	}
	else if( strcmp( boneName, "wiper_left" ) == 0 )
	{
		boneTransform =  translate( bonePivot ) * rotateY( 55 * sin( time ) +45  );
	}
	else if( strcmp( boneName, "wiper_right" ) == 0 )
	{
		boneTransform =  translate( bonePivot ) * rotateY( 55 * sin( time ) +45  );
	}
	else if( strcmp( boneName, "door_left_0" ) == 0 )
	{
		boneTransform =  translate( bonePivot ) * rotateZ( -40.0 * ( 1 + sin( time )  ) );
	}

	mesh.setFrameBoneTransform( i, boneTransform );
}
}

}

Link to comment
  • 2 years later...

getNode() returns WorldExpression.

getParent() returns parent of WorldExpression node.

getNumChilds() returns number of WorldExpression children.

getChild(int num) returns specified WorldExpression child.

@UNIGINE: Availability of these functions within WorldExpression script should be included into documentation.

Link to comment
  • 5 months later...
×
×
  • Create New...