本文整理汇总了C++中ManualObject::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ ManualObject::begin方法的具体用法?C++ ManualObject::begin怎么用?C++ ManualObject::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ManualObject
的用法示例。
在下文中一共展示了ManualObject::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createGrid
// 创建网格
ManualObject* AxisGridPlugin::createGrid(float width , float height , float interval)
{
// 创建网格对象
static size_t s_index = 0;
ManualObject *gridObject = m_worldEditor->getDisplaySystem()->getMainSceneMgr()->createManualObject(
"GridObject" + StringConverter::toString(s_index));
// 用黑色画中间线
gridObject->begin(m_worldEditor->getDisplaySystem()->getColorMaterial(ColourValue::Black) , RenderOperation::OT_LINE_LIST);
gridObject->position(-width , 0 , 0);
gridObject->position(width , 0 , 0);
gridObject->position(0 , 0 , -height);
gridObject->position(0 , 0 , height);
gridObject->end();
// 画普通线
gridObject->begin(m_worldEditor->getDisplaySystem()->getColorMaterial(ColourValue(0.37,0.37,0.37)) , RenderOperation::OT_LINE_LIST);
for(float x = -width ; x <= width ; x += interval)
{
if(abs(x) > 0.0001f)
{
gridObject->position(x , 0 , -height);
gridObject->position(x , 0 , height);
}
}
for(float y = -height ; y <= height ; y += interval)
{
if(abs(y) > 0.0001f)
{
gridObject->position(-width , 0 , y);
gridObject->position(width , 0 , y);
}
}
gridObject->end();
return gridObject;
}
示例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: 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
}
示例4: 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);
}
示例5: createScene
//-------------------------------------------------------------------------------------
void HelloOGRE::createScene(void)
{
using namespace Ogre;
Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "7.mesh");
//Ogre::Entity* cube = mSceneMgr->createEntity("cube","abc.mesh");
Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("Head");
headNode->attachObject(ogreHead);
ManualObject * axis = mSceneMgr->createManualObject("Axis");
axis->begin("line",Ogre::RenderOperation::OperationType::OT_LINE_LIST);
axis->position(0.0f,0.0f,0.0f);
axis->position(20.0f,0.0f,0.0f);
axis->end();
headNode->attachObject(axis);
// Set ambient light
mSceneMgr->setAmbientLight(Ogre::ColourValue(1.0,0.5, 0.0));
mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
mSceneMgr->setSkyDome(true,"Examples/Rockwall");
//mSceneMgr->setSkyPlane(true,"Example/"
// Create a light
Ogre::Light* l = mSceneMgr->createLight("MainLight");
l->setDiffuseColour(0.0f,1.0f,0.0f);
l->setPosition(20,80,50);
l->setDirection(0.0,0.0,0.0);
}
示例6:
// util
//---------------------------------------------------------------------------------------------------------------
ManualObject* App::Create2D(const String& mat, Real s, bool dyn)
{
ManualObject* m = mSceneMgr->createManualObject();
m->setDynamic(dyn);
m->setUseIdentityProjection(true);
m->setUseIdentityView(true);
m->setCastShadows(false);
m->estimateVertexCount(4);
m->begin(mat, RenderOperation::OT_TRIANGLE_STRIP);
m->position(-s,-s*asp, 0); m->textureCoord(0, 1);
m->position( s,-s*asp, 0); m->textureCoord(1, 1);
m->position(-s, s*asp, 0); m->textureCoord(0, 0);
m->position( s, s*asp, 0); m->textureCoord(1, 0);
m->end();
//TODO:replace OT_TRIANGLE_FAN with a more friendly version for D3D11 as it is not supported
/*
m->estimateVertexCount(6);
m->begin(mat, RenderOperation::OT_TRIANGLE_LIST);
m->position(-s,-s*asp, 0); m->textureCoord(0, 1);
m->position( s,-s*asp, 0); m->textureCoord(1, 1);
m->position( s, s*asp, 0); m->textureCoord(1, 0);
m->position(-s, s*asp, 0); m->textureCoord(0, 0);
m->position(-s,-s*asp, 0); m->textureCoord(0, 1);
m->position( s, s*asp, 0); m->textureCoord(1, 0);
m->end();
*/
AxisAlignedBox aabInf; aabInf.setInfinite();
m->setBoundingBox(aabInf); // always visible
m->setRenderQueueGroup(RQG_Hud2);
return m;
}
示例7: 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");
}
示例8: drawBox
void BoxPrimitive::drawBox()
{
ManualObject* manualObject = getManualObject();
manualObject->clear();
std::vector<Vector3> corners;
corners.reserve(8);
Vector3 vmin = mSize.getMinimum();
Vector3 vmax = mSize.getMaximum();
manualObject->begin(mMaterialName);
manualObject->position(vmin); // 0
manualObject->position(Vector3(vmax.x, vmin.y, vmin.z)); // 1
manualObject->position(Vector3(vmax.x, vmax.y, vmin.z)); // 2
manualObject->position(Vector3(vmin.x, vmax.y, vmin.z)); // 3
manualObject->position(Vector3(vmax.x, vmin.y, vmax.z)); // 4
manualObject->position(Vector3(vmin.x, vmin.y, vmax.z)); // 5
manualObject->position(Vector3(vmin.x, vmax.y, vmax.z)); // 6
manualObject->position(vmax); // 7
manualObject->quad(0, 3, 2, 1);
manualObject->quad(0, 5, 6, 3);
manualObject->quad(0, 1, 4, 5);
manualObject->quad(7, 2, 3, 6);
manualObject->quad(7, 4, 1, 2);
manualObject->quad(7, 6, 5, 4);
manualObject->end();
}
示例9: 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;
}
示例10: 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;
}
示例11: drawCube
void DebugDisplay::drawCube( AxisAlignedBox bbox )
{
oht_assert_threadmodel(ThrMdl_Main);
ManualObject * pManObj = _pSceneManager->createManualObject();
rollbackTransforms(bbox);
pManObj->begin(getCurrentMaterial(), RenderOperation::OT_LINE_LIST);
const Vector3
m0 = bbox.getMinimum(),
mN = bbox.getMaximum();
pManObj->position(m0.x, m0.y, m0.z);
pManObj->position(mN.x, m0.y, m0.z);
pManObj->position(m0.x, m0.y, m0.z);
pManObj->position(m0.x, mN.y, m0.z);
pManObj->position(m0.x, m0.y, m0.z);
pManObj->position(m0.x, m0.y, mN.z);
pManObj->position(mN.x, mN.y, m0.z);
pManObj->position(mN.x, m0.y, m0.z);
pManObj->position(mN.x, mN.y, m0.z);
pManObj->position(m0.x, mN.y, m0.z);
pManObj->position(mN.x, mN.y, m0.z);
pManObj->position(mN.x, mN.y, mN.z);
pManObj->position(m0.x, mN.y, mN.z);
pManObj->position(m0.x, mN.y, m0.z);
pManObj->position(m0.x, mN.y, mN.z);
pManObj->position(m0.x, m0.y, mN.z);
pManObj->position(m0.x, mN.y, mN.z);
pManObj->position(mN.x, mN.y, mN.z);
pManObj->position(mN.x, m0.y, mN.z);
pManObj->position(m0.x, m0.y, mN.z);
pManObj->position(mN.x, m0.y, mN.z);
pManObj->position(mN.x, m0.y, m0.z);
pManObj->position(mN.x, m0.y, mN.z);
pManObj->position(mN.x, mN.y, mN.z);
pManObj->end();
_pScNode->attachObject(pManObj);
}
示例12: createDebugNormals
ManualObject* SnowTerrain::createDebugNormals(Ogre::SceneManager* mSceneMgr)
{
ManualObject* manual = mSceneMgr->createManualObject("NormalsDebug");
float *heights = getTerrainHeightData();
Vector4 *normals = getTerrainNormalData();
manual->begin("BaseWhiteNoLighting", RenderOperation::OT_LINE_LIST);
int terrainSize = getTerrain()->getSize();
int terrainWorldSize = getTerrain()->getWorldSize();
for(int z = 0; z < terrainSize; ++z)
{
for(int x = 0; x < terrainSize; ++x)
{
int i = ((terrainSize)*(terrainSize) ) - (z+1)*terrainSize + (x+1);
Vector3 n = Vector3(normals[i].x, normals[i].y, normals[i].z);
float h = heights[i];
Real factor = (Real)terrainSize - 1.0f;
Real invFactor = 1.0f / factor;
float mScale = terrainWorldSize / (Real)(terrainSize);
Real mBase = -terrainWorldSize * 0.5;
Vector3 mPos = Ogre::Vector3(terrainWorldSize * 0.5, 0, terrainWorldSize * 0.5);
Vector3 worldPos;
worldPos.x = x * mScale + mBase + mPos.x;
worldPos.y = h + mPos.y;
worldPos.z = z * mScale + mBase + mPos.z;
// convert back to "normal map" colors (0/1 float instead of -1/1 float, also rgb=>xzy)
manual->colour((n.x + 1)*0.5, (n.z + 1)*0.5, (n.y + 1)*0.5);
// draw line
manual->position(worldPos);
manual->position(worldPos + 3*n);
//manual->index(i);
//manual->index(1);
}
}
manual->end();
//OGRE_FREE(normals);
return manual;
}
示例13: 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);
}
示例14: drawPoint
void DebugDisplay::drawPoint( Vector3 p )
{
oht_assert_threadmodel(ThrMdl_Main);
ManualObject * pManObj = _pSceneManager->createManualObject();
rollbackTransforms(p);
pManObj->begin(getCurrentMaterial(), RenderOperation::OT_POINT_LIST);
pManObj->position(p);
pManObj->end();
_pScNode->attachObject(pManObj);
}
示例15: 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);
}