本文整理汇总了C++中ManualObject::index方法的典型用法代码示例。如果您正苦于以下问题:C++ ManualObject::index方法的具体用法?C++ ManualObject::index怎么用?C++ ManualObject::index使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ManualObject
的用法示例。
在下文中一共展示了ManualObject::index方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pointPos
ManualObject *Debugging::createPathgridPoints(const ESM::Pathgrid *pathgrid)
{
ManualObject *result = mSceneMgr->createManualObject();
const float height = POINT_MESH_BASE * sqrtf(2);
result->begin(PATHGRID_POINT_MATERIAL, RenderOperation::OT_TRIANGLE_STRIP);
bool first = true;
uint32 startIndex = 0;
for(ESM::Pathgrid::PointList::const_iterator it = pathgrid->mPoints.begin();
it != pathgrid->mPoints.end();
it++, startIndex += 6)
{
Vector3 pointPos(it->mX, it->mY, it->mZ);
if (!first)
{
// degenerate triangle from previous octahedron
result->index(startIndex - 4); // 2nd point of previous octahedron
result->index(startIndex); // start point of current octahedron
}
result->position(pointPos + Vector3(0, 0, height)); // 0
result->position(pointPos + Vector3(-POINT_MESH_BASE, -POINT_MESH_BASE, 0)); // 1
result->position(pointPos + Vector3(POINT_MESH_BASE, -POINT_MESH_BASE, 0)); // 2
result->position(pointPos + Vector3(POINT_MESH_BASE, POINT_MESH_BASE, 0)); // 3
result->position(pointPos + Vector3(-POINT_MESH_BASE, POINT_MESH_BASE, 0)); // 4
result->position(pointPos + Vector3(0, 0, -height)); // 5
result->index(startIndex + 0);
result->index(startIndex + 1);
result->index(startIndex + 2);
result->index(startIndex + 5);
result->index(startIndex + 3);
result->index(startIndex + 4);
// degenerates
result->index(startIndex + 4);
result->index(startIndex + 5);
result->index(startIndex + 5);
// end degenerates
result->index(startIndex + 1);
result->index(startIndex + 4);
result->index(startIndex + 0);
result->index(startIndex + 3);
result->index(startIndex + 2);
first = false;
}
result->end();
result->setVisibilityFlags (RV_Debug);
return result;
}
示例2: createManual
void HelloOgre::createManual(){
Ogre::SceneManager* mSceneMgr= OgreApp::I()->getSceneManager();
#if 1
ManualObject* manual = mSceneMgr->createManualObject("manual");
// specify the material (by name) and rendering type
manual->begin("BaseWhiteNoLighting", RenderOperation::OT_LINE_LIST);
// manual->begin("BaseWhiteNoLighting", RenderOperation::OT_TRIANGLE_STRIP);
// define start and end point
manual->position(-100, -100, -100 );
manual->position(100, 100, 100 );
manual->colour( 1.0f, 1.0f, 1.0f, 1.0f );
// tell Ogre, your definition has finished
manual->end();
// add ManualObject to the RootSceneNode (so it will be visible)
mSceneMgr->getRootSceneNode()->attachObject(manual);
#endif
#if 1
// Create a manual object for 2D
manual = mSceneMgr->createManualObject("manual2");
// Use identity view/projection matrices
manual->setUseIdentityProjection(true);
manual->setUseIdentityView(true);
manual->begin("BaseWhiteNoLighting", RenderOperation::OT_LINE_STRIP);
manual->position(-0.2, -0.2, 0.0);
manual->position( 0.2, -0.2, 0.0);
manual->position( 0.2, 0.2, 0.0);
manual->position(-0.2, 0.2, 0.0);
manual->index(0);
manual->index(1);
manual->index(2);
manual->index(3);
manual->index(0);
manual->end();
// Use infinite AAB to always stay visible
AxisAlignedBox aabInf;
aabInf.setInfinite();
manual->setBoundingBox(aabInf);
// Render just before overlays
manual->setRenderQueueGroup(RENDER_QUEUE_OVERLAY - 1);
// Attach to scene
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(manual);
#endif
}
示例3: CreateSkyDome
// Sky Dome
//-------------------------------------------------------------------------------------
void CScene::CreateSkyDome(String sMater, Vector3 sc, float yaw)
{
ManualObject* m = app->mSceneMgr->createManualObject();
m->begin(sMater, RenderOperation::OT_TRIANGLE_LIST);
// divisions- quality
int ia = 32*2, ib = 24,iB = 24 +1/*below_*/, i=0;
//int ia = 4, ib = 4, i=0;
// angles, max
float a,b; const float B = PI_d/2.f, A = 2.f*PI_d;
float bb = B/ib, aa = A/ia; // add
ia += 1;
// up/dn y )
for (b = 0.f; b <= B+bb/*1*/*iB; b += bb)
{
float cb = sinf(b), sb = cosf(b);
float y = sb;
// circle xz o
for (a = 0.f; a <= A; a += aa, ++i)
{
float x = cosf(a)*cb, z = sinf(a)*cb;
m->position(x,y,z);
m->textureCoord(a/A, b/B);
if (a > 0.f && b > 0.f) // rect 2tri
{
m->index(i-1); m->index(i); m->index(i-ia);
m->index(i-1); m->index(i-ia); m->index(i-ia-1);
}
}
}
m->end();
AxisAlignedBox aab; aab.setInfinite();
m->setBoundingBox(aab); // always visible
m->setRenderQueueGroup(RQG_Sky);
m->setCastShadows(false);
#ifdef SR_EDITOR
m->setVisibilityFlags(RV_Sky); // hide on minimap
#endif
app->ndSky = app->mSceneMgr->getRootSceneNode()->createChildSceneNode();
app->ndSky->attachObject(m);
app->ndSky->setScale(sc);
Quaternion q; q.FromAngleAxis(Degree(-yaw), Vector3::UNIT_Y);
app->ndSky->setOrientation(q);
}
示例4: createTexturedRect
Ogre::SceneNode* Terminal::createTexturedRect(std::string object_name, std::string texture_name, float left, float top, float right, float bottom)
{
MaterialPtr material = MaterialManager::getSingleton().create(object_name,Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
material->getTechnique(0)->getPass(0)->createTextureUnitState(texture_name);
material->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(true);
material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
// Ogre::Rectangle2D* rect = new Ogre::Rectangle2D(true);
ManualObject* manual = Entropy::getSingletonPtr()->mSceneMgr->createManualObject(object_name);
manual->setUseIdentityProjection(true);
manual->setUseIdentityView(true);
manual->begin(object_name, RenderOperation::OT_TRIANGLE_STRIP);
manual->position(left, bottom, 0.0);
manual->position(left, top, 0.0);
manual->position(right, bottom, 0.0);
manual->position(right, top, 0.0);
manual->index(0);
manual->index(1);
manual->index(2);
manual->index(3);
manual->end();
// rect->setCorners(left,top,right,bottom);
// rect->setMaterial(object_name);
manual->setRenderQueueGroup(RENDER_QUEUE_OVERLAY);
Ogre::AxisAlignedBox aabInf;
aabInf.setInfinite();
manual->setBoundingBox(aabInf);
Ogre::SceneNode* rect_node = Entropy::getSingletonPtr()->mSceneMgr->getRootSceneNode()->createChildSceneNode(object_name);
rect_node->attachObject(manual);
// rect->setVisible(false);
// rect_node->setPosition(0,0,0);
return rect_node;
}
示例5: CreateRacingLine
void App::CreateRacingLine()
{
//void ROADPATCH::AddRacinglineScenenode(SCENENODE * node, ROADPATCH * nextpatch,
ManualObject* m = mSceneMgr->createManualObject();
m->begin("track/Racingline", RenderOperation::OT_TRIANGLE_LIST);
int ii = 0;
const std::list <ROADSTRIP>& roads = pGame->track.GetRoadList();
for (std::list <ROADSTRIP>::const_iterator it = roads.begin(); it != roads.end(); ++it)
{
const std::list <ROADPATCH>& pats = (*it).GetPatchList();
for (std::list <ROADPATCH>::const_iterator i = pats.begin(); i != pats.end(); ++i)
{
const VERTEXARRAY* a = &((*i).racingline_vertexarray);
if (!a) continue;
int verts = a->vertices.size();
if (verts == 0) continue;
int faces = a->faces.size();
for (int v = 0; v < verts; v += 3)
m->position(a->vertices[v+0], a->vertices[v+2], -a->vertices[v+1]);
for (int f = 0; f < faces; ++f)
m->index(ii + a->faces[f]);
ii += verts/3;
}
}
m->setCastShadows(false);
m->end();
hud->ndLine = mSceneMgr->getRootSceneNode()->createChildSceneNode();
hud->ndLine->attachObject(m);
//ndLine->setVisible(pSet->racingline);
}
示例6: CreateModel
// utility - create VDrift model in Ogre
//-------------------------------------------------------------------------------------------------------
ManualObject* App::CreateModel(SceneManager* sceneMgr, const String& mat,
class VERTEXARRAY* a, Vector3 vPofs, bool flip, bool track, const String& name)
{
int verts = a->vertices.size();
if (verts == 0) return NULL;
int tcs = a->texcoords[0].size(); //-
int norms = a->normals.size();
int faces = a->faces.size();
// norms = verts, verts % 3 == 0
ManualObject* m;
if (name == "")
m = sceneMgr->createManualObject();
else
m = sceneMgr->createManualObject(name);
m->begin(mat, RenderOperation::OT_TRIANGLE_LIST);
int t = 0;
if (track)
{ for (int v = 0; v < verts; v += 3)
{
m->position(a->vertices[v+0], a->vertices[v+2], -a->vertices[v+1]);
if (norms)
m->normal( a->normals [v+0], a->normals [v+2], -a->normals [v+1]);
if (t < tcs)
{ m->textureCoord(a->texcoords[0][t], a->texcoords[0][t+1]); t += 2; }
}
for (int f = 0; f < faces; ++f)
m->index(a->faces[f]);
}else
if (flip)
{ for (int v = 0; v < verts; v += 3)
{
m->position(a->vertices[v], a->vertices[v+1], a->vertices[v+2]);
if (norms)
m->normal( a->normals [v], a->normals [v+1], a->normals [v+2]);
if (t < tcs)
{ m->textureCoord(a->texcoords[0][t], a->texcoords[0][t+1]); t += 2; }
}
for (int f = 0; f < faces; f += 3)
{ m->index(a->faces[f+2]); m->index(a->faces[f+1]); m->index(a->faces[f]); }
}else
{ for (int v = 0; v < verts; v += 3)
{
m->position(-a->vertices[v+1]+vPofs.x, -a->vertices[v+2]+vPofs.y, a->vertices[v]+vPofs.z);
if (norms)
m->normal( -a->normals [v+1], -a->normals [v+2], a->normals [v]);
if (t < tcs)
{ m->textureCoord(a->texcoords[0][t], a->texcoords[0][t+1]); t += 2; }
}
for (int f = 0; f < faces; f += 3)
{ m->index(a->faces[f+2]); m->index(a->faces[f+1]); m->index(a->faces[f]); }
}
m->end();
return m;
}
示例7: material_index
//---------------------------------------------------------------------
void
PFile::addGroup( const Group &group, ManualObject &mo
,const String &sub_name, const String &material_base_name
,const Ogre::Bone *bone ) const
{
size_t material_index( 0 );
if( group.has_texture )
{
material_index = group.texture_index + 1;
}
String material_name( material_base_name + "/" + Ogre::StringConverter::toString( material_index ) );
const uint16 bone_handle( bone->getHandle() );
const Ogre::Vector3 bone_position( getPosition( bone ) );
size_t index( 0 );
size_t vertex_count( group.num_polygons * 3 );
size_t index_count( vertex_count );
size_t polygon_end_index( group.polygon_start_index + group.num_polygons );
mo.begin( sub_name, material_name, vertex_count, index_count );
for( size_t p( group.polygon_start_index ); p < polygon_end_index; ++p )
{
const PolygonDefinition& polygon( m_polygon_definitions[p] );
for( int i(3); i--; )
{
uint32 v( group.vertex_start_index
+polygon.vertex[i] )
,n( 0 + polygon.normal[i] )
,t( group.texture_coordinate_start_index
+polygon.vertex[i] );
Ogre::Vector3 pos( m_vertices[ v ] );
mo.position((STATIC_ROTATION * (pos / HRCFile::kDownScaler)) + bone_position);
mo.colour( m_vertex_colors[ v ] );
mo.normal( STATIC_ROTATION * m_normals[ n ] );
if( group.has_texture )
{
mo.textureCoord(m_texture_coordinates[t]);
}
mo.bone( index, bone_handle );
mo.index( index++ );
}
}
mo.end();
}
示例8: 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());
}
示例9: CreateRoadBezier
void App::CreateRoadBezier()
{
ManualObject* m = mSceneMgr->createManualObject();
//m->begin("pipeGlass", RenderOperation::OT_TRIANGLE_LIST);
m->begin("roadAsphalt", RenderOperation::OT_TRIANGLE_LIST);
int ii=0;
#ifdef SR_EDITOR
const std::list <ROADSTRIP>& roads = track->GetRoadList();
#else
const std::list <ROADSTRIP>& roads = pGame->track.GetRoadList();
#endif
for (std::list <ROADSTRIP>::const_iterator it = roads.begin(); it != roads.end(); ++it)
{
#define VDR_LEN // to get whole track length
#ifdef VDR_LEN
MATHVECTOR<float,3> vec0; float length = 0.f;
#endif
const std::list <ROADPATCH>& pats = (*it).GetPatchList();
for (std::list <ROADPATCH>::const_iterator i = pats.begin(); i != pats.end(); ++i)
{
float p[16][3]; int a=0;
for (int y=0; y<4; ++y)
for (int x=0; x<4; ++x)
{
const MATHVECTOR<float,3>& vec = (*i).GetPatch().GetPoint(x,y);
p[a][0] = vec[2]; p[a][1] = vec[1] + 0.2f/*ofs up*/; p[a][2] = -vec[0]; a++;
#ifdef VDR_LEN
if (x==1 && y==1 /*&& it == roads.begin()*/) //main only-
{
if (i != pats.begin()) // sum distance
length += (vec0-vec).Magnitude();
vec0 = vec;
//LogO(fToStr(length,2,6));
}
#endif
}
a=0;
// normal
Vector3 pos (p[a ][0], p[a ][1], p[a ][2]);
Vector3 posX(p[a+3][0], p[a+3][1], p[a+3][2]); posX-=pos; posX.normalise();
Vector3 posY(p[a+12][0],p[a+12][1],p[a+12][2]); posY-=pos; posY.normalise();
Vector3 norm = posX.crossProduct(posY); norm.normalise();/**/
for (int y=0; y<4; ++y)
for (int x=0; x<4; ++x)
{
Vector3 pos(p[a][0], p[a][1], p[a][2]); a++;
m->position(pos);
m->normal(norm);/**/
m->textureCoord(y/3.f,x/3.f);
if (x<3 && y<3)
{
int a = ii+x+y*4;
m->index(a); m->index(a+1); m->index(a+4);
m->index(a+5); m->index(a+4); m->index(a+1);
}
}
ii += 16;
}
#ifdef VDR_LEN
LogO("VDR TRK: " + pSet->gui.track +" LEN: "+fToStr(length,2,6));
#endif
}
m->end();
AxisAlignedBox aabInf; aabInf.setInfinite();
m->setBoundingBox(aabInf); // always visible
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(m);
}
示例10: CreateVdrMinimap
ManualObject* CHud::CreateVdrMinimap()
{
asp = float(app->mWindow->getWidth())/float(app->mWindow->getHeight());
// get track sizes
minX=FLT_MAX; maxX=FLT_MIN; minY=FLT_MAX; maxY=FLT_MIN;
const std::list <ROADSTRIP>& roads = app->pGame->track.GetRoadList();
for (std::list <ROADSTRIP>::const_iterator it = roads.begin(); it != roads.end(); ++it)
{
const std::list <ROADPATCH>& pats = (*it).GetPatchList();
for (std::list <ROADPATCH>::const_iterator i = pats.begin(); i != pats.end(); ++i)
{
for (int iy=0; iy<4; ++iy)
for (int ix=0; ix<4; ++ix)
{
const MATHVECTOR<float,3>& vec = (*i).GetPatch().GetPoint(ix,iy);
Real x = vec[0], y = vec[2];
if (x < minX) minX = x; if (x > maxX) maxX = x;
if (y < minY) minY = y; if (y > maxY) maxY = y;
}
}
}
float fMapSizeX = maxX - minX, fMapSizeY = maxY - minY; // map size
float size = std::max(fMapSizeX, fMapSizeY);
scX = 1.f / size; scY = 1.f / size;
ManualObject* m = app->mSceneMgr->createManualObject();
m->begin("hud/Minimap", RenderOperation::OT_TRIANGLE_LIST);
int ii = 0;
for (std::list <ROADSTRIP>::const_iterator it = roads.begin(); it != roads.end(); ++it)
{
const std::list <ROADPATCH>& pats = (*it).GetPatchList();
for (std::list <ROADPATCH>::const_iterator i = pats.begin(); i != pats.end(); ++i)
{
float p[16][3]; int a=0;
for (int y=0; y<4; ++y)
for (int x=0; x<4; ++x)
{
const MATHVECTOR<float,3>& vec = (*i).GetPatch().GetPoint(x,y);
p[a][0] = vec[0]; p[a][1] = vec[2]; p[a][2] = vec[1]; a++;
}
a = 0;
// normal
Vector3 pos (p[a ][2], -p[a ][0], p[a ][1]);
Vector3 posX(p[a+3][2], -p[a+3][0], p[a+3][1]); posX-=pos; posX.normalise();
Vector3 posY(p[a+12][2],-p[a+12][0],p[a+12][1]); posY-=pos; posY.normalise();
Vector3 norm = posX.crossProduct(posY); norm.normalise();/**/
for (int y=0; y<4; ++y)
for (int x=0; x<4; ++x)
{
Vector3 pos( (p[a][0] - minX)*scX*2-1, // pos x,y = -1..1
-(p[a][1] - minY)*scY*2+1, 0); a++;
m->position(pos);
m->normal(norm);/**/
Real c = std::min(1.f, std::max(0.3f, 1.f - 2.4f * powf( fabs(norm.y)
/*norm.absDotProduct(vLi)*/, 0.7f) ));
m->colour(ColourValue(c,c,c,1));
m->textureCoord(x/3.f,y/3.f);
if (x<3 && y<3)
{
int a = ii+x+y*4;
m->index(a+0); m->index(a+1); m->index(a+4);
m->index(a+1); m->index(a+4); m->index(a+5);
}
}
ii += 16;
}
}
m->end();
m->setUseIdentityProjection(true); m->setUseIdentityView(true); // on hud
m->setCastShadows(false);
AxisAlignedBox aab; aab.setInfinite(); m->setBoundingBox(aab); // draw always
m->setRenderingDistance(100000.f);
m->setRenderQueueGroup(RQG_Hud2); m->setVisibilityFlags(RV_Hud);
return m;
}