csReversibleTransform operator/ ( const csReversibleTransform &t1, const csReversibleTransform &t2) { return csReversibleTransform ( t1.m_o2t * t2.m_t2o, t2.m_o2t * t1.m_t2o, t2.m_o2t * (t1.v_o2t - t2.v_o2t)); }
bool psEffectAnchorSocket::Create(const csVector3 &offset, iMeshWrapper* posAttach, bool rotateWithMesh) { static unsigned long nextUniqueID = 0; csString anchorID = "effect_anchor_socket_"; anchorID += nextUniqueID++; objBasePos = offset; objOffset = csVector3(0,0,0); this->rotateWithMesh = rotateWithMesh; if(!posAttach) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_WARNING, "planeshift_effects", "Trying to attach an effect socket anchor to nothing.\n"); return false; } cal3d = scfQueryInterface<iSpriteCal3DState> (posAttach->GetMeshObject()); if(!cal3d) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_WARNING, "planeshift_effects", "Trying to attach an effect socket anchor to an invalid mesh type.\n"); return false; } socket = cal3d->FindSocket(socketName); if(!socket) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_WARNING, "planeshift_effects", "Trying to attach an effect socket anchor to a socket that doesn't exist.\n"); return false; } mesh = engine->CreateMeshWrapper("crystalspace.mesh.object.null", anchorID); csRef<iNullMeshState> state = scfQueryInterface<iNullMeshState> (mesh->GetMeshObject()); if(!state) { Error1("No NullMeshState."); return false; } state->SetRadius(1.0); mesh->QuerySceneNode()->SetParent(posAttach->QuerySceneNode()); meshID = socket->AttachSecondary(mesh, csReversibleTransform()); posAttach->GetMovable()->UpdateMove(); isReady = false; initPos = mesh->GetMovable()->GetFullPosition(); return true; }
void BgLoader::RotateSelected(const csVector2& pos) { if(selectedMesh.IsValid()) { float factor_h = 6 * PI * ((float)previousPosition.x - pos.x) / g2d->GetHeight(); float factor_v = 6 * PI * ((float)previousPosition.y - pos.y) / g2d->GetHeight(); origRot += factor_h*currRot_h + factor_v*currRot_v; csYRotMatrix3 pitch(origRot.x); csYRotMatrix3 roll(origRot.y); csZRotMatrix3 yaw(origRot.z); csReversibleTransform trans(roll*yaw, rotBase); trans *= csReversibleTransform(pitch, -rotBase+origTrans); selectedMesh->GetMovable()->SetTransform(trans); previousPosition = pos; } }
void psEffectAnchorSocket::SetSocket(const char* name) { if(!cal3d) socketName = name; else { iSpriteCal3DSocket* newSocket = cal3d->FindSocket(name); if(newSocket) { if(socket) socket->DetachSecondary(meshID); socketName = name; socket = newSocket; meshID = socket->AttachSecondary(mesh, csReversibleTransform()); initPos = mesh->GetMovable()->GetFullPosition(); } } }
bool psEffectAnchorSocket::Update(csTicks elapsed) { if(!isReady) { if(!mesh || !mesh->GetMovable()) //not valid anchor. so tell pseffect to remove us. return false; if(initPos == mesh->GetMovable()->GetFullPosition()) return true; isReady = true; } life += (float)elapsed; if(life > animLength) life = fmod(life,animLength); if(!life) life += animLength; if(keyFrames->GetSize() == 0) return true; currKeyFrame = FindKeyFrameByTime(life); nextKeyFrame = currKeyFrame + 1; if(nextKeyFrame >= keyFrames->GetSize()) nextKeyFrame = 0; // POSITION objOffset = lerpVec(csVector3(keyFrames->Get(currKeyFrame)->actions[psEffectAnchorKeyFrame::KA_POS_X], keyFrames->Get(currKeyFrame)->actions[psEffectAnchorKeyFrame::KA_POS_Y], keyFrames->Get(currKeyFrame)->actions[psEffectAnchorKeyFrame::KA_POS_Z]), csVector3(keyFrames->Get(nextKeyFrame)->actions[psEffectAnchorKeyFrame::KA_POS_X], keyFrames->Get(nextKeyFrame)->actions[psEffectAnchorKeyFrame::KA_POS_Y], keyFrames->Get(nextKeyFrame)->actions[psEffectAnchorKeyFrame::KA_POS_Z]), keyFrames->Get(currKeyFrame)->time, keyFrames->Get(nextKeyFrame)->time, life); csMatrix3 mat; mat.Identity(); socket->SetSecondaryTransform(meshID, csReversibleTransform(mat, objOffset)); return true; }