本文整理汇总了C++中ManualObject::position方法的典型用法代码示例。如果您正苦于以下问题:C++ ManualObject::position方法的具体用法?C++ ManualObject::position怎么用?C++ ManualObject::position使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ManualObject
的用法示例。
在下文中一共展示了ManualObject::position方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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);
}
示例3:
// 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;
}
示例4: 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;
}
示例5: 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
}
示例6: 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;
}
示例7: 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);
}
示例8: 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;
}
示例9: 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;
}
示例10: dibujaLinea
void pathDrawerState::dibujaLinea(size_t idFrom, size_t idTo)
{
ManualObject* manual = _sceneMgr->createManualObject("line_" + to_string(idFrom));
manual->begin("BaseWhiteNoLighting", RenderOperation::OT_LINE_LIST);
Vector3 aux(vMarcas[idFrom]._nodoMarca->getPosition());
aux.y = _planeRoadNode->getPosition().y + 1;
manual->position(aux); //start
aux = vMarcas[idTo]._nodoMarca->getPosition();
aux.y = _planeRoadNode->getPosition().y + 1;
manual->position(aux); //end
manual->end();
_sceneMgr->getRootSceneNode()->attachObject(manual);
cout << "nombre entity linea: " << manual->getName() << endl;
}
示例11: 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);
}
示例12: 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 );
}
示例13: 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");
}
示例14: createQuad
void VideoManager::createQuad(String name,String material_name,float left,float top,float right,float bottom)
{
ManualObject* model = OgreManager::getSingleton().getSceneManager()->createManualObject(name);
model->begin(material_name);
model->position(right,bottom,0); model->textureCoord(1,1);
model->position(right,top ,0); model->textureCoord(1,0);
model->position(left ,top ,0); model->textureCoord(0,0);
model->position(left ,top ,0); model->textureCoord(0,0);
model->position(right,bottom,0); model->textureCoord(1,1);
model->position(left, bottom,0); model->textureCoord(0,1);
model->end();
// make the model 2D
model->setUseIdentityProjection(true);
model->setUseIdentityView(true);
// and atach it to the root node
SceneNode* node = OgreManager::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode();
node->attachObject(model);
}
示例15: drawTriangle
void DebugDisplay::drawTriangle( Vector3 t0, Vector3 t1, Vector3 t2 )
{
oht_assert_threadmodel(ThrMdl_Main);
ManualObject * pManObj = _pSceneManager->createManualObject();
rollbackTransforms(t0);
rollbackTransforms(t1);
rollbackTransforms(t2);
pManObj->begin(getCurrentMaterial(), RenderOperation::OT_TRIANGLE_LIST);
pManObj->position(t0);
pManObj->position(t1);
pManObj->position(t2);
pManObj->end();
_pScNode->attachObject(pManObj);
}