![]() |
Beaming Scene Service
2.0
RakNet wrapper for managing data communications between multiple Beaming clients
|
00001 #ifndef AVATARS_S3D 00002 #define AVATARS_S3D 00003 var Avatars; 00004 var skinShader; 00005 00006 // #define DEBUGAVATARS 00007 00008 00009 function InitAvatars() 00010 { 00011 00012 #ifdef DEBUGAVATARS 00013 Avatars = CVmExternDLL( "HALCAWin32_d.dll" ); 00014 OutPutLn("Loaded Avatars debug dll"); 00015 #else 00016 Avatars = CVmExternDLL( "HALCAWin32.dll" ); 00017 #endif 00018 00019 Avatars.__AddFunction( C_VOID, "Idle"); //updates animations 00020 Avatars.__AddFunction( C_VOID, "IdleOne",C_INT); //updates animation of character with AvatarID 00021 Avatars.__AddFunction( C_VOID, "setLocalDir",C_PCHAR,C_PCHAR,C_PCHAR); 00022 Avatars.__AddFunction( C_INT, "addCharacter",C_PCHAR,C_PCHAR); // adds a new character first parameter directory, second, cfg name 00023 Avatars.__AddFunction( C_INT, "loadShaders",C_PCHAR, C_PCHAR, C_PCHAR, C_PCHAR);//loads fragment geometry and vertex shader and returns shader linker log 00024 Avatars.__AddFunction( C_VOID, "Draw",C_FLOAT); //draws all avatars 00025 Avatars.__AddFunction( C_VOID, "DrawExtShader"); //draws all avatars with External shader 00026 Avatars.__AddFunction( C_VOID, "DrawExtShaderOne",C_INT); //draws avatar with the given avatarID using the external shader 00027 Avatars.__AddFunction( C_VOID, "drawBoundsAndSkeleton"); //draws skeleton and bounding boxes of all avatars, useful when using external shader. 00028 Avatars.__AddFunction( C_INT, "getProgramID"); //Gets the ID of the current shader program 00029 Avatars.__AddFunction( C_VOID, "loadUniAndAttrIDs",C_INT); //Gets the ID of the current shader program 00030 Avatars.__AddFunction( C_VOID, "setDT",C_FLOAT); //set delta t for animations 00031 Avatars.__AddFunction( C_VOID, "setAccumulativeRoot",C_INT,C_INT); //set root node to accumulate animation changes 00032 00033 Avatars.__AddFunction( C_FLOAT, "getAnimationDuration",C_INT,C_INT);// AvatarID, AnimationID returns the duration of the specified animation in seconds 00034 Avatars.__AddFunction( C_INT, "getAnimationCount",C_INT);// AvatarID, returns the number of animations that the avatar AvatarID has loaded. 00035 Avatars.__AddFunction( C_PCHAR, "getAnimationFilename",C_INT,C_INT);// AvatarID, AnimationID, returns the filename of the animation specified by AvatarIDn and AnimationID 00036 Avatars.__AddFunction( C_PCHAR, "getAnimationName",C_INT,C_INT);// AvatarID, AnimationID, returns the name of the animation specified by AvatarIDn and AnimationID 00037 Avatars.__AddFunction( C_INT, "getAnimationId",C_INT,C_PCHAR);// AvatarID, AnimationID, returns the id of the animation specified by AvatarIDn and AnimationName 00038 Avatars.__AddFunction( C_FLOAT, "getAnimationTime",C_INT,C_INT);// AvatarID, AnimationID, returns the time at which point the specified animation is currently played 00039 00040 Avatars.__AddFunction( C_VOID, "useTextureUnit",C_INT); //specifies the texture Unit that the avatar rendering use for diffues and alpha textures specified in their materials 00041 00042 00043 Avatars.__AddFunction( C_VOID, "setDTOne",C_INT, C_FLOAT); //AvatarId, DeltaT, sets deltaT for individual Avatar 00044 Avatars.__AddFunction( C_FLOAT, "getDTOne",C_INT); //AvatarId, returns currently set DeltaT for this Avatar 00045 00046 Avatars.__AddFunction( C_VOID, "ShutDown"); //removes all characters and animations etc. 00047 Avatars.__AddFunction( C_VOID, "exeAct",C_INT,C_INT,C_FLOAT,C_FLOAT,C_FLOAT, C_INT);// AvatarID, AnimationID, inTime, outTime, weight, lock 00048 Avatars.__AddFunction( C_VOID, "exeActAt",C_INT,C_INT,C_FLOAT,C_FLOAT,C_FLOAT, C_INT,C_FLOAT);// AvatarID, AnimationID, inTime, outTime, weight, lock, startTime 00049 Avatars.__AddFunction( C_VOID, "exeActPart",C_INT,C_INT,C_FLOAT,C_FLOAT,C_FLOAT, C_INT,C_FLOAT,C_FLOAT);// AvatarID, AnimationID, inTime, outTime, weight, lock, startTime 00050 Avatars.__AddFunction( C_VOID, "removeAct",C_INT,C_INT);// AvatarID, AnimationID 00051 Avatars.__AddFunction( C_INT, "isExecuting",C_INT,C_INT);// AvatarID, AnimationID, 00052 00053 00054 Avatars.__AddFunction( C_VOID, "setCycleAsync",C_INT,C_INT,C_FLOAT); // sets a cycling animation's state to asychronous AvatarID,AnimationID, Delay 00055 Avatars.__AddFunction( C_VOID, "blendCycle",C_INT,C_INT,C_FLOAT,C_FLOAT); // Blends in an animation with the parameters:AvatarID, AnimationID,Weight, Delay 00056 Avatars.__AddFunction( C_VOID, "blendCycleN",C_INT,C_INT,C_FLOAT,C_FLOAT,C_INT); // Blends in an animation with the parameters:AvatarID, AnimationID,Weight, Delay, number of cycles 00057 Avatars.__AddFunction( C_VOID, "blendCycleNMask",C_INT,C_INT,C_PFLOAT,C_FLOAT,C_INT); // Blends in an animation with the parameters:AvatarID, AnimationID,Weight, Delay, number of cycles 00058 Avatars.__AddFunction( C_VOID, "clearCycle",C_INT,C_INT); // Removes an Animation from the currently bleded ones with the Parameters: AvatarID, AnimationID 00059 Avatars.__AddFunction( C_INT, "isCycling",C_INT,C_INT); // Returns if the animation with parameres AvatarID, AnimationID is blended in at the moment 00060 Avatars.__AddFunction( C_INT, "setMorph",C_INT,C_INT,C_FLOAT); // sets the animation AnimationID of character AvatarID to morph value 00061 Avatars.__AddFunction( C_INT, "incMorph",C_INT,C_INT,C_FLOAT); // increases the animation AnimationID of character AvatarID by morph value 00062 Avatars.__AddFunction( C_INT, "addMorph",C_INT,C_INT); // adds animationID of character AvatarID to Morphable animations. 00063 Avatars.__AddFunction( C_INT, "removeMorph",C_INT,C_INT); // removes animationID of character AvatarID from morphable animations. 00064 00065 00066 Avatars.__AddFunction( C_INT, "setModel",C_INT); // sets an external Cal3D Model to give control to an external application 00067 00068 Avatars.__AddFunction( C_VOID, "setWireFrame",C_INT,C_INT); //AvatarID, 0/1, renders the character in wireframe. only possible with TransformType VertexArray at the moment 00069 Avatars.__AddFunction( C_VOID, "showSkel",C_INT); // visualise all characters' skeleton 00070 Avatars.__AddFunction( C_VOID, "showBody",C_INT); // visualise all characters' body 00071 Avatars.__AddFunction( C_VOID, "showBB",C_INT); // visualise all characters' bounding boxes 00072 Avatars.__AddFunction( C_VOID, "setRotation",C_INT,C_INT,C_PFLOAT);// AvatarID, JointID, rotation as quaternion 00073 Avatars.__AddFunction( C_VOID, "setRotationMatrixAbs",C_INT,C_INT,C_PFLOAT);// AvatarID, JointID, rotation as quaternion 00074 Avatars.__AddFunction( C_VOID, "setRotationAbs",C_INT,C_INT,C_PFLOAT);// AvatarID, JointID, rotation as quaternion, rotation is done absolute using parent bones inverse 00075 Avatars.__AddFunction( C_VOID, "addRotationMatrix",C_INT,C_INT,C_PFLOAT);// AvatarID, JointID, rotation as 3x3 matrx, rotation is done taking multiplying with the current rotation 00076 Avatars.__AddFunction( C_VOID, "addRotationEuler",C_INT,C_INT,C_PFLOAT);// AvatarID, JointID, rotation as Euler angles, rotation is done taking multiplying with the current rotation 00077 Avatars.__AddFunction( C_VOID, "addRotation",C_INT,C_INT,C_PFLOAT);// AvatarID, JointID, rotation quaternion, rotation is done taking multiplying with the current rotation 00078 00079 Avatars.__AddFunction( C_VOID, "addRotationAbs",C_INT,C_INT,C_PFLOAT);// AvatarID, JointID, rotation quaternion, rotation is done taking multiplying with the current rotation 00080 00081 00082 Avatars.__AddFunction( C_VOID, "setRotationEuler",C_INT,C_INT,C_PFLOAT);// AvatarID, JointID, rotation as Euler 00083 Avatars.__AddFunction( C_VOID, "setRotationEulerAbs",C_INT,C_INT,C_PFLOAT);// AvatarID, JointID, rotation as Euler, rotation is done absolute using parent bones inverse 00084 00085 Avatars.__AddFunction( C_VOID, "getRotation",C_INT,C_INT,C_PFLOAT);// AvatarID, JointID, relative rotation as quaternion using xyzw 00086 Avatars.__AddFunction( C_VOID, "getRotationAA",C_INT,C_INT,C_PFLOAT);// AvatarID, JointID, relative rotation as angle axis 00087 Avatars.__AddFunction( C_VOID, "getRotationEuler",C_INT,C_INT,C_PFLOAT);// AvatarID, JointID, relative rotation as Euler angles 00088 Avatars.__AddFunction( C_VOID, "getRotationAAAbs",C_INT,C_INT,C_PFLOAT);// AvatarID, JointID, absolute rotation as angle axis 00089 Avatars.__AddFunction( C_VOID, "getRotationEulerAbs",C_INT,C_INT,C_PFLOAT);// AvatarID, JointID, absolute rotation as Euler angle 00090 Avatars.__AddFunction( C_VOID, "getRotationAbs",C_INT,C_INT,C_PFLOAT);// AvatarID, JointID, absolute rotation as quaternion using xyzw 00091 Avatars.__AddFunction( C_VOID, "getRotationMatrixAbs",C_INT,C_INT,C_PFLOAT);// AvatarID, JointID, absolute rotation as 3x3 rotation Matrix 00092 Avatars.__AddFunction( C_VOID, "getBoneBB",C_INT,C_INT,C_PFLOAT);// AvatarID, JointID, 24 vector containing positions of 8 corner points 00093 Avatars.__AddFunction( C_VOID, "updateBoneBB",C_INT,C_INT);// AvatarID, JointID, updates the bounding box of the specified bone 00094 00095 Avatars.__AddFunction( C_PCHAR, "getBoneName",C_INT,C_INT);// AvatarID, JointID, string containing the name of the bone 00096 00097 Avatars.__AddFunction( C_PCHAR, "getBoneChildIds",C_INT,C_INT);// AvatarID, JointID, string containing the ids of the bone children 00098 Avatars.__AddFunction( C_INT, "getBoneParentId",C_INT,C_INT);// AvatarID, JointID, int containing bone parentId 00099 Avatars.__AddFunction( C_VOID, "setVertexWeightThreshold",C_INT,C_FLOAT);// AvatarID, weight threshold 00100 Avatars.__AddFunction( C_INT, "getNumGPUMeshes",C_INT);// AvatarID 00101 Avatars.__AddFunction( C_VOID, "setMaxBonesPerMesh",C_INT);// maxBonesPerMesh for all avatars 00102 Avatars.__AddFunction( C_VOID, "selectMesh",C_INT,C_INT);// AvatarID, MeshID 00103 00104 Avatars.__AddFunction( C_INT, "isPointInside",C_INT,C_PFLOAT);// AvatarID, Vec3, returns Joint id of bone that has the position of vec3 inside. if no bone bounding box has it inside -1 is returned 00105 Avatars.__AddFunction( C_INT, "isPointInsideCyl",C_INT,C_PFLOAT,C_FLOAT);// // AvatarID, Vec3, SphereRadius returns Joint id of bone that has the position of vec3 with radius SpherRadius inside. if no bone bounding cylinder has it inside -1 is returnedreturned 00106 Avatars.__AddFunction( C_FLOAT, "getBoneBoundingCylinderRadius",C_INT,C_INT);// AvatarID, JointID, returns Returns radius of specified bone -1 if bone or avatarid is invalid. 00107 Avatars.__AddFunction( C_FLOAT, "distanceToBoundingCylinder",C_INT,C_INT);// AvatarID, JointID, returns distance between specified bone and point. 00108 00109 Avatars.__AddFunction( C_VOID, "setModelScale",C_INT,C_PFLOAT);// AvatarID, Vec3, changes the scale of the avatar. 00110 Avatars.__AddFunction( C_PFLOAT_3, "getModelScale",C_INT);// AvatarID retrieves the current scale of the avatar. 00111 00112 Avatars.__AddFunction( C_VOID, "setAllBoneState",C_INT,C_PFLOAT);// AvatarID, Vec3, changes the scale of the avatar. 00113 Avatars.__AddFunction( C_VOID, "getAllBoneState",C_INT,C_PFLOAT);// AvatarID retrieves the current scale of the avatar. 00114 00115 00116 00117 00118 Avatars.__AddFunction( C_VOID, "getRotationAAbs",C_INT,C_INT,C_PFLOAT);// AvatarID, JointID, bone space rotation as angle axis 00119 Avatars.__AddFunction( C_VOID, "lookAt",C_INT,C_INT,C_PFLOAT,C_PFLOAT);// AvatarID, JointID, from Vec3, to Vec3 00120 Avatars.__AddFunction( C_INT, "getBoneId",C_INT,C_PCHAR);// AvatarID, substring of bone name, returns boneID 00121 Avatars.__AddFunction( C_VOID, "getInverseParentRotation",C_INT,C_INT,C_PFLOAT);// AvatarID, boneId, returns 3x3 transposed matrix of absolute parent rotation 00122 Avatars.__AddFunction( C_VOID, "setTranslation",C_INT,C_INT,C_PFLOAT);// sets the translation with the parameters: AvatarID, JointID, set relative translation Vec3 00123 Avatars.__AddFunction( C_VOID, "getTranslation",C_INT,C_INT,C_PFLOAT);// gets the translation with the parameters: AvatarID, JointID, get relative translation Vec3 00124 Avatars.__AddFunction( C_VOID, "getTranslationAbs",C_INT,C_INT,C_PFLOAT);// gets the translation with the parameters:AvatarID, JointID, get absolute translation Vec3 00125 Avatars.__AddFunction( C_VOID, "getTranslationOGL",C_INT,C_INT,C_PFLOAT); // AvatarID, JointID, get relative translation Vec3 OpenGL space 00126 Avatars.__AddFunction( C_VOID, "getTranslationAbsOGL",C_INT,C_INT,C_PFLOAT); // AvatarID, JointID, get absolute translation Vec3 OpenGL space 00127 Avatars.__AddFunction( C_INT, "getNumBone",C_INT);// Returns the number of bones if the Avatar with AvatarID 00128 Avatars.__AddFunction( C_INT, "numCharacters");// Returns the number of Avatars loaded 00129 Avatars.__AddFunction( C_INT, "loadAnimation",C_INT,C_PCHAR);// loads an animation to AvatarID with the filename specified 00130 Avatars.__AddFunction( C_VOID, "setTransformType",C_INT); //which type of transformations is sent to the GPU ? 0 Vertex Array, 1 Matrix, 2 rotmat&transmat, 3 Quaternion, encoded quaternion? 00131 Avatars.__AddFunction( C_VOID, "exeMorph",C_INT,C_INT,C_FLOAT,C_FLOAT);//Executes a morph animation AvatarID, MorphID,seconds,delay 00132 Avatars.__AddFunction( C_VOID, "clearMorph",C_INT,C_INT,C_FLOAT);//Removes a morph animation AvatarID, MorphID,delay 00133 Avatars.__AddFunction( C_VOID, "loadEnvMap",C_PCHAR);//loads an environment map that can be used in shaders to render characters 00134 Avatars.__AddFunction( C_VOID, "DrawGrid"); // draws a grid for debugging purpose. 00135 Avatars.__AddFunction( C_VOID, "doIK",C_INT,C_INT,C_INT,C_PFLOAT,C_FLOAT,C_INT); // Inverse Kinematics with parameters: AvatarID, startBoneId, endBoneId, targetPos, tolerance, iterations 00136 Avatars.__AddFunction( C_VOID, "PointAt",C_INT,C_INT,C_PFLOAT); // PointAt behaviour with the parameters: AvatarID, startBoneId, targetPos 00137 Avatars.__AddFunction( C_VOID, "ogreLookAt",C_INT,C_INT,C_PFLOAT,C_INT); // LookAt Behaviour with the paramteres: AvatarID, startBoneId, targetPos, opposite direction(0/1) 00138 Avatars.__AddFunction( C_VOID, "setUpIK3",C_INT,C_INT,C_INT,C_PFLOAT,C_FLOAT,C_INT); // Setup Inverse Kinematics from Maya with the paramters: AvatarID, startBoneId, endBoneId, targetPos, tolerance, iterations 00139 Avatars.__AddFunction( C_VOID, "doIK3",C_INT,C_INT,C_INT,C_PFLOAT,C_FLOAT,C_INT); // Setup Inverse Kinematics from Maya with the paramters: AvatarID, startBoneId, endBoneId, targetPos, tolerance, iterations 00140 Avatars.__AddFunction( C_VOID, "doIKCCD",C_INT,C_INT,C_INT,C_PFLOAT,C_FLOAT,C_INT); // Inverse Kinematics using ICCD with the paramters: AvatarID, startBoneId, endBoneId, targetPos, tolerance, iterations 00141 00142 Avatars.__AddFunction( C_VOID, "lockBone",C_INT,C_INT);// AvatarID, JointID, locks the bone so that it can be edited manually 00143 Avatars.__AddFunction( C_VOID, "resetBone",C_INT,C_INT);// AvatarID, JointID, locks the bone so that it can be edited manually 00144 00145 00146 Avatars.__AddFunction( C_INT, "FileOpen",C_PCHAR); // open file 00147 Avatars.__AddFunction( C_VOID, "FileWrite",C_PCHAR); // write to file 00148 Avatars.__AddFunction( C_VOID, "FileClose"); // close file 00149 00150 Avatars.__AddFunction( C_VOID, "writeFrameAsJpeg",C_PCHAR,C_INT); // FIlename, imagequality, writes the current OpenGL framebuffer to a jpg image with given filename and quality 00151 00152 00153 Avatars.__AddFunction(C_VOID,"setUseTBO",C_INT); //if set to 1 a texture buffer object is used for morph targets 00154 00155 Avatars.showBB(0); 00156 Avatars.showSkel(0); 00157 Avatars.showBody(1); 00158 00159 00160 Var shaderlog=space(1024); 00161 00162 #ifdef VA_TRANS 00163 Avatars.setTransformType(0); //which type of transformations is sent to the GPU ? 0 Vertex Array, 1 Matrix, 2 rotmat&transmat, 3 Quaternion, encoded quaternion? 00164 #endif 00165 00166 #ifdef DQUAT_TRANSF 00167 Avatars.setTransformType(6); 00168 var logf=space(1024);//dquat.geom 00169 Avatars.loadShaders("dquat.vert","dquat.geom","dquat.frag",logf); 00170 outputln(logf); 00171 #endif 00172 00173 00174 #ifdef DQUAT_TRANSF_XVRSHADER 00175 Avatars.setTransformType(6); //which type of transformations is sent to the GPU ? 0 Vertex Array, 1 Matrix, 2 rotmat&transmat, 3 Quaternion, encoded quaternion? 00176 Avatars.setMaxBonesPerMesh(30);//should reflect the number of dual quaternions in the shader 00177 skinShader=loadShader("skinshDQuat.sh"); 00178 // skinShaderNoShadows=loadShader("skinshNoShadows.sh"); 00179 skinShader.start(); 00180 // Avatars.setUniAndAttrIDs(4,1,2,3,15,45,75,9012); 00181 Avatars.loadUniAndAttrIDs(0); 00182 skinShader.stop(); 00183 #endif 00184 00185 #ifdef TM_TRANSF_XVRSHADER 00186 Avatars.setTransformType(1); //which type of transformations is sent to the GPU ? 0 Vertex Array, 1 Matrix, 2 rotmat&transmat, 3 Quaternion, encoded quaternion? 00187 Avatars.setMaxBonesPerMesh(30);//should reflect the number of transforms in the shader 00188 #ifdef ENVMAPON 00189 skinShader=loadShader("skinshTMEnv.sh"); 00190 #else 00191 skinShader=loadShader("skinshTM.sh"); 00192 #endif 00193 skinShader.start(); 00194 Avatars.loadUniAndAttrIDs(0); 00195 skinShader.stop(); 00196 #endif 00197 } 00198 00199 #endif