本文整理汇总了C++中ogre::Bone::_getDerivedOrientation方法的典型用法代码示例。如果您正苦于以下问题:C++ Bone::_getDerivedOrientation方法的具体用法?C++ Bone::_getDerivedOrientation怎么用?C++ Bone::_getDerivedOrientation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Bone
的用法示例。
在下文中一共展示了Bone::_getDerivedOrientation方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: receiveEvent
void PhysicsComponent::receiveEvent(Event* event)
{
if (event->getType() == Event::PHYSICS_UPDATE) {
btTransform transform;
transform.setIdentity();
Ogre::Vector3 position = parent->getNode()->_getDerivedPosition();
Ogre::Quaternion orientation = parent->getNode()->_getDerivedOrientation();
if (this->getParent()->getGraphicComponent()->isAnimated() && false) {
Ogre::Bone* bone = parent->getOgreEntity()->getSkeleton()->getBone(0);
Ogre::Vector3 bone_converted_pos = parent->getNode()
->convertLocalToWorldPosition(bone->_getDerivedPosition());
Ogre::Quaternion bone_converted_or = parent->getNode()
->convertLocalToWorldOrientation(bone->_getDerivedOrientation());
Ogre::Vector3 bonePos =
parent->getNode()->_getDerivedPosition() +
parent->getNode()->_getDerivedOrientation() *
bone_converted_pos;
Ogre::Quaternion boneRot = parent->getNode()->_getDerivedOrientation() * (bone
->getInitialOrientation().Inverse() * bone->_getDerivedOrientation());
position = bone_converted_pos;
orientation = boneRot;
}
transform.setOrigin(BtOgre::Convert::toBullet(position));
transform.setRotation(BtOgre::Convert::toBullet(orientation));
state->setKinematicPos(transform);
}
}
示例2: _initParticle
/** See Ogre::ParticleEmitter. */
void _initParticle(Ogre::Particle *particle)
{
Ogre::Vector3 xOff, yOff, zOff;
// Call superclass
ParticleEmitter::_initParticle(particle);
xOff = Ogre::Math::SymmetricRandom() * mXRange;
yOff = Ogre::Math::SymmetricRandom() * mYRange;
zOff = Ogre::Math::SymmetricRandom() * mZRange;
#if OGRE_VERSION >= (1 << 16 | 10 << 8 | 0)
Ogre::Vector3& position = particle->mPosition;
Ogre::Vector3& direction = particle->mDirection;
Ogre::ColourValue& colour = particle->mColour;
Ogre::Real& totalTimeToLive = particle->mTotalTimeToLive;
Ogre::Real& timeToLive = particle->mTimeToLive;
#else
Ogre::Vector3& position = particle->position;
Ogre::Vector3& direction = particle->direction;
Ogre::ColourValue& colour = particle->colour;
Ogre::Real& totalTimeToLive = particle->totalTimeToLive;
Ogre::Real& timeToLive = particle->timeToLive;
#endif
Ogre::Node* emitterBone = mEmitterBones.at(OEngine::Misc::Rng::rollDice(mEmitterBones.size()));
position = xOff + yOff + zOff +
mParticleBone->_getDerivedOrientation().Inverse() * (emitterBone->_getDerivedPosition()
- mParticleBone->_getDerivedPosition());
// Generate complex data by reference
genEmissionColour(colour);
// NOTE: We do not use mDirection/mAngle for the initial direction.
Ogre::Radian hdir = mHorizontalDir + mHorizontalAngle*Ogre::Math::SymmetricRandom();
Ogre::Radian vdir = mVerticalDir + mVerticalAngle*Ogre::Math::SymmetricRandom();
direction = (mParticleBone->_getDerivedOrientation().Inverse()
* emitterBone->_getDerivedOrientation() *
Ogre::Quaternion(hdir, Ogre::Vector3::UNIT_Z) *
Ogre::Quaternion(vdir, Ogre::Vector3::UNIT_X)) *
Ogre::Vector3::UNIT_Z;
genEmissionVelocity(direction);
// Generate simpler data
timeToLive = totalTimeToLive = genEmissionTTL();
}
示例3: getBoneWorldTransform
Transform GfxBody::getBoneWorldTransform (unsigned n)
{
checkBone(n);
Ogre::Bone *bone = skeleton->getBone(n);
Transform t(from_ogre(bone->_getDerivedPosition()), from_ogre(bone->_getDerivedOrientation()), from_ogre(bone->_getDerivedScale()));
updateWorldTransform();
return worldTransform * t;
}
示例4: getBoneWorldOrientation
Quaternion CAnimatedEntity::getBoneWorldOrientation(std::string boneName)
{
Ogre::Bone* bone = _entity->getSkeleton()->getBone(boneName);
Ogre::SceneNode *parent = _entityNode; /*node of the entity that has the skeleton*/;
Ogre::Quaternion parentQuat = _entityNode->_getDerivedOrientation();
Ogre::Quaternion boneQuat = bone->_getDerivedOrientation();
Ogre::Quaternion worldQuat = boneQuat * parentQuat; // actually, it might be parentQuat * boneQuat, I forgot
return worldQuat;
}
示例5: _updateLocatorPos
void VLogicModel::_updateLocatorPos()
{
for (VLocatorMap::iterator itr = mLocators.begin(); itr != mLocators.end(); ++itr)
{
VLocatorValue &tempValue = itr->second;
// 只更新创建出来的(已经使用的)locator node
if (tempValue.mLocatorNode != VNULL)
{
if (!tempValue.mBoneName.empty())
{
Ogre::Bone *bone = VNULL;
try
{
bone = mSkeleton->getBone(tempValue.mBoneName);
}
catch (const Ogre::Exception &e)
{
Ogre::LogManager::getSingleton().logMessage("LogicModel::_updateLocatorPos " + mName + e.getDescription());
continue;
}
assert(bone != VNULL);
Ogre::SceneNode *locatorNode = tempValue.mLocatorNode;
assert(locatorNode != VNULL);
locatorNode->setPosition(bone->_getDerivedPosition());
locatorNode->setOrientation(bone->_getDerivedOrientation());
if (tempValue.mTranslateFirst)
{
// 先平移,再旋转
locatorNode->translate(tempValue.mPosition, Ogre::Node::TS_LOCAL);
locatorNode->rotate(tempValue.mOrientation, Ogre::Node::TS_LOCAL);
}
else
{
// 先旋转,再平移
locatorNode->rotate(tempValue.mOrientation, Ogre::Node::TS_LOCAL);
locatorNode->translate(tempValue.mPosition, Ogre::Node::TS_LOCAL);
}
}
}
}
if (mLocators.size() != 0)
{
mModelMainNode->_update(true, false);
}
}
示例6: updateBoneTree
static void updateBoneTree(const Ogre::SkeletonInstance *skelsrc, Ogre::Bone *bone)
{
if(skelsrc->hasBone(bone->getName()))
{
Ogre::Bone *srcbone = skelsrc->getBone(bone->getName());
if(!srcbone->getParent() || !bone->getParent())
{
bone->setOrientation(srcbone->getOrientation());
bone->setPosition(srcbone->getPosition());
bone->setScale(srcbone->getScale());
}
else
{
bone->_setDerivedOrientation(srcbone->_getDerivedOrientation());
bone->_setDerivedPosition(srcbone->_getDerivedPosition());
bone->setScale(Ogre::Vector3::UNIT_SCALE);
}
}
Ogre::Node::ChildNodeIterator boneiter = bone->getChildIterator();
while(boneiter.hasMoreElements())
updateBoneTree(skelsrc, static_cast<Ogre::Bone*>(boneiter.getNext()));
}
示例7: handleShapes
void Animation::handleShapes(std::vector<Nif::NiTriShapeCopy>* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel){
shapeNumber = 0;
if (allshapes == NULL || creaturemodel == NULL || skel == NULL)
{
return;
}
std::vector<Nif::NiTriShapeCopy>::iterator allshapesiter;
for(allshapesiter = allshapes->begin(); allshapesiter != allshapes->end(); allshapesiter++)
{
//std::map<unsigned short, PosAndRot> vecPosRot;
Nif::NiTriShapeCopy& copy = *allshapesiter;
std::vector<Ogre::Vector3>* allvertices = ©.vertices;
//std::set<unsigned int> vertices;
//std::set<unsigned int> normals;
//std::vector<Nif::NiSkinData::BoneInfoCopy> boneinfovector = copy.boneinfo;
std::map<int, std::vector<Nif::NiSkinData::IndividualWeight> >* verticesToChange = ©.vertsToWeights;
//std::cout << "Name " << copy.sname << "\n";
Ogre::HardwareVertexBufferSharedPtr vbuf = creaturemodel->getMesh()->getSubMesh(copy.sname)->vertexData->vertexBufferBinding->getBuffer(0);
Ogre::Real* pReal = static_cast<Ogre::Real*>(vbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));
std::vector<Ogre::Vector3> initialVertices = copy.morph.getInitialVertices();
//Each shape has multiple indices
if(initialVertices.size() )
{
if(copy.vertices.size() == initialVertices.size())
{
//Create if it doesn't already exist
if(shapeIndexI.size() == static_cast<std::size_t> (shapeNumber))
{
std::vector<int> vec;
shapeIndexI.push_back(vec);
}
if(time >= copy.morph.getStartTime() && time <= copy.morph.getStopTime()){
float x;
for (unsigned int i = 0; i < copy.morph.getAdditionalVertices().size(); i++){
int j = 0;
if(shapeIndexI[shapeNumber].size() <= i)
shapeIndexI[shapeNumber].push_back(0);
if(timeIndex(time,copy.morph.getRelevantTimes()[i],(shapeIndexI[shapeNumber])[i], j, x)){
int indexI = (shapeIndexI[shapeNumber])[i];
std::vector<Ogre::Vector3> relevantData = (copy.morph.getRelevantData()[i]);
float v1 = relevantData[indexI].x;
float v2 = relevantData[j].x;
float t = v1 + (v2 - v1) * x;
if ( t < 0 ) t = 0;
if ( t > 1 ) t = 1;
if( t != 0 && initialVertices.size() == copy.morph.getAdditionalVertices()[i].size())
{
for (unsigned int v = 0; v < initialVertices.size(); v++){
initialVertices[v] += ((copy.morph.getAdditionalVertices()[i])[v]) * t;
}
}
}
}
allvertices = &initialVertices;
}
shapeNumber++;
}
}
if(verticesToChange->size() > 0){
for(std::map<int, std::vector<Nif::NiSkinData::IndividualWeight> >::iterator iter = verticesToChange->begin();
iter != verticesToChange->end(); iter++)
{
std::vector<Nif::NiSkinData::IndividualWeight> inds = iter->second;
int verIndex = iter->first;
Ogre::Vector3 currentVertex = (*allvertices)[verIndex];
Nif::NiSkinData::BoneInfoCopy* boneinfocopy = &(allshapesiter->boneinfo[inds[0].boneinfocopyindex]);
Ogre::Bone *bonePtr = 0;
Ogre::Vector3 vecPos;
Ogre::Quaternion vecRot;
std::map<Nif::NiSkinData::BoneInfoCopy*, PosAndRot>::iterator result = vecRotPos.find(boneinfocopy);
if(result == vecRotPos.end()){
bonePtr = skel->getBone(boneinfocopy->bonename);
vecPos = bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.trans;
vecRot = bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.rotation;
//.........这里部分代码省略.........
示例8: getBoneWorldOrientation
Quaternion GfxBody::getBoneWorldOrientation (unsigned n)
{
checkBone(n);
Ogre::Bone *bone = skeleton->getBone(n);
return from_ogre(bone->_getDerivedOrientation());
}
示例9: _addAllBones
PhysicsRagDoll::RagBone* PhysicsRagDoll::_addAllBones(PhysicsRagDoll::RagBone* parent, TiXmlElement* boneElement, Actor* parentActor)
{
// get the information for the bone represented by this element.
Ogre::Vector3 dir = getAttributeValueAsVector3(boneElement, "dir");
Ogre::Real length = getAttributeValueAsReal(boneElement, "length");
Ogre::Vector3 size = getAttributeValueAsVector3(boneElement, "size");
Ogre::String skeleton_bone = getAttributeValueAsStdString(boneElement, "skeleton_bone");
Ogre::Bone* ogrebone = mSkeleton->getBone(skeleton_bone);
Ogre::String shapestr = getAttributeValueAsStdString(boneElement, "shape");
PhysicsRagDoll::RagBone::BoneShape shape = PhysicsRagDoll::RagBone::BS_BOX;
if (shapestr=="box")
shape = PhysicsRagDoll::RagBone::BS_BOX;
if (shapestr=="capsule")
shape = PhysicsRagDoll::RagBone::BS_CAPSULE;
if (shapestr=="cylinder")
shape = PhysicsRagDoll::RagBone::BS_CYLINDER;
if (shapestr=="cone")
shape = PhysicsRagDoll::RagBone::BS_CONE;
if (shapestr=="ellipsoid")
shape = PhysicsRagDoll::RagBone::BS_ELLIPSOID;
if (shapestr=="hull")
shape = PhysicsRagDoll::RagBone::BS_CONVEXHULL;
Ogre::Real mass = getAttributeValueAsReal(boneElement, "mass");
///////////////////////////////////////////////////////////////////////////////
RagBone* me = _addBone(mWorld, parent, dir, shape, size, mass, ogrebone, parentActor);
///////////////////////////////////////////////////////////////////////////////
// position the bone.
Ogre::Quaternion boneorient = mNode->_getDerivedOrientation() * ogrebone->_getDerivedOrientation();
Ogre::Vector3 bonepos;
if (shape != PhysicsRagDoll::RagBone::BS_CONVEXHULL)
bonepos = mNode->_getFullTransform() * ogrebone->_getDerivedPosition() + (boneorient * (dir * (length*0.5f)));
else
bonepos = mNode->_getFullTransform() * ogrebone->_getDerivedPosition();
if (me->getBody())
me->getBody()->setPositionOrientation(bonepos, boneorient);
// set offsets
if (!parent)
{
Ogre::Quaternion offsetorient = (boneorient.Inverse()) * mNode->_getDerivedOrientation();
Ogre::Vector3 offsetpos = boneorient.Inverse() * (mNode->_getDerivedPosition() - bonepos);
me->setOffset(offsetorient, offsetpos);
}
// get the joint to connect this bone with it's parent.
if (parent && me->getBody())
{
TiXmlElement* jointElement = getChildNamed(boneElement, "Joint");
if (!jointElement)
{
// error!
LOG_ERROR(Logger::CORE, " Joint not found while creating Ragdoll! ");
return me;
}
Ogre::Vector3 jointpin = getAttributeValueAsVector3(jointElement, "pin");
Ogre::String jointtypestr = getAttributeValueAsStdString(jointElement, "type");
PhysicsRagDoll::JointType jointtype = PhysicsRagDoll::JT_BALLSOCKET;
if (jointtypestr == "ballsocket")
jointtype = PhysicsRagDoll::JT_BALLSOCKET;
if (jointtypestr == "hinge")
jointtype = PhysicsRagDoll::JT_HINGE;
Ogre::Real limit1 = getAttributeValueAsReal(jointElement, "limit1");
Ogre::Real limit2 = getAttributeValueAsReal(jointElement, "limit2");
Ogre::Vector3 jpos = mNode->_getFullTransform() * ogrebone->_getDerivedPosition();
Ogre::Vector3 jpin = (mNode->_getDerivedOrientation() * parent->getOgreBone()->_getDerivedOrientation()) * jointpin;
_joinBones(jointtype, parent, me, jpos, jpin, limit1, limit2, mWorld);
}
LOG_MESSAGE(Logger::CORE, " added bone from '"+ogrebone->getName()+"'.");
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// add all children of this bone.
for (TiXmlNode* cur = boneElement->FirstChild(); cur; cur = cur->NextSibling())
{
if (cur->Type() == TiXmlNode::ELEMENT && hasNodeName(cur, "Bone"))
{
//.........这里部分代码省略.........