本文整理汇总了C++中ManualObject::convertToMesh方法的典型用法代码示例。如果您正苦于以下问题:C++ ManualObject::convertToMesh方法的具体用法?C++ ManualObject::convertToMesh怎么用?C++ ManualObject::convertToMesh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ManualObject
的用法示例。
在下文中一共展示了ManualObject::convertToMesh方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createVoxelMesh
//this makes the cube mesh used to represent a voxel.
void OgreDisplay::createVoxelMesh()
{
ManualObject* manual = sceneMgr->createManualObject("voxel");
manual->begin("BaseWhite", RenderOperation::OT_TRIANGLE_LIST);
manual->position(-0.5, -0.5, -0.5); //0
manual->position(-0.5, -0.5, 0.5); //1
manual->position(0.5, -0.5, 0.5); //2
manual->position(0.5, -0.5, -0.5); //3
manual->position(-0.5, 0.5, -0.5); //4
manual->position(-0.5, 0.5, 0.5); //5
manual->position(0.5, 0.5, 0.5); //6
manual->position(0.5, 0.5, -0.5); //7
manual->quad(0,1,2,3);
manual->quad(4,5,6,7);
manual->quad(0,1,4,5);
manual->quad(2,3,6,7);
manual->quad(1,2,5,6);
manual->quad(0,3,4,7);
manual->end();
manual->convertToMesh("voxel");
}
示例2: createMeshWithMaterial
void createMeshWithMaterial(String fileName)
{
String matFileNameSuffix = ".material";
String matName1 = "red";
String matFileName1 = matName1 + matFileNameSuffix;
MaterialPtr matPtr = MaterialManager::getSingleton().create(matName1, "General");
Pass* pass = matPtr->getTechnique(0)->getPass(0);
pass->setDiffuse(1.0, 0.1, 0.1, 0);
String matName2 = "green";
String matFileName2 = matName2 + matFileNameSuffix;
matPtr = MaterialManager::getSingleton().create(matName2, "General");
pass = matPtr->getTechnique(0)->getPass(0);
pass->setDiffuse(0.1, 1.0, 0.1, 0);
String matName3 = "blue";
String matFileName3 = matName3 + matFileNameSuffix;
matPtr = MaterialManager::getSingleton().create(matName3, "General");
pass = matPtr->getTechnique(0)->getPass(0);
pass->setDiffuse(0.1, 0.1, 1.0, 0);
String matName4 = "yellow";
String matFileName4 = matName4 + matFileNameSuffix;
matPtr = MaterialManager::getSingleton().create(matName4, "General");
pass = matPtr->getTechnique(0)->getPass(0);
pass->setDiffuse(1.0, 1.0, 0.1, 0);
ManualObject* manObj = OGRE_NEW ManualObject("mesh");
manObj->begin(matName1, RenderOperation::OT_TRIANGLE_LIST);
manObj->position(0, 50, 0);
manObj->position(50, 50, 0);
manObj->position(0, 100, 0);
manObj->triangle(0, 1, 2);
manObj->position(50, 100, 0);
manObj->position(0, 100, 0);
manObj->position(50, 50, 0);
manObj->triangle(3, 4, 5);
manObj->end();
manObj->begin(matName2, RenderOperation::OT_LINE_LIST);
manObj->position(0, 100, 0);
manObj->position(-50, 50, 0);
manObj->position(-50, 0, 0);
manObj->position(-50, 50, 0);
manObj->position(-100, 0, 0);
manObj->position(-50, 0, 0);
manObj->end();
manObj->begin(matName3, RenderOperation::OT_LINE_STRIP);
manObj->position(50, 100, 0);
manObj->position(100, 50, 0);
manObj->position(100, 0, 0);
manObj->position(150, 0, 0);
manObj->end();
manObj->begin(matName4, RenderOperation::OT_POINT_LIST);
manObj->position(50, 0, 0);
manObj->position(0, 0, 0);
manObj->end();
manObj->convertToMesh(fileName);
OGRE_DELETE manObj;
}
示例3: buildMesh
MeshPtr ShowNormalsGenerator::buildMesh(const std::string& name, const String& group) const
{
SceneManager* sceneMgr = Ogre::Root::getSingleton().getSceneManagerIterator().begin()->second;
ManualObject* mo = buildManualObject();
Ogre::MeshPtr mesh = mo->convertToMesh(name, group);
sceneMgr->destroyManualObject(mo);
return mesh;
}
示例4: createCylinderMesh
void OgreDisplay::createCylinderMesh(std::string name, std::string material)
{
//make a cube mesh
ManualObject* cylinderMesh = sceneMgr->createManualObject("cylinder");
cylinderMesh->begin(material, RenderOperation::OT_TRIANGLE_LIST);
for(double i = 0.0; i < Math::PI * 2; i += Math::PI / 5)
{
cylinderMesh->position(cos(i), 1, sin(i));
cylinderMesh->textureCoord(i / (Math::PI * 2), 1.0);
Ogre::Vector3 myNormal(cos(i), 0, sin(i));
myNormal.normalise();
cylinderMesh->normal(myNormal);
}
for(double i = 0.0; i < Math::PI * 2; i += Math::PI / 5)
{
cylinderMesh->position(cos(i), -1, sin(i));
cylinderMesh->textureCoord(i / (Math::PI * 2), 0.0);
Ogre::Vector3 myNormal(cos(i), 0, sin(i));
myNormal.normalise();
cylinderMesh->normal(myNormal);
}
for(int i = 0; i < 10; i++)
{
cylinderMesh->triangle(i, (i+1) % 10, ((i + 10) % 20));
}
for(int i = 10; i < 20; i++)
{
cylinderMesh->triangle(i, (i+1) % 10, (i+1) % 10 + 10);
}
cylinderMesh->position(0, 1, 0);
cylinderMesh->textureCoord(0.5, 0.5);
cylinderMesh->position(0, -1, 0);
cylinderMesh->textureCoord(0.5, 0.5);
for(int i = 0; i < 10; i++)
{
cylinderMesh->triangle(20, (i+1) % 10, i);
cylinderMesh->triangle(21, ((i+10) % 10) + 10, ((i+ 11) % 10) + 10);
}
cylinderMesh->end();
cylinderMesh->convertToMesh(name);
}
示例5: createScene
void OgreAppLogic::createScene(void)
{
// setup some basic lighting for our scene
mSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 8);
// make a cube to bounce around
Entity *ent1;
SceneNode *boxNode;
ManualObject *cmo = createCubeMesh("manual", "");
cmo->convertToMesh("cube");
ent1 = mSceneMgr->createEntity("Cube", "cube.mesh");
ent1->setCastShadows(true);
boxNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
boxNode->attachObject(ent1);
boxNode->setScale(Vector3(0.1,0.1,0.1)); // for some reason converttomesh multiplied dimensions by 10
mSceneMgr->setAmbientLight(ColourValue(0.3, 0.3, 0.3));
mSceneMgr->createLight()->setPosition(20, 80, 50);
// create a floor mesh resource
MeshManager::getSingleton().createPlane("floor", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Plane(Vector3::UNIT_Y, -30), 1000, 1000, 10, 10, true, 1, 8, 8, Vector3::UNIT_Z);
// create a floor entity, give it a material, and place it at the origin
Entity* floor = mSceneMgr->createEntity("Floor", "floor");
floor->setMaterialName("Examples/BumpyMetal");
mSceneMgr->getRootSceneNode()->attachObject(floor);
mSceneMgr->getRootSceneNode()->attachObject(mSceneMgr->createEntity("Head", "ogrehead.mesh"));
mSceneMgr->setSkyBox(true, "Examples/GridSkyBox");
Ogre::Entity* ent = mSceneMgr->createEntity("Sinbad.mesh"); //1x1_cube.mesh //Sinbad.mesh //axes.mesh
mObjectNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("cube");
mObjectNode->setOrientation(Quaternion(Degree(90.f), Vector3::UNIT_X));
Ogre::Real scale = 22;
mObjectNode->setPosition(10, 10, 10*scale);
mObjectNode->setScale(Ogre::Vector3::UNIT_SCALE*scale);
mObjectNode->attachObject(ent);
mObjectNode->setVisible(true);
// create swords and attach them to sinbad
Ogre::Entity* sword1 = mSceneMgr->createEntity("SinbadSword1", "Sword.mesh");
Ogre::Entity* sword2 = mSceneMgr->createEntity("SinbadSword2", "Sword.mesh");
ent->attachObjectToBone("Sheath.L", sword1);
ent->attachObjectToBone("Sheath.R", sword2);
mAnimState = ent->getAnimationState("Dance");
mAnimState->setLoop(true);
mAnimState->setEnabled(true);
}
示例6: setupScene
void setupScene()
{
mSceneMgr = mRoot->createSceneManager(ST_GENERIC, "Default SceneManager");
Camera *cam = mSceneMgr->createCamera("Camera");
Viewport *vp = mRoot->getAutoCreatedWindow()->addViewport(cam);
Entity *ent;
mSceneMgr->setAmbientLight(ColourValue(0.25, 0.25, 0.25));
mSceneMgr->setShadowTechnique( SHADOWTYPE_STENCIL_ADDITIVE );
// EN:: make a cube to bounce around
// BR:: cria um cubo pra quicar
ManualObject *cmo = createCubeMesh("manual", "");
cmo->convertToMesh("cube");
ent = mSceneMgr->createEntity("Cube", "cube.mesh");
ent->setCastShadows(true);
boxNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
boxNode->attachObject(ent);
boxNode->setScale(Vector3(0.1,0.1,0.1));
// EN:: make a rock wall on the floor
// BR:: adiciona piso de pedra no chão
Plane plane(Vector3::UNIT_Y, 0);
MeshManager::getSingleton().createPlane("ground",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
1500,1500,20,20,true,1,5,5,Vector3::UNIT_Z);
ent = mSceneMgr->createEntity("GroundEntity", "ground");
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
ent->setMaterialName("Examples/Rockwall");
ent->setCastShadows(false);
// EN:: make a light to see stuff with
// BR:: adiciona uma iluminação
Light *light = mSceneMgr->createLight("Light1");
light->setType(Light::LT_POINT);
light->setPosition(Vector3(250, 150, 250));
light->setDiffuseColour(ColourValue::White);
light->setSpecularColour(ColourValue::White);
// EN:: Create the scene node
// BR:: cria o SceneNode (nó da cena)
SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode("CamNode1", Vector3(-200, 100, 200));
node->yaw(Degree(-45));
node->attachObject(cam);
}
示例7: testCreateLineWithMaterial
void MeshWithoutIndexDataTests::testCreateLineWithMaterial()
{
String matName = "lineMat";
MaterialPtr matPtr = MaterialManager::getSingleton().create(matName, "General");
Pass* pass = matPtr->getTechnique(0)->getPass(0);
pass->setDiffuse(1.0, 0.1, 0.1, 0);
ManualObject* line = OGRE_NEW ManualObject("line");
line->begin(matName, RenderOperation::OT_LINE_LIST);
line->position(0, 50, 0);
line->position(50, 100, 0);
line->end();
String fileName = "lineWithMat.mesh";
MeshPtr lineMesh = line->convertToMesh(fileName);
OGRE_DELETE line;
CPPUNIT_ASSERT(lineMesh->getNumSubMeshes() == 1);
CPPUNIT_ASSERT(lineMesh->getSubMesh(0)->indexData->indexCount == 0);
RenderOperation rop;
lineMesh->getSubMesh(0)->_getRenderOperation(rop);
CPPUNIT_ASSERT(rop.useIndexes == false);
CPPUNIT_ASSERT(lineMesh->getSubMesh(0)->vertexData->vertexCount == 2);
MeshSerializer meshWriter;
meshWriter.exportMesh(lineMesh.get(), fileName);
MaterialSerializer matWriter;
matWriter.exportMaterial(
MaterialManager::getSingleton().getByName(matName),
matName + ".material"
);
mMeshMgr->remove( fileName );
ResourceGroupManager::getSingleton().addResourceLocation(".", "FileSystem");
MeshPtr loadedLine = mMeshMgr->load(fileName, "General");
remove(fileName.c_str());
remove((matName + ".material").c_str());
CPPUNIT_ASSERT(loadedLine->getNumSubMeshes() == 1);
CPPUNIT_ASSERT(loadedLine->getSubMesh(0)->indexData->indexCount == 0);
loadedLine->getSubMesh(0)->_getRenderOperation(rop);
CPPUNIT_ASSERT(rop.useIndexes == false);
CPPUNIT_ASSERT(lineMesh->getSubMesh(0)->vertexData->vertexCount == 2);
mMeshMgr->remove( fileName );
}
示例8: createScene
void Application::createScene()
{
//mSceneMgr = mRoot->createSceneManager(ST_GENERIC, "Default SceneManager"); In create cameras and viewports
//Camera *cam = mSceneMgr->createCamera("Camera");
//Viewport *vp = mRoot->getAutoCreatedWindow()->addViewport(cam);
//
Entity *ent;
mSceneMgr->setAmbientLight(ColourValue(0.25, 0.25, 0.25));
mSceneMgr->setShadowTechnique( SHADOWTYPE_STENCIL_ADDITIVE );
// make a cube to bounce around
ManualObject *cmo = createCubeMesh("manual", "");
cmo->convertToMesh("cube");
ent = mSceneMgr->createEntity("Cube", "cube.mesh");
ent->setCastShadows(true);
boxNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
boxNode->attachObject(ent);
boxNode->setScale(Vector3(0.1,0.1,0.1)); // for some reason converttomesh multiplied dimensions by 10
//
//
// make a rock wall on the floor
Plane plane(Vector3::UNIT_Y, 0);
MeshManager::getSingleton().createPlane("ground",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
1500,1500,20,20,true,1,5,5,Vector3::UNIT_Z);
ent = mSceneMgr->createEntity("GroundEntity", "ground");
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
ent->setMaterialName("Examples/Rockwall");
ent->setCastShadows(false);
//
// // make a light to see stuff with
Light *light = mSceneMgr->createLight("Light1");
light->setType(Light::LT_POINT);
light->setPosition(Vector3(250, 150, 250));
light->setDiffuseColour(ColourValue::White);
light->setSpecularColour(ColourValue::White);
//
// // Create the scene node
SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode("CamNode1", Vector3(-200, 100, 200));
node->yaw(Degree(-45));
//node->attachObject(cam);
//node->attachObject(mCamera);
}
示例9: getOctreeGrid
Entity* OctreeNode::getOctreeGrid(SceneManager *sceneManager)
{
if (!mOctreeGrid)
{
mGridPositionCount = 0;
mNodeI++;
ManualObject* manual = sceneManager->createManualObject();
manual->begin("BaseWhiteNoLighting", RenderOperation::OT_LINE_LIST);
manual->colour((Real)1.0, (Real)0.0, (Real)0.0);
buildOctreeGridLines(manual);
manual->end();
StringUtil::StrStreamType meshName;
meshName << "VolumeOctreeGridMesh" << mNodeI;
manual->convertToMesh(meshName.str());
StringUtil::StrStreamType entityName;
entityName << "VolumeOctreeGrid" << mNodeI;
mOctreeGrid = sceneManager->createEntity(entityName.str(), meshName.str());
}
return mOctreeGrid;
}
示例10: testCreateLineList
void MeshWithoutIndexDataTests::testCreateLineList()
{
ManualObject* lineList = OGRE_NEW ManualObject("line");
lineList->begin("BaseWhiteNoLighting", RenderOperation::OT_LINE_LIST);
lineList->position(0, 50, 0);
lineList->position(50, 100, 0);
lineList->position(50, 50, 0);
lineList->position(100, 100, 0);
lineList->position(0, 50, 0);
lineList->position(50, 50, 0);
lineList->end();
String fileName = "lineList.mesh";
MeshPtr lineListMesh = lineList->convertToMesh(fileName);
OGRE_DELETE lineList;
CPPUNIT_ASSERT(lineListMesh->getNumSubMeshes() == 1);
CPPUNIT_ASSERT(lineListMesh->getSubMesh(0)->indexData->indexCount == 0);
RenderOperation rop;
lineListMesh->getSubMesh(0)->_getRenderOperation(rop);
CPPUNIT_ASSERT(rop.useIndexes == false);
CPPUNIT_ASSERT(lineListMesh->getSubMesh(0)->vertexData->vertexCount == 6);
MeshSerializer meshWriter;
meshWriter.exportMesh(lineListMesh.get(), fileName);
mMeshMgr->remove( fileName );
ResourceGroupManager::getSingleton().addResourceLocation(".", "FileSystem");
MeshPtr loadedLineList = mMeshMgr->load(fileName, "General");
remove(fileName.c_str());
CPPUNIT_ASSERT(loadedLineList->getNumSubMeshes() == 1);
CPPUNIT_ASSERT(loadedLineList->getSubMesh(0)->indexData->indexCount == 0);
loadedLineList->getSubMesh(0)->_getRenderOperation(rop);
CPPUNIT_ASSERT(rop.useIndexes == false);
CPPUNIT_ASSERT(loadedLineList->getSubMesh(0)->vertexData->vertexCount == 6);
mMeshMgr->remove( fileName );
}
示例11: generateWithManualObject
Entity* MeshBuilder::generateWithManualObject(SceneManager *sceneManager, const String &name, const String &material)
{
ManualObject* manual = sceneManager->createManualObject();
manual->begin(material, RenderOperation::OT_TRIANGLE_LIST);
for (VecVertex::const_iterator iter = mVertices.begin(); iter != mVertices.end(); ++iter)
{
manual->position(Vector3(iter->x, iter->y, iter->z));
manual->normal(Vector3(iter->nX, iter->nY, iter->nZ));
}
for (VecIndices::const_iterator iter = mIndices.begin(); iter != mIndices.end(); ++iter)
{
manual->index(*iter);
}
manual->end();
StringUtil::StrStreamType meshName;
meshName << name << "ManualObject";
MeshManager::getSingleton().remove(meshName.str());
manual->convertToMesh(meshName.str());
return sceneManager->createEntity(name, meshName.str());
}
示例12: getDualGrid
Entity* DualGridGenerator::getDualGrid(SceneManager *sceneManager)
{
if (!mDualGrid && mDualCells.size() > 0)
{
ManualObject* manual = sceneManager->createManualObject();
manual->begin("BaseWhiteNoLighting", RenderOperation::OT_LINE_LIST);
manual->colour((Real)0.0, (Real)1.0, (Real)0.0);
manual->estimateVertexCount(mDualCells.size() * 8);
manual->estimateIndexCount(mDualCells.size() * 24);
uint32 baseIndex = 0;
for (VecDualCell::iterator it = mDualCells.begin(); it != mDualCells.end(); ++it)
{
MeshBuilder::addCubeToManualObject(
manual,
it->mC0,
it->mC1,
it->mC2,
it->mC3,
it->mC4,
it->mC5,
it->mC6,
it->mC7,
baseIndex);
}
manual->end();
mDualGridI++;
StringUtil::StrStreamType meshName;
meshName << "VolumeDualGridGridMesh" << mDualGridI;
manual->convertToMesh(meshName.str());
StringUtil::StrStreamType entityName;
entityName << "VolumeDualGrid" << mDualGridI;
mDualGrid = sceneManager->createEntity(entityName.str(), meshName.str());
}
return mDualGrid;
}
示例13: testEdgeList
void MeshWithoutIndexDataTests::testEdgeList()
{
String fileName = "testEdgeList.mesh";
ManualObject* line = OGRE_NEW ManualObject("line");
line->begin("BaseWhiteNoLighting", RenderOperation::OT_LINE_LIST);
line->position(0, 50, 0);
line->position(50, 100, 0);
line->end();
MeshPtr mesh = line->convertToMesh(fileName);
OGRE_DELETE line;
// whole mesh must not contain index data, for this test
CPPUNIT_ASSERT(mesh->getNumSubMeshes() == 1);
CPPUNIT_ASSERT(mesh->getSubMesh(0)->indexData->indexCount == 0);
mesh->buildEdgeList();
MeshSerializer meshWriter;
// if it does not crash here, test is passed
meshWriter.exportMesh(mesh.get(), fileName);
remove(fileName.c_str());
mMeshMgr->remove( fileName );
}
示例14: CreateVdrTrack
void App::CreateVdrTrack(std::string strack, TRACK* pTrack)
{
// materials -------------
std::vector<OGRE_MESH>& meshes = pTrack->ogre_meshes;
std::string sMatCache = strack + ".matdef", sMatOrig = "_" + sMatCache,
sPathCache = PATHMANAGER::ShaderDir() + "/" + sMatCache, sPathOrig = gcom->TrkDir() +"objects/"+ sMatOrig;
bool hasMatOrig = boost::filesystem::exists(sPathOrig), hasMatCache = boost::filesystem::exists(sPathCache);
bool bGenerate = 0, gen = !hasMatOrig && !hasMatCache || bGenerate; // set 1 to force generate for new vdrift tracks
//TODO .mat ..rewrite this code for new system
#if 0
if (gen)
{
String sMtrs;
for (int i=0; i < meshes.size(); i++)
{
OGRE_MESH& msh = meshes[i];
if (msh.sky /*&& ownSky*/) continue;
if (!msh.newMtr) continue; // create material if new
bool found = true;
TexturePtr tex = TextureManager::getSingleton().getByName(msh.material);
if (tex.isNull())
try{
tex = TextureManager::getSingleton().load(msh.material, rgDef); }
catch(...){
found = false; }
msh.found = found; // dont create meshes for not found textures, test
if (!found) continue;
#if 0 // use 0 for some tracks (eg.zandvoort) - have alpha textures for all!
if (!tex.isNull() && tex->hasAlpha())
msh.alpha = true; // for textures that have alpha
#endif
if (msh.alpha)
sMtrs += "["+msh.material+"]\n"+
" parent = 0vdrAlpha\n"+
" diffuseMap_512 = "+msh.material+"\n";
else
sMtrs += "["+msh.material+"]\n"+
" parent = 0vdrTrk\n"+
" diffuseMap_512 = "+msh.material+"\n";
}
std::ofstream fileout(sPathCache.c_str());
if (!fileout) LogO("Error: Can't save vdrift track matdef!");
fileout.write(sMtrs.c_str(), sMtrs.size());
fileout.close();
hasMatCache = true;
}
#endif
// meshes -------------
std::vector<Entity*> ents;
static int ii = 0; int i;
for (i=0; i < meshes.size(); ++i)
{
OGRE_MESH& msh = meshes[i];
if (msh.sky /*&& ownSky*/) continue;
if (!msh.found) continue;
//if (strstr(msh.material.c_str(), "tree")!=0) continue;
//LogO( String("--- model: ") + msh.name + " mtr:" + msh.material +
//" v:" + toStr(msh.mesh->vertices.size()) + " f:" + toStr(msh.mesh->faces.size()) );
//if (ownSky && msh.sky)
if (!msh.sky)
{
ManualObject* m = CreateModel(mSceneMgr, msh.material, msh.mesh, Vector3(0,0,0), false, true);
//if (!m) continue;
if (msh.sky)
m->setCastShadows(false);
MeshPtr mp = m->convertToMesh("m"+toStr(ii+i));
Entity* e = mSceneMgr->createEntity(mp);
ents.push_back(e);
}
}
ii += i;
// static geom -------------
scn->vdrTrack = mSceneMgr->createStaticGeometry("track");
scn->vdrTrack->setRegionDimensions(Vector3::UNIT_SCALE * 1000); // 1000
scn->vdrTrack->setOrigin(Vector3::ZERO);
scn->vdrTrack->setCastShadows(true);
for (std::vector<Entity*>::iterator it = ents.begin(); it != ents.end(); ++it)
scn->vdrTrack->addEntity(*it, Vector3::ZERO);
scn->vdrTrack->build();
//mStaticGeom->dump("_track-sg.txt");
}
示例15: createScene
void GameState::createScene()
{
mSceneMgr->setSkyBox(true, "SkyBox");
mDebugDrawer = new BtOgre::DebugDrawer(mSceneMgr->getRootSceneNode(), mWorld);
mDebugDrawer->setDebugMode(btIDebugDraw::DBG_DrawWireframe);
mWorld->setDebugDrawer(mDebugDrawer);
//player = new Viper( mSceneMgr, mWorld);
team1 = new TeamManager("red",this, mSceneMgr, mWorld, "Team01");
team1->addViper(Ogre::Vector3(-20, 5, 0), "Player");
player = team1->getViperByName("Player");
Ogre::SceneNode * playerSceneNode = player->getSceneNode();
mCameraNode = playerSceneNode->createChildSceneNode("CameraNode", Ogre::Vector3(-4, 5, 0));
mCameraNode->attachObject(mCamera);
//Viper * player2 = new Viper(mSceneMgr, mWorld, Ogre::Vector3(100, 0,0));
//player2->setDirection(Ogre::Vector3(10,0,0));
//player2->setSpeed(50);
//player2->transform(Ogre::Quaternion::IDENTITY, Ogre::Vector3::ZERO);
team2 = new TeamManager("blue",this, mSceneMgr, mWorld,"Team02");
team2->addViper(Ogre::Vector3(100, 0,0));
OgreFramework::getSingleton().mSoundManager->createSound("GameBackgroundMusic", "background_music.ogg", false, true, true) ;
OgreFramework::getSingleton().mSoundManager->getSound("GameBackgroundMusic")->play();
CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
CEGUI::Window *guiRoot = wmgr.loadWindowLayout("game.layout");
CEGUI::System::getSingleton().setGUISheet(guiRoot);
CEGUI::ProgressBar * bar = (CEGUI::ProgressBar *)wmgr.getWindow("GameState/Life");
bar->setProgress(1.0f);
generateEnvironment();
// create ManualObject which will be the Viper bullet placeholder
Ogre::ManualObject mo("BulletObject");
const float width = 0.2;
const float height = 0.5;
Ogre::Vector3 vec(width/2, 0, 0);
Ogre::Quaternion rot;
rot.FromAngleAxis(Ogre::Degree(90), Ogre::Vector3::UNIT_Y);
mo.begin("blue", Ogre::RenderOperation::OT_TRIANGLE_LIST);
for (int i = 0; i < 2; ++i)
{
mo.position(-vec.x, height, -vec.z);
mo.textureCoord(0, 0);
mo.position(vec.x, height, vec.z);
mo.textureCoord(1, 0);
mo.position(-vec.x, 0, -vec.z);
mo.textureCoord(0, 1);
mo.position(vec.x, 0, vec.z);
mo.textureCoord(1, 1);
int offset = i * 4;
mo.triangle(offset, offset+3, offset+1);
mo.triangle(offset, offset+2, offset+3);
vec = rot * vec;
}
mo.end();
mo.convertToMesh("ViperBulletMesh");
Ogre::Entity * ent123 = mSceneMgr->createEntity("ViperBulletMesh");
Ogre::Quaternion quat;
quat.FromAngleAxis(Ogre::Degree(90), Ogre::Vector3(0,0,1));
#ifndef DEBUG
wmgr.destroyWindow("GameState/Debug");
#endif
ManualObject* myManualObject = mSceneMgr->createManualObject("manual1");
//SceneNode* myManualObjectNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("manual1_node");
MaterialPtr myManualObjectMaterial = MaterialManager::getSingleton().create("manual1Material", "General");
myManualObjectMaterial->setReceiveShadows(false);
myManualObjectMaterial->getTechnique(0)->setLightingEnabled(true);
myManualObjectMaterial->getTechnique(0)->getPass(0)->setDiffuse(0,0,1,0);
myManualObjectMaterial->getTechnique(0)->getPass(0)->setAmbient(0,0,1);
myManualObjectMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(0,0,1);
// myManualObjectMaterial->dispose(); // dispose pointer, not the material
myManualObject->begin("manual1Material", Ogre::RenderOperation::OT_LINE_LIST);
myManualObject->position(-10, 0, 0);
myManualObject->position(1000, 0, 0);
// etc
myManualObject->end();
myManualObject->convertToMesh("line");
Ogre::Entity *lineLeft = mSceneMgr->createEntity("line");;
Ogre::SceneNode * mNodeLeft = (Ogre::SceneNode *)player->getSceneNode()->getChild(player->getName()+"leftCanon");
mNodeLeft->attachObject(lineLeft);
Ogre::Entity *lineRight = mSceneMgr->createEntity("line");;
Ogre::SceneNode * mNodeRight = (Ogre::SceneNode *)player->getSceneNode()->getChild(player->getName()+"rightCanon");
mNodeRight->attachObject(lineRight);
}