本文整理汇总了C++中ManualObject::normal方法的典型用法代码示例。如果您正苦于以下问题:C++ ManualObject::normal方法的具体用法?C++ ManualObject::normal怎么用?C++ ManualObject::normal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ManualObject
的用法示例。
在下文中一共展示了ManualObject::normal方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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();
}
示例4: 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());
}
示例5: createCubeMesh
// make a cube, no cube primiatives in ogre
// yanked from betajaen
//http://www.ogre3d.org/forums/viewtopic.php?p=301318&sid=ce193664e1d3d7c4af509e6f4e2718c6
ManualObject* createCubeMesh(Ogre::String name, Ogre::String matName) {
ManualObject* cube = new ManualObject(name);
cube->begin(matName);
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->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,1.0);
cube->normal(-0.666667,-0.333333,0.666667);
cube->textureCoord(0,1);
cube->position(0.5,-0.5,1.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(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: 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);
}
示例7: 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;
}
示例8: createCubeMesh
void OgreDisplay::createCubeMesh(std::string name, std::string material)
{
//make a cube mesh
ManualObject* cubeMesh = sceneMgr->createManualObject("cube");
cubeMesh->begin(material, RenderOperation::OT_TRIANGLE_LIST);
cubeMesh->position(-0.5, -0.5, -0.5); //0
cubeMesh->normal(0,-1,0);
cubeMesh->textureCoord(0,0);
cubeMesh->position(-0.5, -0.5, 0.5); //1
cubeMesh->normal(0,-1,0);
cubeMesh->textureCoord(0,1);
cubeMesh->position(0.5, -0.5, 0.5); //2
cubeMesh->normal(0,-1,0);
cubeMesh->textureCoord(1,1);
cubeMesh->position(0.5, -0.5, -0.5); //3
cubeMesh->normal(0,-1,0);
cubeMesh->textureCoord(1,0);
cubeMesh->position(-0.5, 0.5, -0.5); //4
cubeMesh->normal(0,1,0);
cubeMesh->textureCoord(0,0);
cubeMesh->position(-0.5, 0.5, 0.5); //5
cubeMesh->normal(0,1,0);
cubeMesh->textureCoord(0,1);
cubeMesh->position(0.5, 0.5, 0.5); //6
cubeMesh->normal(0,1,0);
cubeMesh->textureCoord(1,1);
cubeMesh->position(0.5, 0.5, -0.5); //7
cubeMesh->normal(0,1,0);
cubeMesh->textureCoord(1,0);
cubeMesh->position(-0.5, -0.5, -0.5); //8
cubeMesh->normal(0,0,-1);
cubeMesh->textureCoord(0,0);
cubeMesh->position(-0.5, -0.5, 0.5); //9
cubeMesh->normal(0,0,1);
cubeMesh->textureCoord(0,0);
cubeMesh->position(0.5, -0.5, 0.5); //10
cubeMesh->normal(0,0,1);
cubeMesh->textureCoord(1,0);
cubeMesh->position(0.5, -0.5, -0.5); //11
cubeMesh->normal(0,0,-1);
cubeMesh->textureCoord(1,0);
cubeMesh->position(-0.5, 0.5, -0.5); //12
cubeMesh->normal(0,0,-1);
cubeMesh->textureCoord(0,1);
cubeMesh->position(-0.5, 0.5, 0.5); //13
cubeMesh->normal(0,0,1);
cubeMesh->textureCoord(0,1);
cubeMesh->position(0.5, 0.5, 0.5); //14
cubeMesh->normal(0,0,1);
cubeMesh->textureCoord(1,1);
cubeMesh->position(0.5, 0.5, -0.5); //15
cubeMesh->normal(0,0,-1);
cubeMesh->textureCoord(1,1);
cubeMesh->position(-0.5, -0.5, -0.5); //16
cubeMesh->normal(-1,0,0);
cubeMesh->textureCoord(0,0);
cubeMesh->position(-0.5, -0.5, 0.5); //17
cubeMesh->normal(-1,0,0);
cubeMesh->textureCoord(0,1);
cubeMesh->position(0.5, -0.5, 0.5); //18
cubeMesh->normal(1,0,0);
cubeMesh->textureCoord(0,1);
cubeMesh->position(0.5, -0.5, -0.5); //19
cubeMesh->normal(1,0,0);
cubeMesh->textureCoord(0,0);
cubeMesh->position(-0.5, 0.5, -0.5); //20
cubeMesh->normal(-1,0,0);
cubeMesh->textureCoord(1,0);
cubeMesh->position(-0.5, 0.5, 0.5); //21
cubeMesh->normal(-1,0,0);
cubeMesh->textureCoord(1,1);
cubeMesh->position(0.5, 0.5, 0.5); //22
cubeMesh->normal(1,0,0);
cubeMesh->textureCoord(1,1);
cubeMesh->position(0.5, 0.5, -0.5); //23
cubeMesh->normal(1,0,0);
cubeMesh->textureCoord(1,0);
//bottom
cubeMesh->quad(3,2,1,0);
//top
cubeMesh->quad(4,5,6,7);
//front
cubeMesh->quad(10,14,13,9);
//back
cubeMesh->quad(8,12,15,11);
//left
cubeMesh->quad(16,17,21,20);
//right
cubeMesh->quad(23,22,18,19);
cubeMesh->end();
cubeMesh->convertToMesh(name);
}