本文整理汇总了C++中ogre::MeshPtr::getPointer方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshPtr::getPointer方法的具体用法?C++ MeshPtr::getPointer怎么用?C++ MeshPtr::getPointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::MeshPtr
的用法示例。
在下文中一共展示了MeshPtr::getPointer方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _prepare
//-----------------------------------------------------------------------
void EntityRenderer::_prepare(ParticleTechnique* technique)
{
/**
- This renderer is a ´hacky´ solution to display geometry-based particles. It pre-creates a
number of SceneNodes (childs of the parent Node to which the ParticleSystem is attached) and
Entities and uses these pools to display the particles. There are better solutions, but
this one is simple and fast enough, although it has some drawbacks.
- Future solutions should rather make use of hardware instancing to display a large number of
geometry-based particles at once.
*/
// Use the given technique, although it should be the same as mParentTechnique (must be set already)
if (!technique || mRendererInitialised)
return;
std::stringstream ss;
ss << this;
mEntityName = mMeshName + ss.str();
mQuota = technique->getVisualParticleQuota();
Ogre::SceneNode* parentNode = technique->getParentSystem()->getParentSceneNode();
Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().load(mMeshName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::Mesh* meshPointer = mesh.getPointer();
Vector3 size = meshPointer->getBounds().getSize();
mBoxWidth = size.x == 0.0f ? 1.0f : size.x;
mBoxHeight = size.y == 0.0f ? 1.0f : size.y;
mBoxDepth = size.z == 0.0f ? 1.0f : size.z;
if (parentNode)
{
// Create number of VisualData objects including SceneNodes
String sceneNodeName;
for (size_t i = 0; i < mQuota; i++)
{
sceneNodeName = "ParticleUniverse" + ss.str() + StringConverter::toString(i);
EntityRendererVisualData* visualData =
PU_NEW_T(EntityRendererVisualData, MEMCATEGORY_SCENE_OBJECTS)(parentNode->createChildSceneNode(sceneNodeName));
mAllVisualData.push_back(visualData); // Managed by this renderer
mVisualData.push_back(visualData); // Used to assign to a particle
}
// Create number of Entities
Ogre::Entity* entity = technique->getParentSystem()->getSceneManager()->createEntity(mEntityName, mMeshName); // Base entity
vector<EntityRendererVisualData*>::const_iterator it;
vector<EntityRendererVisualData*>::const_iterator itEnd = mAllVisualData.end();
size_t j;
for (it = mAllVisualData.begin(), j = 0; it != itEnd; ++it, ++j)
{
Ogre::Entity* clonedEntity = entity->clone(mEntityName + StringConverter::toString(j));
clonedEntity->setMaterialName(technique->getMaterialName());
clonedEntity->setRenderQueueGroup(mQueueId);
mEntities.push_back(clonedEntity);
(*it)->node->attachObject(clonedEntity);
}
technique->getParentSystem()->getSceneManager()->destroyEntity(mEntityName);
}
_makeNodesVisible(false);
mRendererInitialised = true;
}
示例2: LoadModel
Ogre::MeshPtr CMapLoader::LoadModel(const char * path)
{
MapResource<Ogre::MeshPtr> res;
Ogre::MeshPtr pMesh;
// Check if this model was already loaded
pMesh = Ogre::MeshManager::getSingleton().getByName(path);
if(!pMesh.isNull())
return pMesh;
sectionitem_t * item = LoadItem(path, &res.map);
if(item == NULL)
return Ogre::MeshPtr(NULL);
pMesh = Ogre::MeshManager::getSingleton().createManual(path,
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::DataStreamPtr stream(new Ogre::MemoryDataStream(item->data, item->size, false, true));
Ogre::MeshSerializer serializer;
serializer.importMesh(stream, pMesh.getPointer());
// No need to keep this in memory
mapUnloadItem(item);
// Track this resource
res.data = pMesh;
meshes.push_back(res);
return pMesh;
}
示例3: updateBounds
void gkMesh::updateBounds()
{
m_boundsInit = false;
getBoundingBox();
// update ogre-bounds
Ogre::MeshManager& mgr = Ogre::MeshManager::getSingleton();
const gkString& name = getResourceName().getName();
Ogre::MeshPtr omesh = mgr.getByName(name);
if (!omesh.isNull()){
omesh.getPointer()->_setBounds(m_bounds, false);
omesh.getPointer()->_setBoundingSphereRadius(m_bounds.getSize().squaredLength());
}
}
示例4: reload
void gkMesh::reload()
{
Ogre::MeshManager& mgr = Ogre::MeshManager::getSingleton();
const gkString& name = getResourceName().getName();
Ogre::MeshPtr omesh = mgr.getByName(name);
if (!omesh.isNull())
omesh.getPointer()->reload();
}
示例5: _loadMesh
//-----------------------------------------------------------------------
void VertexEmitter::_loadMesh (void)
{
Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().load(mMeshName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
mMesh = mesh.getPointer();
mMeshProcessed = false;
if (mMesh->getNumSubMeshes() > 0)
{
mSubMesh = mMesh->getSubMesh(0);
}
else
{
mSubMesh = 0;
}
}
示例6: Process
void Process() {
Ogre::String targetFilename = LG::RendererOgre::Instance()->EntityNameToFilename(this->meshName, Ogre::String(""));
// Make sure the directory exists -- I wish the serializer did this for me
LG::RendererOgre::Instance()->CreateParentDirectory(targetFilename);
LG::Log("OLMeshTracker::MakePersistant: persistance to %s", targetFilename.c_str());
Ogre::MeshPtr meshHandle = (Ogre::MeshPtr)Ogre::MeshManager::getSingleton().getByName(meshName);
LG::OLMeshTracker::Instance()->MeshSerializer->exportMesh(meshHandle.getPointer(), targetFilename);
if (this->stringParam == "unload") {
LG::Log("OLMeshTracker::MakePersistant: queuing unload after persistance");
// if we're supposed to unload after serializing, schedule that to happen
LG::OLMeshTracker::Instance()->MakeUnLoadedLocked(this->meshName, Ogre::String(), NULL);
}
}
示例7: UnloadModel
void CMapLoader::UnloadModel(Ogre::MeshPtr mesh)
{
Ogre::ResourceHandle handle = mesh->getHandle();
// Ogre::MeshManager::getSingleton().unload(handle);
Ogre::MeshManager::getSingleton().remove(handle);
std::vector<MapResource<Ogre::MeshPtr>>::iterator i;
for(i = meshes.begin();i != meshes.end();i++)
{
if(i->data.getPointer() == mesh.getPointer())
{
meshes.erase(i);
}
}
}
示例8: aabb
Ogre::Entity*
ModelFile::GetModel( const ModelInfo& info )
{
VectorTexForGen textures;
Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().create( info.data.name + "export", "General" );
Ogre::SkeletonPtr skeleton = Ogre::SkeletonManager::getSingleton().create( info.data.name + "export", "General" );
int number_of_bones = GetU8( 0x02 );
int number_of_parts = GetU8( 0x03 );
int offset_to_bones = GetU32LE( 0x0c );
int offset_to_parts = GetU32LE( 0x10 );
Ogre::Bone* root1 = skeleton->createBone( "0", 0 );
Ogre::Bone* root2 = skeleton->createBone( "1", 1 );
root1->addChild( root2 );
for( int i = 0; i < number_of_bones; ++i )
{
Bone bone;
bone.parent_id = ( i != 0 ) ? ( s8 )GetU8( offset_to_bones + i * 0x04 + 0x03 ) : -1;
bone.length = ( s16 )GetU16LE( offset_to_bones + i * 0x04 + 0x00 );
m_Skeleton.push_back(bone);
Ogre::Bone* bone1 = skeleton->createBone( Ogre::StringConverter::toString( i * 2 + 2 ), i * 2 + 2 );
Ogre::Bone* bone2 = skeleton->createBone( Ogre::StringConverter::toString( i * 2 + 3 ), i * 2 + 3 );
LOGGER->Log( "Add skeleton bone: bone_id = " + Ogre::StringConverter::toString( i ) + ", length = " + Ogre::StringConverter::toString( bone.length ) + ", parent = " + Ogre::StringConverter::toString( bone.parent_id ) + ".\n" );
if( bone.parent_id == -1 )
{
skeleton->getBone( 1 )->addChild( bone1 );
}
else
{
skeleton->getBone( bone.parent_id * 2 + 3 )->addChild( bone1 );
}
bone1->addChild( bone2 );
}
AnimationExtractor( skeleton, info, m_Skeleton );
// draw skeleton
{
//DrawSkeleton( m_Skeleton, mesh );
}
for( int i = 0; i < number_of_parts; ++i )
{
MeshExtractor( info.data, "ffix/field_model/" + info.data.name, this, offset_to_parts + i * 0x28, textures, mesh );
}
// <OGRE> ///////////////////////////////
skeleton->optimiseAllAnimations();
Ogre::SkeletonSerializer skeleton_serializer;
skeleton_serializer.exportSkeleton( skeleton.getPointer(), "exported/models/field/units/" + info.data.name + ".skeleton" );
// Update bounds
Ogre::AxisAlignedBox aabb( -999, -999, -999, 999, 999, 999 );
mesh->_setBounds( aabb, false );
mesh->_setBoundingSphereRadius( 999 );
mesh->setSkeletonName( "models/field/units/" + info.data.name + ".skeleton" );
Ogre::MeshSerializer ser;
ser.exportMesh( mesh.getPointer(), "exported/models/field/units/" + info.data.name + ".mesh" );
// create and export textures for model
//if (textures.size() > 0)
{
Vram* vram = new Vram();
File* tex = new File( "./data/field/5/1b/2/4/1.tim" );
LoadTimFileToVram( tex, 0, vram );
delete tex;
tex = new File( "./data/field/5/1b/2/4/2.tim" );
LoadTimFileToVram( tex, 0, vram );
delete tex;
vram->Save( "1.jpg" );
CreateTexture( vram, info.data, "exported/models/field/units/" + info.data.name + ".png", textures );
delete vram;
}
CreateMaterial( "ffix/field_model/" + info.data.name, "exported/models/field/units/" + info.data.name + ".material", ( textures.size() > 0 ) ? "models/field/units/" + info.data.name + ".png" : "", "", "" );
//.........这里部分代码省略.........
示例9: doExportMesh
//.........这里部分代码省略.........
// Vertex normals
// For the moment, ignore any discrepancies per vertex
msTriangleEx_GetNormal(pTriangleEx, k, &Normal[0]);
msTriangleEx_GetTexCoord(pTriangleEx, k, &uv[0]);
pTex[(vertIdx*2)]=uv[0];
pTex[(vertIdx*2)+1]=uv[1];
pNorm[(vertIdx*3)] = Normal[0];
pNorm[(vertIdx*3)+1] = Normal[1];
pNorm[(vertIdx*3)+2] = Normal[2];
}
} // Faces
nbuf->unlock();
ibuf->unlock();
tbuf->unlock();
// Now use Ogre's ability to reorganise the vertex buffers the best way
Ogre::VertexDeclaration* newDecl =
ogreSubMesh->vertexData->vertexDeclaration->getAutoOrganisedDeclaration(
foundBoneAssignment, false);
Ogre::BufferUsageList bufferUsages;
for (size_t u = 0; u <= newDecl->getMaxSource(); ++u)
bufferUsages.push_back(Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
ogreSubMesh->vertexData->reorganiseBuffers(newDecl, bufferUsages);
logMgr.logMessage("Geometry done.");
} // SubMesh
// Set bounds
ogreMesh->_setBoundingSphereRadius(Ogre::Math::Sqrt(maxSquaredRadius));
ogreMesh->_setBounds(Ogre::AxisAlignedBox(min, max), false);
// Keep hold of a Skeleton pointer for deletion later
// Mesh uses Skeleton pointer for skeleton name
Ogre::SkeletonPtr pSkel;
if (exportSkeleton && foundBoneAssignment)
{
// export skeleton, also update mesh to point to it
pSkel = doExportSkeleton(pModel, ogreMesh);
}
else if (!exportSkeleton && foundBoneAssignment)
{
// We've found bone assignments, but skeleton is not to be exported
// Prompt the user to find the skeleton
if (!locateSkeleton(ogreMesh))
return;
}
// Export
logMgr.logMessage("Creating MeshSerializer..");
Ogre::MeshSerializer serializer;
logMgr.logMessage("MeshSerializer created.");
// Generate LODs if required
if (generateLods)
{
// Build LOD depth list
Ogre::Mesh::LodDistanceList distList;
float depth = 0;
for (unsigned short depthidx = 0; depthidx < numLods; ++depthidx)
{
depth += lodDepthIncrement;
distList.push_back(depth);
}
ogreMesh->generateLodLevels(distList, lodReductionMethod, lodReductionAmount);
}
if (generateEdgeLists)
{
ogreMesh->buildEdgeList();
}
if (generateTangents)
{
unsigned short src, dest;
ogreMesh->suggestTangentVectorBuildParams(tangentSemantic, src, dest);
ogreMesh->buildTangentVectors(tangentSemantic, src, dest, tangentsSplitMirrored, tangentsSplitRotated, tangentsUseParity);
}
// Export
Ogre::String msg;
msg = "Exporting mesh data to file '" + Ogre::String(szFile) + "'";
logMgr.logMessage(msg);
serializer.exportMesh(ogreMesh.getPointer(), szFile);
logMgr.logMessage("Export successful");
Ogre::MeshManager::getSingleton().remove(ogreMesh->getHandle());
if (!pSkel.isNull())
Ogre::SkeletonManager::getSingleton().remove(pSkel->getHandle());
if (exportMaterials && msModel_GetMaterialCount(pModel) > 0)
{
doExportMaterials(pModel);
}
}
示例10: EngineSetup
//.........这里部分代码省略.........
ManualObject->position(1, 1, 1);
ManualObject->triangle(18, 19, 20);
ManualObject->position(1, 0, 0);
ManualObject->position(1, 1, 1);
ManualObject->position(1, 0, 1);
ManualObject->triangle(21, 22, 23);
//face 5
ManualObject->position(0, 1, 0);
ManualObject->position(1, 1, 0);
ManualObject->position(0, 1, 1);
ManualObject->triangle(24, 25, 26);
ManualObject->position(1, 1, 0);
ManualObject->position(1, 1, 1);
ManualObject->position(0, 1, 1);
ManualObject->triangle(27, 28, 29);
//face 6
ManualObject->position(0, 0, 0);
ManualObject->position(0, 1, 1);
ManualObject->position(0, 0, 1);
ManualObject->triangle(30, 31, 32);
ManualObject->position(0, 0, 0);
ManualObject->position(0, 1, 0);
ManualObject->position(0, 1, 1);
ManualObject->triangle(33, 34, 35);
ManualObject->end();
Ogre::MeshPtr MeshPtr = ManualObject->convertToMesh("Animation");
Ogre::SubMesh* sub = MeshPtr->getSubMesh(0);
Ogre::SkeletonPtr Skeleton = Ogre::SkeletonManager::getSingleton().create("Skeleton", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
MeshPtr.getPointer()->_notifySkeleton(Skeleton);
Ogre::Bone *Root1 = NULL;
Ogre::Bone *Child1 = NULL;
Ogre::Bone *Child2 = NULL;
Root1 = Skeleton.getPointer()->createBone("Root");
Root1->setPosition(Ogre::Vector3(0.0, 0.0, 0.0));
Root1->setOrientation(Ogre::Quaternion::IDENTITY);
Child1 = Root1->createChild(1);
Child1->setPosition(Ogre::Vector3(4.0, 0.0, 0.0));
Child1->setOrientation(Ogre::Quaternion::IDENTITY);
Child2 = Root1->createChild(2);
Child2->setPosition(Ogre::Vector3(5.0, 0.0, 0.0));
Child2->setOrientation(Ogre::Quaternion::IDENTITY);
Ogre::VertexBoneAssignment Assignment;
Assignment.boneIndex = 0;
Assignment.vertexIndex = 0;
Assignment.weight = 1.0;
Skeleton->setBindingPose();
sub->addBoneAssignment(Assignment);
Assignment.vertexIndex = 1;
sub->addBoneAssignment(Assignment);
Assignment.vertexIndex = 2;
sub->addBoneAssignment(Assignment);
Ogre::Animation *Animation = MeshPtr->createAnimation("HandAnimation", 100.0);
Ogre::NodeAnimationTrack *Track = Animation->createNodeTrack(0, Root1);
Ogre::TransformKeyFrame *KeyFrame = NULL;
for (float FrameTime = 0.0; FrameTime < 100.0; FrameTime += 0.1)
{
KeyFrame = Track->createNodeKeyFrame(FrameTime);
KeyFrame->setTranslate(Ogre::Vector3(10.0, 0.0, 0.0));
}
Root1->setManuallyControlled(true);
Child1->setManuallyControlled(true);
Child2->setManuallyControlled(true);
MeshPtr->load();
MeshPtr.getPointer()->_notifySkeleton(Skeleton);
// Ogre::SkeletonSerializer skeletonSerializer;
// skeletonSerializer.exportSkeleton(Skeleton.get(), "C:\\Users\\Ilya\\Documents\\Visual Studio 2010\\Projects\\Recipes\\media\\models\\testskeleton.skeleton");
// Ogre::MeshSerializer ser;
// ser.exportMesh(MeshPtr.get(), "C:\\Users\\Ilya\\Documents\\Visual Studio 2010\\Projects\\Recipes\\media\\models\\testskeleton.mesh");
Ogre::Entity *Entity = SceneManager->createEntity("Animation", "Animation"/*"testskeleton.mesh"*/);
Ogre::SceneNode *SceneNode = SceneManager->getRootSceneNode()->createChildSceneNode();
SceneNode->attachObject(Entity);
Entity->setDisplaySkeleton(true);
m_AnimationState = Entity->getAnimationState("HandAnimation");
m_AnimationState->setEnabled(true);
m_AnimationState->setLoop(true);
m_Camera->setPolygonMode(Ogre::PolygonMode::PM_WIREFRAME);
Root->renderOneFrame();
}
开发者ID:southerlies,项目名称:OGRE-3D-1.7-Application-Development-Cookbook-Code,代码行数:101,代码来源:SceletalAnimationView.cpp
示例11: aabb
Ogre::Entity*
StageFile::GetModel( const StageInfo& info )
{
//DumpSettings("exported/" + info.data.name + ".lua");
VectorTexForGen textures;
Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().create(info.data.name + "export", "General");
Ogre::SkeletonPtr skeleton = Ogre::SkeletonManager::getSingleton().create(info.data.name + "export", "General");
u32 number_of_files = GetU32LE(0);
LOGGER->Log("Number of file " + IntToString(number_of_files) + "\n");
Ogre::Bone* root1 = skeleton->createBone( "0", 0 );
Ogre::Bone* root2 = skeleton->createBone( "1", 1 );
root1->addChild( root2 );
Ogre::Animation* anim = skeleton->createAnimation( "Idle", 1 );
Ogre::NodeAnimationTrack* track1 = anim->createNodeTrack( 0, root1 );
track1->removeAllKeyFrames();
Ogre::TransformKeyFrame* frame1 = track1->createNodeKeyFrame( 0 );
Ogre::Matrix3 matrix;
matrix.FromEulerAnglesYXZ( Ogre::Radian( Ogre::Degree( 0 ) ), Ogre::Radian( Ogre::Degree( -90 ) ), Ogre::Radian( Ogre::Degree( 0 ) ) );
Ogre::Quaternion rot;
rot.FromRotationMatrix( matrix );
frame1->setRotation( rot );
for (u32 i = 1; i < number_of_files - 1; ++i)
{
int offset_to_vertex = GetU32LE(0x04 + i * 0x04);
MeshExtractor(info.data, "ffvii/battle_stage/" + info.data.name, this, offset_to_vertex, textures, mesh, Ogre::StringConverter::toString(i), 1);
}
// <OGRE> ///////////////////////////////
skeleton->optimiseAllAnimations();
Ogre::SkeletonSerializer skeleton_serializer;
skeleton_serializer.exportSkeleton(skeleton.getPointer(), "exported/models/ffvii/battle/stages/" + info.data.name + ".skeleton");
// Update bounds
Ogre::AxisAlignedBox aabb(-999, -999, -999, 999, 999, 999);
mesh->_setBounds(aabb, false);
mesh->_setBoundingSphereRadius(999);
mesh->setSkeletonName( "models/ffvii/battle/stages/" + info.data.name + ".skeleton" );
Ogre::MeshSerializer ser;
ser.exportMesh(mesh.getPointer(), "exported/models/ffvii/battle/stages/" + info.data.name + ".mesh");
// create and export textures for model
if( textures.size() > 0 )
{
int number_of_files = GetU32LE( 0x00 );
int offset_to_texture = GetU32LE( number_of_files * 0x04 );
Vram* vram = Vram::MakeInstance().release();
LoadTimFileToVram( this, offset_to_texture, vram );
//vram->Save( "qqq" );
CreateTexture( vram, info.data, "exported/models/ffvii/battle/stages/" + info.data.name + ".png", textures );
delete vram;
}
CreateMaterial("ffvii/battle_stage/" + info.data.name, "exported/models/ffvii/battle/stages/" + info.data.name + ".material", "models/ffvii/battle/stages/" + info.data.name + ".png", "", "");
Ogre::SceneManager* scene_manager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
Ogre::Entity* thisEntity = scene_manager->createEntity( info.data.name, "models/ffvii/battle/stages/" + info.data.name + ".mesh" );
//thisEntity->setDisplaySkeleton(true);
//thisEntity->setDebugDisplayEnabled(true);
thisEntity->setVisible(false);
thisEntity->getAnimationState( "Idle" )->setEnabled( true );
thisEntity->getAnimationState( "Idle" )->setLoop( true );
Ogre::SceneNode* thisSceneNode = scene_manager->getRootSceneNode()->createChildSceneNode();
thisSceneNode->setPosition( 0, 0, 0 );
thisSceneNode->roll( Ogre::Radian( Ogre::Degree( 180.0f ) ) );
thisSceneNode->yaw( Ogre::Radian( Ogre::Degree( 120.0f ) ) );
thisSceneNode->pitch( Ogre::Radian( Ogre::Degree( 90.0f ) ) );
thisSceneNode->attachObject( thisEntity );
return thisEntity;
}