本文整理汇总了C++中ogre::SceneNode::_getDerivedScale方法的典型用法代码示例。如果您正苦于以下问题:C++ SceneNode::_getDerivedScale方法的具体用法?C++ SceneNode::_getDerivedScale怎么用?C++ SceneNode::_getDerivedScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::SceneNode
的用法示例。
在下文中一共展示了SceneNode::_getDerivedScale方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: srand
void OBTutorial2::createBoxShape(Ogre::Entity* entity, Ogre::Vector3 position, bool bStatic)
{
Ogre::SceneNode *node = entity->getParentSceneNode();
Vector3 size = node->_getDerivedScale()*entity->getBoundingBox().getHalfSize();
float mass = bStatic ? 0.0f : 1.0f;
srand( (unsigned)time( NULL ) );
node->setPosition(position);
node->setOrientation(Quaternion(Degree(Ogre::Math::RangeRandom(0.0,60.0)), Vector3::UNIT_Y));
btBoxShape *sceneBoxShape = new btBoxShape(toBulletVector(size)); // konvertovat vektor size
// and the Bullet rigid body
MyMotionState * defaultMotionState = new MyMotionState(btTransform(btQuaternion(btScalar(0),btScalar(0),btScalar(0),btScalar(1))), node);
btRigidBody *defaultBody = new btRigidBody(btScalar(1), defaultMotionState, sceneBoxShape);
/* defaultBody->setShape(node,
sceneBoxShape,
0.6f, // dynamic body restitution
0.6f, // dynamic body friction
mass, // dynamic bodymass
node->_getDerivedPosition(), // starting position of the box
node->_getDerivedOrientation()); // orientation of the box**/
mShapes.push_back(sceneBoxShape);
mBodies.push_back(defaultBody);
mNumEntitiesInstanced++;
}
示例2: LocalToWorld
float3x4 EC_Mesh::LocalToWorld() const
{
if (!entity_)
{
LogError(QString("EC_Mesh::LocalToWorld failed! No entity exists in mesh \"%1\" (entity: \"%2\")!").arg(meshRef.Get().ref).arg(ParentEntity() ? ParentEntity()->Name() : "(EC_Mesh with no parent entity)"));
return float3x4::identity;
}
Ogre::SceneNode *node = entity_->getParentSceneNode();
if (!node)
{
LogError(QString("EC_Mesh::LocalToWorld failed! Ogre::Entity is not attached to a Ogre::SceneNode! Mesh \"%1\" (entity: \"%2\")!").arg(meshRef.Get().ref).arg(ParentEntity() ? ParentEntity()->Name() : "(EC_Mesh with no parent entity)"));
return float3x4::identity;
}
assume(!float3(node->_getDerivedScale()).IsZero());
float3x4 tm = float3x4::FromTRS(node->_getDerivedPosition(), node->_getDerivedOrientation(), node->_getDerivedScale());
assume(tm.IsColOrthogonal());
return tm;
}
示例3: FindClosestPolygon
void Renderer::FindClosestPolygon(Ogre::Entity* entity, float& closestDistance,
Ogre::Vector3& position, Ogre::Vector3& normal)
{
closestDistance = std::numeric_limits<float>::max(); // default value (means
// nothing detected)
// Get transformation
Ogre::SceneNode* parentNode = entity->getParentSceneNode();
Ogre::Vector3 parentPos;
Ogre::Quaternion parentOrientation;
Ogre::Vector3 parentScale;
if (parentNode)
{
parentPos = parentNode->_getDerivedPosition();
parentOrientation = parentNode->_getDerivedOrientation();
parentScale = parentNode->_getDerivedScale();
}
else
{
parentPos = Ogre::Vector3::ZERO;
parentOrientation = Ogre::Quaternion::IDENTITY;
parentScale = Ogre::Vector3::UNIT_SCALE;
}
// Handle animated entities
bool isAnimated = entity->hasSkeleton();
if (isAnimated)
{
entity->addSoftwareAnimationRequest(false);
entity->_updateAnimation();
}
// Loop through each submesh
Ogre::MeshPtr mesh = entity->getMesh();
for (uint i = 0; i < mesh->getNumSubMeshes(); ++i)
{
Ogre::SubMesh* subMesh = mesh->getSubMesh(i);
// Ignore anything that isn't a triangle List
if (subMesh->operationType != Ogre::RenderOperation::OT_TRIANGLE_LIST)
continue;
// Get the vertex data
Ogre::VertexData* vertexData;
if (subMesh->useSharedVertices)
{
if (isAnimated)
vertexData = entity->_getSkelAnimVertexData();
else
vertexData = mesh->sharedVertexData;
}
else
{
if (isAnimated)
vertexData = entity->getSubEntity(i)->_getSkelAnimVertexData();
else
vertexData = subMesh->vertexData;
}
// Get the size of one vertex
const Ogre::VertexElement* posEl =
vertexData->vertexDeclaration->findElementBySemantic(Ogre::VES_POSITION);
Ogre::HardwareVertexBufferSharedPtr vBuff =
vertexData->vertexBufferBinding->getBuffer(posEl->getSource());
uint vertexSize = vBuff->getVertexSize();
// Save pointer to first vertex
short* pVertex = (short*)vBuff->lock(Ogre::HardwareBuffer::HBL_READ_ONLY);
short* pStartVertex = pVertex;
// Get the index buffer
// If it is null then skip as it must be a point cloud
Ogre::HardwareIndexBufferSharedPtr iBuff = subMesh->indexData->indexBuffer;
if (iBuff.isNull())
continue;
uint* pLong = (uint*)iBuff->lock(Ogre::HardwareBuffer::HBL_READ_ONLY);
uint16_t* pShort = (uint16_t*)pLong;
// Look through each vertex and check each triangle with the ray
Ogre::Vector3 vertexPos;
Ogre::Vector3 vertex1;
Ogre::Vector3 vertex2;
float* pReal;
uint index;
for (uint k = 0; k < subMesh->indexData->indexCount; k++)
{
// Read index value
if (iBuff->getType() == Ogre::HardwareIndexBuffer::IT_32BIT) // if 32bit indexes
{
index = (uint)pLong[k];
}
else
{
index = (uint)pShort[k];
}
// Read referenced vertex
pVertex = pStartVertex + (vertexSize * index); // calculate pointer
//.........这里部分代码省略.........
示例4: insertMesh
//.........这里部分代码省略.........
float size = std::max(std::max(extents.x, extents.y), extents.z);
bool small = (size < Settings::Manager::getInt("small object size", "Viewing distance")) && Settings::Manager::getBool("limit small object distance", "Viewing distance");
// do not fade out doors. that will cause holes and look stupid
if (ptr.getTypeName().find("Door") != std::string::npos)
small = false;
if (mBounds.find(ptr.getCell()) == mBounds.end())
mBounds[ptr.getCell()] = Ogre::AxisAlignedBox::BOX_NULL;
mBounds[ptr.getCell()].merge(bounds);
bool transparent = false;
for(size_t i = 0;i < entities.mEntities.size();i++)
{
Ogre::Entity *ent = entities.mEntities[i];
for (unsigned int i=0; i<ent->getNumSubEntities(); ++i)
{
Ogre::MaterialPtr mat = ent->getSubEntity(i)->getMaterial();
Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator();
while (techIt.hasMoreElements())
{
Ogre::Technique* tech = techIt.getNext();
Ogre::Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements())
{
Ogre::Pass* pass = passIt.getNext();
if (pass->getDepthWriteEnabled() == false)
transparent = true;
}
}
}
}
if(!mIsStatic || !Settings::Manager::getBool("use static geometry", "Objects") || transparent)
{
for(size_t i = 0;i < entities.mEntities.size();i++)
{
Ogre::Entity *ent = entities.mEntities[i];
ent->setRenderingDistance(small ? Settings::Manager::getInt("small object distance", "Viewing distance") : 0);
ent->setVisibilityFlags(mIsStatic ? (small ? RV_StaticsSmall : RV_Statics) : RV_Misc);
ent->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
}
}
else
{
Ogre::StaticGeometry* sg = 0;
if (small)
{
if( mStaticGeometrySmall.find(ptr.getCell()) == mStaticGeometrySmall.end())
{
uniqueID = uniqueID +1;
sg = mRenderer.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID));
mStaticGeometrySmall[ptr.getCell()] = sg;
sg->setRenderingDistance(Settings::Manager::getInt("small object distance", "Viewing distance"));
}
else
sg = mStaticGeometrySmall[ptr.getCell()];
}
else
{
if( mStaticGeometry.find(ptr.getCell()) == mStaticGeometry.end())
{
uniqueID = uniqueID +1;
sg = mRenderer.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID));
mStaticGeometry[ptr.getCell()] = sg;
}
else
sg = mStaticGeometry[ptr.getCell()];
}
// This specifies the size of a single batch region.
// If it is set too high:
// - there will be problems choosing the correct lights
// - the culling will be more inefficient
// If it is set too low:
// - there will be too many batches.
sg->setRegionDimensions(Ogre::Vector3(2500,2500,2500));
sg->setVisibilityFlags(small ? RV_StaticsSmall : RV_Statics);
sg->setCastShadows(true);
sg->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
for(size_t i = 0;i < entities.mEntities.size();i++)
{
Ogre::Entity *ent = entities.mEntities[i];
insert->detachObject(ent);
sg->addEntity(ent,insert->_getDerivedPosition(),insert->_getDerivedOrientation(),insert->_getDerivedScale());
mRenderer.getScene()->destroyEntity(ent);
}
}
}
示例5: LocalToWorld
float3x4 EC_Mesh::LocalToWorld() const
{
if (!entity_)
{
LogError("EC_Mesh::LocalToParent failed! No entity exists in this mesh!");
return float3x4::identity;
}
Ogre::SceneNode *node = entity_->getParentSceneNode();
if (!node)
{
LogError("EC_Mesh::LocalToParent failed! Ogre::Entity is not attached to a Ogre::SceneNode!");
return float3x4::identity;
}
return float3x4::FromTRS(node->_getDerivedPosition(), node->_getDerivedOrientation(), node->_getDerivedScale());
}