// Agrega una rotacion a partir de un vector3d void EntityTransform::addRotation(Vector3d rotation) { // Se realizan 3 rotaciones addRotationY(-rotation.y); //Es distinta por optimizacion addRotation(rotation.x, 'x'); addRotation(rotation.z, 'z'); }
void tgStructure::addRotation(const btVector3& fixedPoint, const btVector3& axis, double angle) { const btQuaternion rotation(axis, angle); addRotation(fixedPoint, rotation); }
void tgStructure::addRotation(const btVector3& fixedPoint, const btVector3& fromOrientation, const btVector3& toOrientation) { addRotation(fixedPoint, tgUtil::getQuaternionBetween(fromOrientation, toOrientation)); }
void UAimPredictionSC::SERVER_makeRotation_Implementation(FtoServerAimData data) { addRotation(data.command, data.value); if (!checkIsTolerance(data.recentRotation)) { ///send Correction CLIENT_sendCorrection(RelativeRotation); } }
/** After the slice is done rotating, replace the original cubes with the new cubes by changing the colors */ void updateCubes() { for (int i=0; i<CUBES_PER_PLANE; i++) memcpy(colors[lastRotationCubesBefore[i]],newCubeColors[i],sizeof(colors[0])); for (int i=0; i<CUBES_PER_PLANE; i++) { addRotation(lastRotationCubesBefore[i],lastRotationAxis,lastRotationWasClockwise); positions[lastRotationCubesBefore[i]] = lastRotationCubesAfter[i]; } finishedRotating = true; if (isSolved()) std::cout << "Rubik's cube solved!" << std::endl; }
void UAimPredictionSC::addYaw(float value) { if (value != 0) { addRotation(EAimCommand::horizontalAim, value); ///Send server command FtoServerAimData tempServerAimData; tempServerAimData.command = EAimCommand::horizontalAim; tempServerAimData.value = value; tempServerAimData.recentRotation = RelativeRotation; SERVER_makeRotation(tempServerAimData); } }
void BasicScreenObject::doRotate(){ rotationspeed *= rotationdrag; if (rotationspeed.length() > 0) { addRotation(rotationspeed.x, rotationspeed.y, rotationspeed.z); } if(rotationattractionforce > 0){ ofQuaternion betweenquat = rotationattractionquat-getOrientationQuat(); float betweenangle; ofVec3f dirvec(1,0,0); betweenquat.getRotate(betweenangle, dirvec); ofQuaternion nowquat = getOrientationQuat(); nowquat.slerp(rotationattractionforce, nowquat, rotationattractionquat); setOrientation(nowquat); } }
void EntityTransform::beginDraw() { SceneManager::PassMode passMode = graphicsEngine->getSceneManager()->passMode; //Si se ha modificado algo, toca generarla de nuevo if(dirty) { // Aplicamos la identidad primero ya que la traslacion indica directamente // la posicion final, no un desplazamiento transformMatrix.setIdentity(); addTranslation(translation); addRotation(rotation); addScale(scale); } // Solo apilamos en el dibujado de mallas, etc if (passMode == SceneManager::PassMode::OBJECTS) { // Apilar matriz actual glPushMatrix(); } // Camaras, aplicamos la inversa else if (passMode == SceneManager::PassMode::CAMERAS) { if(dirty) { transformMatrix = transformMatrix.inverse(); } } // La posicion de las luces se aplican en la entidad de la hoja if (passMode != SceneManager::PassMode::LIGHTS) { // Para camaras y resto de objetos // Multiplicar matriz actual por la de transformacion addOpenGLMatrix(); } dirty = false; }
void KinematicMotion::addKinematicMotion(const KinematicMotion *kinematicMotion) { addRotation(kinematicMotion->getRotationMatrix()); // step 1 addTranslation(kinematicMotion->getTranslationVector()); // step 2, order must not be changed }
void SpaceShip::update(float elapsedTime) { if(turnLeft) { addRotation(-0.090); } if(turnRight) { addRotation(0.090); } if(thrust){ addThrust(5); } else { addThrust(-2); } if(backThrust) { addThrust(-1.5); } if(thrust || turnLeft || turnRight) { direction.x = cos(rotation); direction.y = sin(rotation); } if(isFiring) { if(bulletCount < 1) { ofSpaceShipFireEventArgs e = {position, ofPoint(cos(rotation), sin(rotation))}; ofNotifyEvent(spaceShipFires, e, this); bulletCount++; } } if(timeIsDestroyed >= 0) { if(timeIsDestroyed >= 1) { resetSpaceShip(); } else { timeIsDestroyed += 0.05; } } else { position += -(direction) * speed * elapsedTime; } marginsWrap(); }