steve3d Posted November 6, 2010 Share Posted November 6, 2010 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
frustum Posted November 6, 2010 Share Posted November 6, 2010 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
ulf.schroeter Posted November 6, 2010 Share Posted November 6, 2010 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. 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
ulf.schroeter Posted October 4, 2013 Share Posted October 4, 2013 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
binstream Posted March 12, 2014 Share Posted March 12, 2014 https://developer.unigine.com/en/docs/1.0/scripting/library/worlds/class.worldexpression Link to comment
Recommended Posts