void VectApp :: Lerp(Vect &out, const Vect &a, const Vect &b, const float t) { // out = a + t * (b - a); has 3 temporaries out.set(a[x] + t*(b[x]-a[x]), a[y] + t*(b[y]-a[y]), a[z] + t*(b[z]-a[z]) ); }
void Camera::Orbit( void ) { Vect CamFocusPos; Vect focus; focus.set(0,2.5f,-18.0f); CamFocusPos = this->vPos - focus; float angle_y = 0.001f; Matrix RotY( ROT_Y, angle_y ); CamFocusPos *= RotY; CamFocusPos += focus; this->setOrientAndPosition( Vect(0.0f,1.0f,0.0f), Vect(0.0f,2.5f,-18.0f), CamFocusPos ); }
void calcVetor () { // Initialize x, y and z elements Vect vecA; Vect vecB(1, 10, 100); // Set elements vecA.set(1, 2, 3); // Get elements double x = vecA.getx(); double y = vecA.gety(); double z = vecA.getz(); Vect vecC; // Addition and subtraction of vectors vecC = vecA + vecB; vecC += vecA; vecC = vecA - vecB; vecC -= vecA; int val = 10; // Multiplication and division of a vector and a scholar vecC = vecA * val; vecC *= val; vecC = vecA / val; vecC /= val; // Cross product vecC = vecA * vecB; // Inner product double inner = vecA % vecB; // Norm double norm = vecA.norm(); // Normalization vecC = vecA.normalize(); }
void StressTest( void ) { #if IMPLICIT_CONVERSIONS volatile int I_ValueX(2); volatile int I_ValueY(3); volatile int I_ValueZ(4); volatile char C_ValueX(7); volatile char C_ValueY(8); volatile char C_ValueZ(9); volatile double D_ValueX( 11 ); volatile double D_ValueY( 12 ); volatile double D_ValueZ( 13 ); #else volatile float I_ValueX(2); volatile float I_ValueY(3); volatile float I_ValueZ(4); volatile float C_ValueX(7); volatile float C_ValueY(8); volatile float C_ValueZ(9); volatile float D_ValueX( 11 ); volatile float D_ValueY( 12 ); volatile float D_ValueZ( 13 ); #endif // Disable warning message (simulating bad users) #pragma warning( disable : 4244 ) Vect A; A.setX( I_ValueX ); A.setY( I_ValueY ); A.setZ( I_ValueZ ); Vect B( D_ValueX, I_ValueY, D_ValueZ ); Vect C; C = A + B; Vect D( C ); D.setX( D_ValueZ ); C.setZ( I_ValueX ); Vect E = A + B; A.set( I_ValueX, D_ValueY, C_ValueX ); B = A+ B; C = B + E; E.setZ(I_ValueX ); Vect F; F.setX(C_ValueX); Vect G( F.getX(), A.getY(), B.getZ() ); Vect H( C.getZ(), C_ValueZ, F.getX() ); }
void Teddy::SetAnimationHierarchy() { // Load the model PyramidModel *pPyramidModel = new PyramidModel( "pyramidModel.azul" );pPyramidModel; // Create/Load Shader ShaderObject *pShaderObject_textureLight = new ShaderObject( ShaderName::TEXTURE_POINT_LIGHT, "texturePointLightDiff"); // Setup renderer Render_TextureLight *pRender_TextureLight = new Render_TextureLight( pShaderObject_textureLight );pRender_TextureLight; // GraphicsObject for a specific instance GraphicsObject_TextureLight *pGraphics_TextureLight;pGraphics_TextureLight; // Create GameObject Vect color; Vect pos(1,1,1); PCSTree *pTree = GameObjectMan::GetPCSTree(); root = pTree->getRoot(); GameObjectRigid *pGameRigid = new GameObjectRigid( 0 ); GameObjectMan::Add( pGameRigid, GameObjectMan::GetRoot() ); pGameRigid->setName("Rigid"); pGameRigid->scale = Vect(0.60f,0.60f,0.60f); pGameRigid->pos = Vect(50,-30,0); //// TEDDY BEAR color.set(1.00f, 1.0f, 50.00f, 1.0f); std::vector<MyGameObjectAnim*> goList; for (unsigned int i = 0; i < listHirerachy.size(); i++) { //initial pGraphics_TextureLight = new GraphicsObject_TextureLight( pPyramidModel, pRender_TextureLight, TextureName::DUCKWEED, color, pos); MyGameObjectAnim *pBone = new MyGameObjectAnim( pGraphics_TextureLight ); pBone->setIndex(listHirerachy[i].index); pBone->setName(listHirerachy[i].Name); goList.push_back(pBone); pBone->tedy = this; if(listHirerachy[i].index==0) { pFirstBone= pBone; } } for (unsigned int j = 0; j < listHirerachy.size(); j++) { //craete hierachy if( j == 0) { MyGameObjectAnim* temp = goList[0]; GameObjectMan::Add( temp, pGameRigid ); //GameObjectMan::Add( temp,GameObjectMan::GetRoot()); } else { MyGameObjectAnim* temp = goList[j]; MyGameObjectAnim* tempParent = findByIndex(goList,listHirerachy[j].ParentIndex); GameObjectMan::Add( temp, tempParent ); } } pTree->printTree(); }