本文整理汇总了C++中ogre::ManualObject::triangle方法的典型用法代码示例。如果您正苦于以下问题:C++ ManualObject::triangle方法的具体用法?C++ ManualObject::triangle怎么用?C++ ManualObject::triangle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::ManualObject
的用法示例。
在下文中一共展示了ManualObject::triangle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateRegion
//-------------------------------------------------------
Ogre::MeshPtr Ground::CreateRegion(size_t id, const std::string & material, const Ogre::Box & roi, const Ogre::Vector3 & offset, const Ogre::Vector3 & steps, const Ogre::Vector2 & texOffset)
{
assert(mSceneManager != nullptr);
Ogre::ManualObject* object = mSceneManager->createManualObject();
object->begin(material, Ogre::RenderOperation::OT_TRIANGLE_LIST);
{
size_t lastIdx = 0;
for (size_t y = 0; y < REGION_SIZE; ++y)
{
size_t texY = static_cast<size_t>(static_cast<float>(y) / REGION_SIZE * (roi.getHeight() - 1));
size_t texYn = static_cast<size_t>(static_cast<float>(y + 1) / REGION_SIZE * (roi.getHeight() - 1));
//Flip texture vertically
texY = roi.getHeight() - 1 - texY;
texYn = roi.getHeight() - 1 - texYn;
float texCrdT = texOffset[1] + static_cast<float>(texY) / (mImage->getHeight() - 1);
float texCrdTn = texOffset[1] + static_cast<float>(texYn) / (mImage->getHeight() - 1);
for (size_t x = 0; x < REGION_SIZE; ++x)
{
size_t texX = static_cast<size_t>(static_cast<float>(x) / REGION_SIZE * (roi.getWidth() - 1));
size_t texXn = static_cast<size_t>(static_cast<float>(x + 1) / REGION_SIZE * (roi.getWidth() - 1));
float texCrdS = texOffset[0] + static_cast<float>(texX) / (mImage->getWidth() - 1);
float texCrdSn = texOffset[0] + static_cast<float>(texXn) / (mImage->getWidth() - 1);
float h00 = mImage->getColourAt(roi.left + texX, roi.top + texY, 0)[0];
float h10 = mImage->getColourAt(roi.left + texXn, roi.top + texY, 0)[0];
float h01 = mImage->getColourAt(roi.left + texX, roi.top + texYn, 0)[0];
float h11 = mImage->getColourAt(roi.left + texXn, roi.top + texYn, 0)[0];
object->position(x * steps[0] + offset[0], y * steps[1] + offset[1], h00 * steps[2]);
object->textureCoord(texCrdS, texCrdT);
object->colour(h00, h00, h00);
object->position((x + 1) * steps[0] + offset[0], y * steps[1] + offset[1], h10 * steps[2]);
object->textureCoord(texCrdSn, texCrdT);
object->colour(h10, h10, h10);
object->position(x * steps[0] + offset[0], (y + 1) * steps[1] + offset[1], h01 * steps[2]);
object->textureCoord(texCrdS, texCrdTn);
object->colour(h01, h01, h01);
object->position((x + 1) * steps[0] + offset[0], (y + 1) * steps[1] + offset[1], h11 * steps[2]);
object->textureCoord(texCrdSn, texCrdTn);
object->colour(h11, h11, h11);
object->triangle(lastIdx + 1, lastIdx + 2, lastIdx);
object->triangle(lastIdx + 3, lastIdx + 2, lastIdx + 1);
lastIdx += 4;
}
}
}
object->end();
return object->convertToMesh("Mesh/" + CLASS_NAME + "/" + mName + "/" + std::to_string(id));
}
示例2: toMesh
Ogre::MeshPtr STLLoader::toMesh(const std::string& name)
{
Ogre::ManualObject* object = new Ogre::ManualObject( "the one and only" );
object->begin( "BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST );
unsigned int vertexCount = 0;
V_Triangle::const_iterator it = triangles_.begin();
V_Triangle::const_iterator end = triangles_.end();
for (; it != end; ++it )
{
if( vertexCount >= 2004 )
{
// Subdivide large meshes into submeshes with at most 2004
// vertices to prevent problems on some graphics cards.
object->end();
object->begin( "BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST );
vertexCount = 0;
}
const STLLoader::Triangle& tri = *it;
float u, v;
u = v = 0.0f;
object->position( tri.vertices_[0] );
object->normal( tri.normal_);
calculateUV( tri.vertices_[0], u, v );
object->textureCoord( u, v );
object->position( tri.vertices_[1] );
object->normal( tri.normal_);
calculateUV( tri.vertices_[1], u, v );
object->textureCoord( u, v );
object->position( tri.vertices_[2] );
object->normal( tri.normal_);
calculateUV( tri.vertices_[2], u, v );
object->textureCoord( u, v );
object->triangle( vertexCount + 0, vertexCount + 1, vertexCount + 2 );
vertexCount += 3;
}
object->end();
Ogre::MeshPtr mesh = object->convertToMesh( name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
mesh->buildEdgeList();
delete object;
return mesh;
}
示例3: _exportPolygonMeshToEntity
Ogre::ManualObject* RecastInterface::_exportPolygonMeshToEntity(unsigned short* vertices,
int numVertices,
unsigned short* polygons,
int numPolys,
int maxPolys,
int numVertsPerPoly,
const Ogre::Vector3& origin)
{
if(_polyMesh == nullptr || _detailMesh == nullptr)
{
return NULL;
}
int nIndex = 0;
Ogre::ManualObject* manObj = _scene->createManualObject("recastTempMO");
manObj->begin("arena_locker/blue",Ogre::RenderOperation::OT_TRIANGLE_LIST);
for( int i = 0; i < numPolys; ++i)
{
const unsigned short* p = &polygons[i * numVertsPerPoly * 2];
unsigned short vi[3];
for(int j = 2; j < numVertsPerPoly; ++j)
{
if(p[j] == RC_MESH_NULL_IDX) break;
vi[0] = p[0];
vi[1] = p[j-1];
vi[2] = p[j];
for(int k = 0; k < 3; ++k)
{
const unsigned short* v = &vertices[vi[k]*3];
const float x = origin[0] + v[0] * _recastParams.getCellSize();
const float y = origin[1] + v[1] * _recastParams.getCellHeight();
const float z = origin[2] + v[2] * _recastParams.getCellSize();
manObj->position(x,y,z);
}
manObj->triangle(nIndex,nIndex+1,nIndex+2);
nIndex += 3;
}
}
manObj->end();
return manObj;
}
示例4:
void RenderSystem::RenderMesh3D(std::string meshName, std::string materialName, const MagicDGP::Mesh3D* pMesh)
{
InfoLog << "RenderSystem::RenderMesh3D" << std::endl;
Ogre::ManualObject* pMObj = NULL;
if (mpSceneMgr->hasManualObject(meshName))
{
pMObj = mpSceneMgr->getManualObject(meshName);
pMObj->clear();
}
else
{
pMObj = mpSceneMgr->createManualObject(meshName);
if (mpSceneMgr->hasSceneNode("ModelNode"))
{
mpSceneMgr->getSceneNode("ModelNode")->attachObject(pMObj);
}
else
{
mpSceneMgr->getRootSceneNode()->createChildSceneNode("ModelNode")->attachObject(pMObj);
}
}
pMObj->begin(materialName, Ogre::RenderOperation::OT_TRIANGLE_LIST);
int vertNum = pMesh->GetVertexNumber();
for (int i = 0; i < vertNum; i++)
{
const MagicDGP::Vertex3D* pVert = pMesh->GetVertex(i);
MagicMath::Vector3 pos = pVert->GetPosition();
MagicMath::Vector3 nor = pVert->GetNormal();
MagicMath::Vector3 color = pVert->GetColor();
pMObj->position(pos[0], pos[1], pos[2]);
pMObj->normal(nor[0], nor[1], nor[2]);
pMObj->colour(color[0], color[1], color[2]);
}
int faceNum = pMesh->GetFaceNumber();
for (int i = 0; i < faceNum; i++)
{
if (pMesh->GetFace(i)->IsValid())
{
const MagicDGP::Edge3D* pEdge = pMesh->GetFace(i)->GetEdge();
pMObj->triangle(pEdge->GetVertex()->GetId(), pEdge->GetNext()->GetVertex()->GetId(), pEdge->GetPre()->GetVertex()->GetId());
}
}
pMObj->end();
}
示例5:
Ogre::ManualObject* BasicTutorial2::createCubeMesh (Ogre::String name, Ogre::String matName)
{
Ogre::ManualObject* cube = new Ogre::ManualObject(name);
cube->begin(matName);
cube->position(0.5f,-0.5f,1.0f);cube->normal(0.408248f,-0.816497f,0.408248f);cube->textureCoord(1,0);
cube->position(-0.5f,-0.5f,0.0f);cube->normal(-0.408248f,-0.816497f,-0.408248f);cube->textureCoord(0,1);
cube->position(0.5f,-0.5f,0.0f);cube->normal(0.666667f,-0.333333f,-0.666667f);cube->textureCoord(1,1);
cube->position(-0.5f,-0.5f,1.0f);cube->normal(-0.666667f,-0.333333f,0.666667f);cube->textureCoord(0,0);
cube->position(0.5f,0.5f,1.0f);cube->normal(0.666667f,0.333333f,0.666667f);cube->textureCoord(1,0);
cube->position(-0.5,-0.5,1.0);cube->normal(-0.666667f,-0.333333f,0.666667f);cube->textureCoord(0,1);
cube->position(0.5,-0.5,1.0);cube->normal(0.408248,-0.816497,0.408248f);cube->textureCoord(1,1);
cube->position(-0.5,0.5,1.0);cube->normal(-0.408248,0.816497,0.408248);cube->textureCoord(0,0);
cube->position(-0.5,0.5,0.0);cube->normal(-0.666667,0.333333,-0.666667);cube->textureCoord(0,1);
cube->position(-0.5,-0.5,0.0);cube->normal(-0.408248,-0.816497,-0.408248);cube->textureCoord(1,1);
cube->position(-0.5,-0.5,1.0);cube->normal(-0.666667,-0.333333,0.666667);cube->textureCoord(1,0);
cube->position(0.5,-0.5,0.0);cube->normal(0.666667,-0.333333,-0.666667);cube->textureCoord(0,1);
cube->position(0.5,0.5,0.0);cube->normal(0.408248,0.816497,-0.408248);cube->textureCoord(1,1);
cube->position(0.5,-0.5,1.0);cube->normal(0.408248,-0.816497,0.408248);cube->textureCoord(0,0);
cube->position(0.5,-0.5,0.0);cube->normal(0.666667,-0.333333,-0.666667);cube->textureCoord(1,0);
cube->position(-0.5,-0.5,0.0);cube->normal(-0.408248,-0.816497,-0.408248);cube->textureCoord(0,0);
cube->position(-0.5,0.5,1.0);cube->normal(-0.408248,0.816497,0.408248);cube->textureCoord(1,0);
cube->position(0.5,0.5,0.0);cube->normal(0.408248,0.816497,-0.408248);cube->textureCoord(0,1);
cube->position(-0.5,0.5,0.0);cube->normal(-0.666667,0.333333,-0.666667);cube->textureCoord(1,1);
cube->position(0.5,0.5,1.0);cube->normal(0.666667,0.333333,0.666667);cube->textureCoord(0,0);
cube->triangle(0,1,2); cube->triangle(3,1,0);
cube->triangle(4,5,6); cube->triangle(4,7,5);
cube->triangle(8,9,10); cube->triangle(10,7,8);
cube->triangle(4,11,12); cube->triangle(4,13,11);
cube->triangle(14,8,12); cube->triangle(14,15,8);
cube->triangle(16,17,18); cube->triangle(16,19,17);
cube->end();
return cube;
}
示例6: ExportWallMesh
void OgreExporter_c::ExportWallMesh(Ogre::ManualObject &manualMesh, int floorHeight, int ceilingHeight, Name_u textureName, int offsetX, int offsetY, const Vertex_s *vertices, const LineDef_s &lineDef, const WadFile_c &wad)
{
std::stringstream stream;
stream << textureName.ToString();
manualMesh.begin(stream.str(), Ogre::RenderOperation::OT_TRIANGLE_LIST);
const Texture_s &tex = wad.GetTextureInfo(textureName);
const Vertex_s &startVertex = vertices[lineDef.iStartVertex];
const Vertex_s &endVertex = vertices[lineDef.iEndVertex];
int height = ceilingHeight - floorHeight;
int width = Ogre::Vector2(startVertex.iX, startVertex.iY).distance(Ogre::Vector2(endVertex.iX, endVertex.iY));
float offsetU = offsetX / (float) tex.uWidth;
float offsetV = offsetY / (float) tex.uHeight;
float endV = (height / (float)tex.uHeight) + offsetV;
float endU = (width / (float) tex.uWidth) + offsetU;
manualMesh.position(-startVertex.iX, floorHeight, startVertex.iY);
manualMesh.textureCoord(offsetU, endV);
manualMesh.position(-startVertex.iX, ceilingHeight, startVertex.iY);
manualMesh.textureCoord(offsetU, offsetV);
manualMesh.position(-endVertex.iX, ceilingHeight, endVertex.iY);
manualMesh.textureCoord(endU, offsetV);
manualMesh.position(-endVertex.iX, floorHeight, endVertex.iY);
manualMesh.textureCoord(endU, endV);
manualMesh.triangle(2, 1, 0);
manualMesh.triangle(0, 3, 2);
manualMesh.end();
}
示例7: malloc
//-------------------------------------------------------------------------------------
Ogre::ManualObject* const DigitalForensicsVisualisation::rectangle(std::string matName)
{
char* name = (char*) malloc (32);
sprintf(name, "rect%d", app.rectCount++);
Ogre::ManualObject* rect = mSceneMgr->createManualObject(name);
rect->begin(matName, Ogre::RenderOperation::OT_TRIANGLE_LIST);
rect->position(100,100.1,0);
rect->textureCoord(1,0);
rect->normal(50,500,50);
rect->position(0,100.1,100);
rect->textureCoord(0,1);
rect->normal(50,500,50);
rect->position(0,100.1,0);
rect->textureCoord(0,0);
rect->normal(50,500,50);
rect->position(100,100.1,100);
rect->textureCoord(1,1);
rect->normal(50,500,50);
rect->triangle(2,1,0);
rect->triangle(1,3,0);
rect->end();
free(name);
return rect;
}
示例8: createCubeMesh
//Copied from BetaCairo demo : http://www.ogre3d.org/forums/viewtopic.php?t=26987 (created by betajaen)
Ogre::ManualObject* OgreAppLogic::createCubeMesh(const std::string& name, const std::string& matName)
{
Ogre::ManualObject* cube = new Ogre::ManualObject(name);
cube->begin(matName);
cube->position(0.500000,-0.500000,1.000000);
cube->normal(0.408248f,-0.816497f,0.408248f);
cube->textureCoord(1,0);
cube->position(-0.500000,-0.500000,0.000000);
cube->normal(-0.408248f,-0.816497f,-0.408248f);
cube->textureCoord(0,1);
cube->position(0.500000,-0.500000,0.000000);
cube->normal(0.666667f,-0.333333f,-0.666667f);
cube->textureCoord(1,1);
cube->position(-0.500000,-0.500000,1.000000);
cube->normal(-0.666667f,-0.333333f,0.666667f);
cube->textureCoord(0,0);
cube->position(0.500000,0.500000,1.000000);
cube->normal(0.666667f,0.333333f,0.666667f);
cube->textureCoord(1,0);
cube->position(-0.500000,-0.500000,1.000000);
cube->normal(-0.666667f,-0.333333f,0.666667f);
cube->textureCoord(0,1);
cube->position(0.500000,-0.500000,1.000000);
cube->normal(0.408248f,-0.816497f,0.408248f);
cube->textureCoord(1,1);
cube->position(-0.500000,0.500000,1.000000);
cube->normal(-0.408248f,0.816497f,0.408248f);
cube->textureCoord(0,0);
cube->position(-0.500000,0.500000,0.000000);
cube->normal(-0.666667f,0.333333f,-0.666667f);
cube->textureCoord(0,1);
cube->position(-0.500000,-0.500000,0.000000);
cube->normal(-0.408248f,-0.816497f,-0.408248f);
cube->textureCoord(1,1);
cube->position(-0.500000,-0.500000,1.000000);
cube->normal(-0.666667f,-0.333333f,0.666667f);
cube->textureCoord(1,0);
cube->position(0.500000,-0.500000,0.000000);
cube->normal(0.666667f,-0.333333f,-0.666667f);
cube->textureCoord(0,1);
cube->position(0.500000,0.500000,0.000000);
cube->normal(0.408248f,0.816497f,-0.408248f);
cube->textureCoord(1,1);
cube->position(0.500000,-0.500000,1.000000);
cube->normal(0.408248f,-0.816497f,0.408248f);
cube->textureCoord(0,0);
cube->position(0.500000,-0.500000,0.000000);
cube->normal(0.666667f,-0.333333f,-0.666667f);
cube->textureCoord(1,0);
cube->position(-0.500000,-0.500000,0.000000);
cube->normal(-0.408248f,-0.816497f,-0.408248f);
cube->textureCoord(0,0);
cube->position(-0.500000,0.500000,1.000000);
cube->normal(-0.408248f,0.816497f,0.408248f);
cube->textureCoord(1,0);
cube->position(0.500000,0.500000,0.000000);
cube->normal(0.408248f,0.816497f,-0.408248f);
cube->textureCoord(0,1);
cube->position(-0.500000,0.500000,0.000000);
cube->normal(-0.666667f,0.333333f,-0.666667f);
cube->textureCoord(1,1);
cube->position(0.500000,0.500000,1.000000);
cube->normal(0.666667f,0.333333f,0.666667f);
cube->textureCoord(0,0);
cube->triangle(0,1,2);
cube->triangle(3,1,0);
cube->triangle(4,5,6);
cube->triangle(4,7,5);
cube->triangle(8,9,10);
cube->triangle(10,7,8);
cube->triangle(4,11,12);
cube->triangle(4,13,11);
cube->triangle(14,8,12);
cube->triangle(14,15,8);
cube->triangle(16,17,18);
cube->triangle(16,19,17);
cube->end();
//.........这里部分代码省略.........
示例9: generateMesh
void Map::generateMesh(std::string materialName)
{
Ogre::ManualObject* plane = new Ogre::ManualObject("plane");
plane->estimateIndexCount(m_length * m_width * 8);
plane->estimateVertexCount(m_length * m_width * 8);
plane->clear();
plane->begin(materialName);
Ogre::Vector3 pos = Ogre::Vector3(0, 0, 0);
Ogre::Quaternion quat;
Ogre::Quaternion quatNext;
unsigned long planeNum = 0;
for (unsigned int i = 0; i < m_length; i++) {
quat = m_rotationalSpline.getPoint(i);
quatNext = m_rotationalSpline.getPoint(i + 1);
for (int x = -100 * (m_width / (double) 2), j = 0; (unsigned) j < m_width; j++, x += 100) {
int back = -100;
int left = x;
int right = x + 100;
int down = -20 ;
Ogre::Vector3 nextPos = pos + quat * Ogre::Vector3(0, 0, back);
Ogre::Vector3 posMinus50 = pos + quat * Ogre::Vector3(left, 0, 0);
Ogre::Vector3 posPlus50 = pos + quat * Ogre::Vector3(right, 0, 0);
Ogre::Vector3 nextPosMinus50 = nextPos + quatNext * Ogre::Vector3(left, 0, 0);
Ogre::Vector3 nextPosPlus50 = nextPos + quatNext * Ogre::Vector3(right, 0, 0);
//TODO: fix normals?
plane->position(posMinus50);
plane->normal((quat * Vector3(0, 1, 0)).normalisedCopy());
plane->textureCoord(1, 1);
plane->position(nextPosMinus50);
plane->normal((quat * Vector3(0, 1, 0)).normalisedCopy());
plane->textureCoord(1, 0);
plane->position(posPlus50);
plane->normal((quat * Vector3(0, 1, 0)).normalisedCopy());
plane->textureCoord(0, 1);
plane->position(nextPosPlus50);
plane->normal((quat * Vector3(0, 1, 0)).normalisedCopy());
plane->textureCoord(0, 0);
Ogre::Vector3 nextPosDown = nextPos + quat * Ogre::Vector3(0, down, 0);
Ogre::Vector3 posMinus50Down = posMinus50 + quat * Ogre::Vector3(0, down, 0);
Ogre::Vector3 posPlus50Down = posPlus50 + quat * Ogre::Vector3(0, down, 0);
Ogre::Vector3 nextPosMinus50Down = nextPosMinus50 + quatNext * Ogre::Vector3(0, down, 0);
Ogre::Vector3 nextPosPlus50Down = nextPosPlus50 + quatNext * Ogre::Vector3(0, down, 0);
//TODO: fix normals?
plane->position(posMinus50Down);
plane->normal((quat * Vector3(-1, -1, 1)).normalisedCopy());
plane->textureCoord(0, 0);
plane->position(nextPosMinus50Down);
plane->normal((quat * Vector3(-1, -1, -1)).normalisedCopy());
plane->textureCoord(0, 1);
plane->position(posPlus50Down);
plane->normal((quat * Vector3(1, -1, 1)).normalisedCopy());
plane->textureCoord(1, 0);
plane->position(nextPosPlus50Down);
plane->normal((quat * Vector3(1, -1, -1)).normalisedCopy());
plane->textureCoord(1, 1);
if (m_cubes[planeNum / (double) m_width][planeNum % m_width] != HOLE) {
//if (m_cubes[planeNum / (double) m_width][planeNum % m_width] == NORMAL)
//{
//top
plane->triangle(0 + planeNum * 8, 1 + planeNum * 8, 2 + planeNum * 8);
plane->triangle(2 + planeNum * 8, 1 + planeNum * 8, 0 + planeNum * 8);
plane->triangle(1 + planeNum * 8, 3 + planeNum * 8, 2 + planeNum * 8);
plane->triangle(2 + planeNum * 8, 3 + planeNum * 8, 1 + planeNum * 8);
//}
//bottom
plane->triangle(4 + planeNum * 8, 5 + planeNum * 8, 6 + planeNum * 8);
plane->triangle(6 + planeNum * 8, 5 + planeNum * 8, 4 + planeNum * 8);
plane->triangle(5 + planeNum * 8, 7 + planeNum * 8, 6 + planeNum * 8);
plane->triangle(6 + planeNum * 8, 7 + planeNum * 8, 5 + planeNum * 8);
if (planeNum % m_width == 0 || m_cubes[planeNum / (double) m_width][(planeNum - 1) % m_width] == HOLE) {
//left
plane->triangle(0 + planeNum * 8, 4 + planeNum * 8, 5 + planeNum * 8);
plane->triangle(5 + planeNum * 8, 4 + planeNum * 8, 0 + planeNum * 8);
plane->triangle(0 + planeNum * 8, 1 + planeNum * 8, 5 + planeNum * 8);
plane->triangle(5 + planeNum * 8, 1 + planeNum * 8, 0 + planeNum * 8);
}
if (planeNum % m_width == m_width - 1 || m_cubes[planeNum / (double) m_width][(planeNum + 1) % m_width] == HOLE) {
//right
plane->triangle(2 + planeNum * 8, 6 + planeNum * 8, 7 + planeNum * 8);
plane->triangle(7 + planeNum * 8, 6 + planeNum * 8, 2 + planeNum * 8);
plane->triangle(2 + planeNum * 8, 3 + planeNum * 8, 7 + planeNum * 8);
plane->triangle(7 + planeNum * 8, 3 + planeNum * 8, 2 + planeNum * 8);
}
if (planeNum / (double) m_width >= m_length - 1 || m_cubes[(planeNum + m_width) / (double) m_width][planeNum % m_width] == HOLE) {
//back
plane->triangle(5 + planeNum * 8, 7 + planeNum * 8, 1 + planeNum * 8);
plane->triangle(1 + planeNum * 8, 7 + planeNum * 8, 5 + planeNum * 8);
plane->triangle(1 + planeNum * 8, 3 + planeNum * 8, 7 + planeNum * 8);
//.........这里部分代码省略.........
示例10: CreateWall
void OgreApplication::CreateWall(Ogre::String material_name){
try {
/* Create two rectangles */
/* Retrieve scene manager and root scene node */
Ogre::SceneManager* scene_manager = ogre_root_->getSceneManager("MySceneManager");
Ogre::SceneNode* root_scene_node = scene_manager->getRootSceneNode();
/* Create the 3D object */
Ogre::ManualObject* object = NULL;
Ogre::String object_name = "Wall";
object = scene_manager->createManualObject(object_name);
object->setDynamic(false);
/* Create triangle list for the object */
object->begin(material_name, Ogre::RenderOperation::OT_TRIANGLE_LIST);
/* Add vertices */
/* One side of the "wall" */
object->position(-1.0,-1.0,0.0);
object->normal(0.0, 0.0, -1.0);
object->tangent(-1.0, 0.0, 0.0);
object->textureCoord(1.0, 0.0);
object->position(-1.0,1.0,0.0);
object->normal(0.0, 0.0, -1.0);
object->tangent(-1.0, 0.0, 0.0);
object->textureCoord(1.0, 1.0);
object->position(1.0,1.0,0.0);
object->normal(0.0, 0.0, -1.0);
object->tangent(-1.0, 0.0, 0.0);
object->textureCoord(0.0, 1.0);
object->position(1.0,-1.0,0.0);
object->normal(0.0, 0.0, -1.0);
object->tangent(-1.0, 0.0, 0.0);
object->textureCoord(0.0, 0.0);
/* The other side of the "wall" */
object->position(-1.0,-1.0,0.0);
object->normal(0.0, 0.0, 1.0);
object->tangent(1.0, 0.0, 0.0);
object->textureCoord(0.0, 0.0);
object->position(-1.0,1.0,0.0);
object->normal(0.0, 0.0, 1.0);
object->tangent(1.0, 0.0, 0.0);
object->textureCoord(0.0, 1.0);
object->position(1.0,1.0,0.0);
object->normal(0.0, 0.0, 1.0);
object->tangent(1.0, 0.0, 0.0);
object->textureCoord(1.0, 1.0);
object->position(1.0,-1.0,0.0);
object->normal(0.0, 0.0, 1.0);
object->tangent(1.0, 0.0, 0.0);
object->textureCoord(1.0, 0.0);
/* Add triangles */
/* One side */
object->triangle(0, 1, 2);
object->triangle(0, 2, 3);
/* The other side */
object->triangle(4, 7, 6);
object->triangle(4, 6, 5);
/* We finished the object */
object->end();
/* Convert triangle list to a mesh */
Ogre::String mesh_name = "Wall";
object->convertToMesh(mesh_name);
/* Create one instance of the sphere (one entity) */
/* The same object can have multiple instances or entities */
Ogre::Entity* entity = scene_manager->createEntity(mesh_name);
/* Apply a material to the entity to give it color */
/* We already did that above, so we comment it out here */
/* entity->setMaterialName(material_name); */
/* But, this call is useful if we have multiple entities with different materials */
/* Create a scene node for the entity */
/* The scene node keeps track of the entity's position */
Ogre::SceneNode* scene_node = root_scene_node->createChildSceneNode(mesh_name);
scene_node->attachObject(entity);
/* Position and rotate the entity with the scene node */
//scene_node->rotate(Ogre::Vector3(0, 1, 0), Ogre::Degree(60));
//scene_node->rotate(Ogre::Vector3(1, 0, 0), Ogre::Degree(30));
//scene_node->rotate(Ogre::Vector3(1, 0, 0), Ogre::Degree(-90));
//scene_node->translate(0.0, 0.0, 0.0);
scene_node->scale(0.5, 0.5, 0.5);
}
catch (Ogre::Exception &e){
throw(OgreAppException(std::string("Ogre::Exception: ") + std::string(e.what())));
//.........这里部分代码省略.........
示例11: EngineSetup
void CTransparentMaterialView::EngineSetup(void)
{
Ogre::Root *Root = ((CTransparentMaterialApp*)AfxGetApp())->m_Engine->GetRoot();
Ogre::SceneManager *SceneManager = NULL;
SceneManager = Root->createSceneManager(Ogre::ST_GENERIC, "MFCOgre");
//
// Create a render window
// This window should be the current ChildView window using the externalWindowHandle
// value pair option.
//
Ogre::NameValuePairList parms;
parms["externalWindowHandle"] = Ogre::StringConverter::toString((long)m_hWnd);
parms["vsync"] = "true";
CRect rect;
GetClientRect(&rect);
Ogre::RenderTarget *RenderWindow = Root->getRenderTarget("Ogre in MFC");
if (RenderWindow == NULL)
{
try
{
m_RenderWindow = Root->createRenderWindow("Ogre in MFC", rect.Width(), rect.Height(), false, &parms);
}
catch(...)
{
MessageBox("Cannot initialize\nCheck that graphic-card driver is up-to-date", "Initialize Render System", MB_OK | MB_ICONSTOP);
exit(EXIT_SUCCESS);
}
}
// Load resources
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
// Create the camera
m_Camera = SceneManager->createCamera("Camera");
m_Camera->setNearClipDistance(0.5);
m_Camera->setFarClipDistance(5000);
m_Camera->setCastShadows(false);
m_Camera->setUseRenderingDistance(true);
m_Camera->setPosition(Ogre::Vector3(320.0, 240.0, 500.0));
Ogre::SceneNode *CameraNode = NULL;
CameraNode = SceneManager->getRootSceneNode()->createChildSceneNode("CameraNode");
Ogre::Viewport* Viewport = NULL;
if (0 == m_RenderWindow->getNumViewports())
{
Viewport = m_RenderWindow->addViewport(m_Camera);
Viewport->setBackgroundColour(Ogre::ColourValue(0.8f, 1.0f, 0.8f));
}
// Alter the camera aspect ratio to match the viewport
m_Camera->setAspectRatio(Ogre::Real(rect.Width()) / Ogre::Real(rect.Height()));
Ogre::ManualObject *Screen = SceneManager->createManualObject("Screen");
Screen->setDynamic(true);
Screen->begin("window", Ogre::RenderOperation::OT_TRIANGLE_LIST);
Screen->position(-100,-100,50);
Screen->textureCoord(0,0);
Screen->position(300,-100,50);
Screen->textureCoord(1,0);
Screen->position(300,300,50);
Screen->textureCoord(1,1);
Screen->triangle(0, 1, 2);
Screen->position(-100,-100,50);
Screen->textureCoord(0,0);
Screen->position(300,300,50);
Screen->textureCoord(1,1);
Screen->position(-100,300,50);
Screen->textureCoord(0,1);
Screen->triangle(3, 4, 5);
Screen->end();
Ogre::Entity *RobotEntity = SceneManager->createEntity("Robot", "robot.mesh");
Ogre::SceneNode *RobotNode = SceneManager->getRootSceneNode()->createChildSceneNode();
RobotNode->attachObject(RobotEntity);
Ogre::SceneNode *WindowNode = SceneManager->getRootSceneNode()->createChildSceneNode();
WindowNode->attachObject(Screen);
}
开发者ID:southerlies,项目名称:OGRE-3D-1.7-Application-Development-Cookbook-Code,代码行数:94,代码来源:TransparentMaterialView.cpp
示例12: DrawPlanetMap
void TestGame::DrawPlanetMap(Logic::PlanetJustGenerateEvent *evnt){
std::map<Logic::BaseCountry*,std::vector<Logic::CountryTile>>::iterator CntrItr;
std::vector<Logic::CountryTile>::iterator TileItr;
int tilesize=TILESIZE;
bool why;
Ogre::Vector3 tempVect;
int maxX = (int)Logic::BaseAsset::GetSigleton("MAP_X"),maxY=(int)Logic::BaseAsset::GetSigleton("MAP_Y");
Ogre::SceneNode* node,*capitalNode,*mapnode =mSceneMgr->getRootSceneNode()->createChildSceneNode("Map");
mapnode->translate(-maxX/2*tilesize,-maxY/2*tilesize,0);
Ogre::Entity* entNinja = 0;
Ogre::FontPtr font = Ogre::FontManager::getSingleton().getResourceIterator().begin()->second;
// Make sure the texture is not WRITE_ONLY, we need to read the buffer to do the blending with the font (get the alpha for example)
int j =0;
for(CntrItr=evnt->allTiles.begin();CntrItr!=evnt->allTiles.end(); CntrItr++){
Ogre::ManualObject* manual = mSceneMgr->createManualObject("CountryObject"+CntrItr->first->mName);
Ogre::Texture* texture = Ogre::TextureManager::getSingleton().createManual("CountryText"+CntrItr->first->mName,"General",Ogre::TEX_TYPE_2D,512, 512, 0, Ogre::PF_FLOAT32_RGBA , Ogre::TU_DEFAULT).getPointer();
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create("CountryMaterial"+CntrItr->first->mName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
//Draw the background to the new texture
Ogre::HardwarePixelBufferSharedPtr pixelBuffer = texture->getBuffer();
// Lock the pixel buffer and get a pixel box
pixelBuffer->lock(Ogre::HardwareBuffer::HBL_NORMAL); // for best performance use HBL_DISCARD!
const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock();
float *pDest = static_cast<float*>(pixelBox.data);
Ogre::ColourValue *temp = &CntrItr->first->mColor;
// Fill in some pixel data. This will give a semi-transparent blue,
// but this is of course dependent on the chosen pixel format.
for (size_t k = 0; k < 512; k++)
for(size_t q = 0; q < 512; q++)
{
*pDest++ =temp->b; // B
*pDest++ = temp->g;
*pDest++ =temp->r;
*pDest++ = 0; // A*/
/* *pDest++ = 255; // B
*pDest++ = 0; // G
*pDest++ = 0; // R
*pDest++ = 127; // A*/
}
// Unlock the pixel buffer
pixelBuffer->unlock();
///WriteToTexture(Logic::LogicStd::IntToString(j),Ogre::TexturePtr(texture),Ogre::Image::Box(25,275,370,500),font,Ogre::ColourValue(1.0,1.0,1.0,1.0),'c');
mat->getTechnique(0)->getPass(0)->createTextureUnitState("CountryText"+CntrItr->first->mName);
// mat->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
j++;
// specify the material (by name) and rendering type
manual->begin("CountryMaterial"+CntrItr->first->mName, Ogre::RenderOperation::OT_TRIANGLE_LIST);
int i=0;
for(TileItr= CntrItr->second.begin();TileItr!= CntrItr->second.end();TileItr++){
tempVect = calculateActualPointFromCenter(CntrItr->first->mCapital.mPosition,(*TileItr).mPosition);
tempVect =tempVect*tilesize;
manual->position(tempVect.x-tilesize/2,tempVect.y+tilesize/2,tempVect.z);
//manual->colour(CntrItr->first->mColor);
manual->position(tempVect.x+tilesize/2,tempVect.y+tilesize/2,tempVect.z);
//manual->colour(CntrItr->first->mColor);
manual->position(tempVect.x+tilesize/2,tempVect.y-tilesize/2,tempVect.z);
//manual->colour(CntrItr->first->mColor);
manual->position(tempVect.x-tilesize/2,tempVect.y-tilesize/2,tempVect.z);
//manual->colour(CntrItr->first->mColor);
manual->triangle(i*4+0,i*4+2,i*4+1);
manual->triangle(i*4+0,i*4+3,i*4+2);
//manual->quad(i*4+0,i*4+2,i*4+3,i*4+1);
i++;
}
// tell Ogre, your definition has finished
manual->end();
// add ManualObject to the RootSceneNode (so it will be visible)
node =mapnode->createChildSceneNode();
entNinja= mSceneMgr->createEntity("Capital/"+CntrItr->first->mName, "capital.mesh");
entNinja->setCastShadows(true);
entNinja->setMaterialName("CountryMaterial"+CntrItr->first->mName);
Control::ClickHelper* helpr = new Control::ClickHelper(Logic::CHT_COUNTRY);
helpr->target = CntrItr->first;
entNinja->setUserAny(Ogre::Any(helpr));
//.........这里部分代码省略.........
示例13: EngineSetup
void CSceletalAnimationView::EngineSetup(void)
{
Ogre::Root *Root = ((CSceletalAnimationApp*)AfxGetApp())->m_Engine->GetRoot();
Ogre::SceneManager *SceneManager = NULL;
SceneManager = Root->createSceneManager(Ogre::ST_GENERIC, "Animation");
//
// Create a render window
// This window should be the current ChildView window using the externalWindowHandle
// value pair option.
//
Ogre::NameValuePairList parms;
parms["externalWindowHandle"] = Ogre::StringConverter::toString((long)m_hWnd);
parms["vsync"] = "true";
CRect rect;
GetClientRect(&rect);
Ogre::RenderTarget *RenderWindow = Root->getRenderTarget("Mouse Input");
if (RenderWindow == NULL)
{
try
{
m_RenderWindow = Root->createRenderWindow("Mouse Input", rect.Width(), rect.Height(), false, &parms);
}
catch(...)
{
MessageBox("Cannot initialize\nCheck that graphic-card driver is up-to-date", "Initialize Render System", MB_OK | MB_ICONSTOP);
exit(EXIT_SUCCESS);
}
}
// Load resources
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
// Create the camera
m_Camera = SceneManager->createCamera("Camera");
m_Camera->setNearClipDistance(0.5);
m_Camera->setFarClipDistance(5000);
m_Camera->setCastShadows(false);
m_Camera->setUseRenderingDistance(true);
m_Camera->setPosition(Ogre::Vector3(5.0, 5.0, 10.0));
Ogre::SceneNode *CameraNode = NULL;
CameraNode = SceneManager->getRootSceneNode()->createChildSceneNode("CameraNode");
Ogre::Viewport* Viewport = NULL;
if (0 == m_RenderWindow->getNumViewports())
{
Viewport = m_RenderWindow->addViewport(m_Camera);
Viewport->setBackgroundColour(Ogre::ColourValue(0.8f, 0.8f, 0.8f));
}
// Alter the camera aspect ratio to match the viewport
m_Camera->setAspectRatio(Ogre::Real(rect.Width()) / Ogre::Real(rect.Height()));
m_Camera->lookAt(Ogre::Vector3(0.5, 0.5, 0.5));
m_Camera->setPolygonMode(Ogre::PolygonMode::PM_WIREFRAME);
Ogre::ManualObject* ManualObject = NULL;
ManualObject = SceneManager->createManualObject("Animation");
ManualObject->setDynamic(false);
ManualObject->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST);
//face 1
ManualObject->position(0, 0, 0);//0
ManualObject->position(1, 0, 0);//1
ManualObject->position(1, 1, 0);//2
ManualObject->triangle(0, 1, 2);//3
ManualObject->position(0, 0, 0);//4
ManualObject->position(1, 1, 0);//5
ManualObject->position(0, 1, 0);//6
ManualObject->triangle(3, 4, 5);//7
//face 2
ManualObject->position(0, 0, 1);//8
ManualObject->position(1, 0, 1);//9
ManualObject->position(1, 1, 1);//10
ManualObject->triangle(6, 7, 8);//11
ManualObject->position(0, 0, 1);//12
ManualObject->position(1, 1, 1);//13
ManualObject->position(0, 1, 1);//14
ManualObject->triangle(9, 10, 11);//15
//face 3
ManualObject->position(0, 0, 0);//16
ManualObject->position(1, 0, 0);//17
ManualObject->position(1, 0, 1);//18
ManualObject->triangle(12, 13, 14);//19
ManualObject->position(0, 0, 0);
ManualObject->position(1, 0, 1);
ManualObject->position(0, 1, 1);
ManualObject->triangle(15, 16, 17);
//face 4
ManualObject->position(1, 0, 0);
ManualObject->position(1, 1, 0);
ManualObject->position(1, 1, 1);
ManualObject->triangle(18, 19, 20);
ManualObject->position(1, 0, 0);
ManualObject->position(1, 1, 1);
//.........这里部分代码省略.........
开发者ID:southerlies,项目名称:OGRE-3D-1.7-Application-Development-Cookbook-Code,代码行数:101,代码来源:SceletalAnimationView.cpp
示例14: generateMeshObstacles
void Map::generateMeshObstacles(std::string materialName)
{
Ogre::ManualObject* obstacles = new Ogre::ManualObject("obstacles");
obstacles->estimateIndexCount(m_length * m_width * 8);
obstacles->estimateVertexCount(m_length * m_width * 8);
obstacles->clear();
obstacles->begin(materialName);
Ogre::Vector3 pos = Ogre::Vector3(0, 0, 0);
Ogre::Quaternion quat;
Ogre::Quaternion quatNext;
unsigned long planeNum = 0;
m_obstaclePositions.clear();
for (unsigned int i = 0; i < m_length; i++) {
quat = m_rotationalSpline.getPoint(i);
quatNext = m_rotationalSpline.getPoint(i + 1);
for (int x = -100 * (m_width / (double) 2), j = 0; (unsigned) j < m_width; j++, x += 100) {
int back = -100;
int left = x;
int right = x + 100;
int up = 100;
Ogre::Vector3 nextPos = pos + quat * Ogre::Vector3(0, 0, back);
Ogre::Vector3 posMinus50 = pos + quat * Ogre::Vector3(left, 0, 0);
Ogre::Vector3 posPlus50 = pos + quat * Ogre::Vector3(right, 0, 0);
Ogre::Vector3 nextPosMinus50 = nextPos + quatNext * Ogre::Vector3(left, 0, 0);
Ogre::Vector3 nextPosPlus50 = nextPos + quatNext * Ogre::Vector3(right, 0, 0);
//TODO: fix normals
obstacles->position(posMinus50);
obstacles->normal((quat * Vector3(0, 1, 0)).normalisedCopy());
obstacles->textureCoord(1, 1);
obstacles->position(nextPosMinus50);
obstacles->normal((quat * Vector3(0, 1, 0)).normalisedCopy());
obstacles->textureCoord(1, 0);
obstacles->position(posPlus50);
obstacles->normal((quat * Vector3(0, 1, 0)).normalisedCopy());
obstacles->textureCoord(0, 1);
obstacles->position(nextPosPlus50);
obstacles->normal((quat * Vector3(0, 1, 0)).normalisedCopy());
obstacles->textureCoord(0, 0);
Ogre::Vector3 nextPosUp = nextPos + quat * Ogre::Vector3(0, up, 0);
Ogre::Vector3 posMinus50Up = posMinus50 + quat * Ogre::Vector3(0, up, 0);
Ogre::Vector3 posPlus50Up = posPlus50 + quat * Ogre::Vector3(0, up, 0);
Ogre::Vector3 nextPosMinus50Up = nextPosMinus50 + quatNext * Ogre::Vector3(0, up, 0);
Ogre::Vector3 nextPosPlus50Up = nextPosPlus50 + quatNext * Ogre::Vector3(0, up, 0);
//TODO: fix normals
obstacles->position(posMinus50Up);
obstacles->normal((quat * Vector3(-1, 1, 1)).normalisedCopy());
obstacles->textureCoord(0, 0);
obstacles->position(nextPosMinus50Up);
obstacles->normal((quat * Vector3(-1, 1, -1)).normalisedCopy());
obstacles->textureCoord(0, 1);
obstacles->position(posPlus50Up);
obstacles->normal((quat * Vector3(1, 1, 1)).normalisedCopy());
obstacles->textureCoord(1, 0);
obstacles->position(nextPosPlus50Up);
obstacles->normal((quat * Vector3(1, 1, -1)).normalisedCopy());
obstacles->textureCoord(1, 1);
if (m_cubes[planeNum / (double) m_width][planeNum % m_width] == OBSTACLE) {
//TODO: check if this hack works..
m_obstaclePositions.push_back(posMinus50);
//top
obstacles->triangle(4 + planeNum * 8, 5 + planeNum * 8, 6 + planeNum * 8);
obstacles->triangle(6 + planeNum * 8, 5 + planeNum * 8, 4 + planeNum * 8);
obstacles->triangle(5 + planeNum * 8, 7 + planeNum * 8, 6 + planeNum * 8);
obstacles->triangle(6 + planeNum * 8, 7 + planeNum * 8, 5 + planeNum * 8);
if (planeNum % m_width == 0 || m_cubes[planeNum / (double) m_width][(planeNum - 1) % m_width] != OBSTACLE) {
//left
obstacles->triangle(0 + planeNum * 8, 4 + planeNum * 8, 5 + planeNum * 8);
obstacles->triangle(5 + planeNum * 8, 4 + planeNum * 8, 0 + planeNum * 8);
obstacles->triangle(0 + planeNum * 8, 1 + planeNum * 8, 5 + planeNum * 8);
obstacles->triangle(5 + planeNum * 8, 1 + planeNum * 8, 0 + planeNum * 8);
}
if (planeNum % m_width == m_width - 1 || m_cubes[planeNum / (double) m_width][(planeNum + 1) % m_width] != OBSTACLE) {
//right
obstacles->triangle(2 + planeNum * 8, 6 + planeNum * 8, 7 + planeNum * 8);
obstacles->triangle(7 + planeNum * 8, 6 + planeNum * 8, 2 + planeNum * 8);
obstacles->triangle(2 + planeNum * 8, 3 + planeNum * 8, 7 + planeNum * 8);
obstacles->triangle(7 + planeNum * 8, 3 + planeNum * 8, 2 + planeNum * 8);
}
if (planeNum / (double) m_width >= m_length - 1 || m_cubes[(planeNum + m_width) / (double) m_width][planeNum % m_width] != OBSTACLE) {
//back
obstacles->triangle(5 + planeNum * 8, 7 + planeNum * 8, 1 + planeNum * 8);
obstacles->triangle(1 + planeNum * 8, 7 + planeNum * 8, 5 + planeNum * 8);
obstacles->triangle(1 + planeNum * 8, 3 + planeNum * 8, 7 + planeNum * 8);
obstacles->triangle(7 + planeNum * 8, 3 + planeNum * 8, 1 + planeNum * 8);
}
//.........这里部分代码省略.........
示例15: createRecastPolyMesh
void AwarenessVisualizer::createRecastPolyMesh(const std::string& name, const unsigned short *verts, const int nverts, const unsigned short *polys, const int npolys, const unsigned char *areas, const int maxpolys, const unsigned short *regions, const int nvp, const float cs, const float ch, const float *orig, bool colorRegions)
{
// Demo specific parameters
float m_navMeshOffsetFromGround = 0.2; //ch / 5; // Distance above ground for drawing navmesh polygons
float m_navMeshEdgesOffsetFromGround = 0.5; //ch / 3; // Distance above ground for drawing edges of navmesh (should be slightly higher than navmesh polygons)
// float m_pathOffsetFromGround = 1 + m_navMeshOffsetFromGround; // Distance above ground for drawing path debug lines relative to cellheight (should be higher than navmesh polygons)
// Colors for navmesh debug drawing
static Ogre::ColourValue m_navmeshNeighbourEdgeCol(0.9, 0.9, 0.9); // Light Grey
static Ogre::ColourValue m_navmeshOuterEdgeCol(0, 0, 0); // Black
static Ogre::ColourValue m_navmeshGroundPolygonCol(0, 0.7, 0); // Green
static Ogre::ColourValue m_navmeshOtherPolygonCol(0, 0.175, 0); // Dark green
static Ogre::ColourValue m_pathCol(1, 0, 0); // Red
// When drawing regions choose different random colors for each region
Ogre::ColourValue* regionColors = NULL;
if (colorRegions) {
regionColors = new Ogre::ColourValue[maxpolys];
for (int i = 0; i < maxpolys; ++i) {
regionColors[i] = Ogre::ColourValue(Ogre::Math::RangeRandom(0, 1), Ogre::Math::RangeRandom(0, 1), Ogre::Math::RangeRandom(0, 1), 1);
}
}
int nIndex = 0;
if (npolys) {
// start defining the manualObject with the navmesh planes
Ogre::ManualObject* pRecastMOWalk;
if (mSceneManager.hasManualObject("RecastMOWalk_" + name)) {
pRecastMOWalk = mSceneManager.getManualObject("RecastMOWalk_" + name);
pRecastMOWalk->clear();
} else {
pRecastMOWalk = mSceneManager.createManualObject("RecastMOWalk_" + name);
//Remove from the overhead map.
pRecastMOWalk->setVisibilityFlags(pRecastMOWalk->getVisibilityFlags() & ~Ogre::SceneManager::WORLD_GEOMETRY_TYPE_MASK);
mTileSceneNode->attachObject(pRecastMOWalk);
}
pRecastMOWalk->begin("/common/base/authoring/awareness", Ogre::RenderOperation::OT_TRIANGLE_LIST);
for (int i = 0; i < npolys; ++i) { // go through all polygons
if (areas[i] == Navigation::POLYAREA_GROUND || areas[i] == DT_TILECACHE_WALKABLE_AREA) {
const unsigned short* p = &polys[i * nvp * 2];
unsigned short vi[3];
for (int j = 2; j < nvp; ++j) // go through all verts in the polygon
{
if (p[j] == RC_MESH_NULL_IDX)
break;
vi[0] = p[0];
vi[1] = p[j - 1];
vi[2] = p[j];
for (int k = 0; k < 3; ++k) // create a 3-vert triangle for each 3 verts in the polygon.
{
const unsigned short* v = &verts[vi[k] * 3];
const float x = orig[0] + v[0] * cs;
const float y = orig[1] + (v[1]/*+1*/) * ch;
const float z = -orig[2] - v[2] * cs;
pRecastMOWalk->position(x, y + m_navMeshOffsetFromGround, z);
if (colorRegions) {
pRecastMOWalk->colour(regionColors[regions[i]]); // Assign vertex color
} else {
if (areas[i] == Navigation::POLYAREA_GROUND)
pRecastMOWalk->colour(m_navmeshGroundPolygonCol);
else
pRecastMOWalk->colour(m_navmeshOtherPolygonCol);
}
}
pRecastMOWalk->triangle(nIndex, nIndex + 2, nIndex + 1);
nIndex += 3;
}
}
}
pRecastMOWalk->end();
// Define manualObject with the navmesh edges between neighbouring polygons
Ogre::ManualObject* pRecastMONeighbour;
if (mSceneManager.hasManualObject("RecastMONeighbour_" + name)) {
pRecastMONeighbour = mSceneManager.getManualObject("RecastMONeighbour_" + name);
pRecastMONeighbour->clear();
} else {
pRecastMONeighbour = mSceneManager.createManualObject("RecastMONeighbour_" + name);
//Remove from the overhead map.
pRecastMONeighbour->setVisibilityFlags(pRecastMONeighbour->getVisibilityFlags() & ~Ogre::SceneManager::WORLD_GEOMETRY_TYPE_MASK);
mTileSceneNode->attachObject(pRecastMONeighbour);
}
pRecastMONeighbour->begin("/common/base/authoring/awareness", Ogre::RenderOperation::OT_LINE_LIST);
for (int i = 0; i < npolys; ++i) {
const unsigned short* p = &polys[i * nvp * 2];
for (int j = 0; j < nvp; ++j) {
if (p[j] == RC_MESH_NULL_IDX)
break;
if (p[nvp + j] == RC_MESH_NULL_IDX)
continue;
int vi[2];
vi[0] = p[j];
//.........这里部分代码省略.........