void TumblingRobot::Create(){ if(this->pScene == NULL){ #ifdef _DEBUG std::cout<< "pScene == NULL at TumblingRobot::Create()" << std::endl; #endif //_DEBUG return; } TumblingBody* body = new TumblingBody(pScene, position); TumblingArm* leftArm = new TumblingArm(pScene, position, NxVec3(-2, 0, 0), NxQuat(-10, NxVec3(0, 1, 0)) ); TumblingArm* rightArm = new TumblingArm(pScene, position, NxVec3(2, 0, 0), NxQuat(10, NxVec3(0, 1, 0)) ); NxRevoluteJointDesc leftJointDesc; leftJointDesc.setToDefault(); leftJointDesc.actor[0] = body->getActor(); leftJointDesc.actor[1] = leftArm->getActor(); leftJointDesc.setGlobalAnchor(position + NxVec3(2, 0, 0)); leftJointDesc.setGlobalAxis(NxMat33(leftArm->getLocalOrientation()) * NxVec3(1, 0, 0)); NxJoint* leftJoint = pScene->createJoint( leftJointDesc ); NxRevoluteJointDesc rightJointDesc; rightJointDesc.setToDefault(); rightJointDesc.actor[0] = body->getActor(); rightJointDesc.actor[1] = rightArm->getActor(); rightJointDesc.setGlobalAnchor(position + NxVec3(2, 0, 0)); rightArm->getLocalOrientation(); rightJointDesc.setGlobalAxis(NxMat33(rightArm->getLocalOrientation()) * NxVec3(1, 0, 0)); NxJoint* rightJoint = pScene->createJoint( rightJointDesc ); //Register Parts this->parts.push_back(body); this->parts.push_back(leftArm); this->parts.push_back(rightArm); //Register Joints this->joints.push_back(leftJoint); this->joints.push_back(rightJoint); WalkControl* cWalk = new WalkControl(pHost); ArmControl* cLeftArm = new ArmControl(pHost); ArmControl* cRightArm = new ArmControl(pHost); cWalk->addTarget(cLeftArm); cWalk->addTarget(cRightArm); clients.push_back(cWalk); clients.push_back(cLeftArm); clients.push_back(cRightArm); pHost->addClient(cWalk); pHost->addClient(cLeftArm); pHost->addClient(cRightArm); leftArm->setClient(cLeftArm); rightArm->setClient(cRightArm); return; }
void DXApp::HandleMouseMove(bool bMouseDown, int X, int Y) { if(bMouseDown) { NxVec3 Temp; Temp = Cam.location; Temp.y = 0; Temp.normalize(); Temp = Temp.cross(NxVec3(0.0f, 1.0f, 0.0f)); NxQuat(((float)(Y-OldMY))/20.0f, Temp).rotate(Cam.ViewDir); Temp = NxVec3(0.0f, 1.0f, 0.0f); NxQuat(((float)(X-OldMX))/20.0f, Temp).rotate(Cam.ViewDir); } OldMX = X; OldMY = Y; }
void Controller::updateRenderable() { if (mRenderable) { printf("Rendering...\n"); mRenderable->render(Vec3(mController->getPosition()), Quat(NxQuat(mDisplayYaw, NxVec3(0,1,0)))); } }
/*********************************************************** Constructor ***********************************************************/ PhysXActorsHandler::PhysXActorsHandler(boost::shared_ptr<PhysXEngine> Pengine, boost::shared_ptr<ActorUserData> UserData, NxActor* Actor, const LbaQuaternion& rotation) : PhysXObjectHandlerBase(Pengine, UserData), _Actor(Actor) { _Actor->setGlobalOrientationQuat(NxQuat(NxVec3(rotation.X, rotation.Y, rotation.Z), rotation.W)); #ifdef _DEBUG LogHandler::getInstance()->LogToFile("Created new PhysXActor."); #endif }
void MakeStackIcon::onRender(uint flags) { if (!enabled) return; #ifdef DXRENDER D3DMATERIAL9 stackIconMaterial = dxr->textureMaterial; stackIconMaterial.Diffuse = D3DXCOLOR(1, 1, 1, ease(alpha)); dxr->device->SetMaterial(&stackIconMaterial); Mat33 orientation(NxQuat(90, Vec3(1,0,0))); dxr->renderSideLessBox(Vec3(position.x, 10, position.z), orientation, Vec3(size / 2.0f, -size / 2.0f, 1), texMgr->getGLTextureId("widget.vertStack")); dxr->device->SetMaterial(&dxr->textureMaterial); #else glPushAttribToken token(GL_ENABLE_BIT); //glColor4f(72.0f/255., 149.0f/255., 234.0f/255., 1.0); if (alpha == 1.0) glColor4d(1, 1, 1, 1); else glColor4d(1, 1, 1, ease(alpha)); glDisable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texMgr->getGLTextureId("widget.vertStack")); glEnable(GL_BLEND); glPushMatrix(); glTranslated(position.x, 0, position.z); glScalef(size / 2.0f, 0.2f, size / 2.0f); glBegin(GL_TRIANGLE_FAN); { glNormal3f(0,1,0); glTexCoord2f(1,1); glVertex3f(-1,1,1); glTexCoord2f(0,1); glVertex3f(1,1,1); glTexCoord2f(0,0); glVertex3f(1,1,-1); glTexCoord2f(1,0); glVertex3f(-1,1,-1); } glEnd(); glPopMatrix(); #endif }
/*********************************************************** rotate object in the world ***********************************************************/ void PhysXActorsHandler::RotateTo(unsigned int time, const LbaQuaternion& Q) { _Pengine->SetActorRotation(time, _Actor, NxQuat(NxVec3(Q.X, Q.Y, Q.Z), Q.W)); }