本文整理汇总了C++中ogre::ManualObject::convertToMesh方法的典型用法代码示例。如果您正苦于以下问题:C++ ManualObject::convertToMesh方法的具体用法?C++ ManualObject::convertToMesh怎么用?C++ ManualObject::convertToMesh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::ManualObject
的用法示例。
在下文中一共展示了ManualObject::convertToMesh方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createCubeMesh
//-------------------------------------------------------------------------------------
void BasicTutorial2::createScene(void)
{
mSceneMgr->setAmbientLight(Ogre::ColourValue(0, 0, 0));
//mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
//Create cube
//Create a basic green color texture
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create("BoxColor", "General", true );
Ogre::Technique* tech = mat->getTechnique(0);
Ogre::Pass* pass = tech->getPass(0);
Ogre::TextureUnitState* tex = pass->createTextureUnitState();
tex->setTextureName("grassTexture.png");
//tex->setNumMipmaps(4);
tex->setTextureAnisotropy(1);
tex->setTextureFiltering(Ogre::FO_POINT, Ogre::FO_POINT, Ogre::FO_POINT);
//Create the one box and the supporting class objects
Ogre::ManualObject* testBox = createCubeMesh("TestBox1", "BoxColor");
Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
Ogre::MeshPtr Mesh = testBox->convertToMesh("TestBox2");
Ogre::StaticGeometry* pGeom = new Ogre::StaticGeometry (mSceneMgr, "Boxes");
Ogre::Entity* pEnt = mSceneMgr->createEntity("TestBox2");
//testBox->triangle
pGeom->setRegionDimensions(Ogre::Vector3(300, 300, 300));
World::Instance();
pGeom->build ();
mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
Ogre::Light* l = mSceneMgr->createLight("MainLight");
l->setPosition(20,80,50);
//Create Cube
/* Ogre::Entity* entNinja = mSceneMgr->createEntity("Ninja", "ninja.mesh");
entNinja->setCastShadows(true);
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entNinja);*/
Ogre::Light* directionalLight = mSceneMgr->createLight("directionalLight");
directionalLight->setType(Ogre::Light::LT_DIRECTIONAL);
directionalLight->setDiffuseColour(Ogre::ColourValue(.25, .25, 0));
directionalLight->setSpecularColour(Ogre::ColourValue(.25, .25, 0));
directionalLight->setDirection(Ogre::Vector3( 0, -1, 1 ));
}
示例2: realizeMesh
Ogre::MeshPtr MultiShape::realizeMesh(const std::string& name)
{
Ogre::ManualObject * manual = Root::getInstance()->sceneManager->createManualObject(name);
for (std::vector<Shape>::iterator it = shapes.begin(); it!=shapes.end(); it++)
{
manual->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_STRIP);
it->_appendToManualObject(manual);
manual->end();
}
Ogre::MeshPtr mesh = manual->convertToMesh(name);
return mesh;
}
示例3: CreateImplosionParticleGeometry
void ParticleFactory::CreateImplosionParticleGeometry(Ogre::String object_name, int num_particles){
Ogre::SceneNode* root_scene_node = scene_manager->getRootSceneNode();
/* Create the 3D object */
Ogre::ManualObject* object = NULL;
object = scene_manager->createManualObject(object_name);
object->setDynamic(false);
/* Create point list for the object */
object->begin("", Ogre::RenderOperation::OT_POINT_LIST);
/* Initialize random numbers */
std::srand(std::time(0));
/* Create a set of points which will be the particles */
/* This is similar to drawing a sphere: we will sample points on a sphere, but will allow them to also
deviate a bit from the sphere along the normal (change of radius) */
float trad = 1.4; // Defines the starting point of the particles
float maxspray = 1.5; // This is how much we allow the points to deviate from the sphere
float u, v, w, theta, phi, spray; // Work variables
for (int i = 0; i < num_particles; i++){
// Randomly select three numbers to define a point in spherical coordinates
u = ((double) rand() / (RAND_MAX));
v = ((double) rand() / (RAND_MAX));
w = ((double) rand() / (RAND_MAX));
// Use u to define the angle theta along one direction of a sphere
theta = u * 2.0 * 3.1416;
// Use v to define the angle phi along the other direction of the sphere
phi = acos(2.0*v - 1.0);
// Use we to define how much we can deviate from the surface of the sphere (change of radius)
spray = maxspray*pow((float) w, (float) (1.0/3.0)); // Cubic root of w
// Define the normal and point based on theta, phi and the spray
Ogre::Vector3 normal = Ogre::Vector3(spray*cos(theta)*sin(phi), spray*sin(theta)*sin(phi), spray*cos(phi));
object->position(normal.x*trad, normal.y*trad, normal.z*trad);
object->normal(normal);
object->colour(Ogre::ColourValue(i/(float) num_particles, 0.0, 1.0 - (i/(float) num_particles))); // We can use the color for debug, if needed
}
/* We finished the object */
object->end();
/* Convert triangle list to a mesh */
object->convertToMesh(object_name);
}
示例4: addTerrainDecal
int DecalManager::addTerrainDecal(Ogre::Vector3 position, Ogre::Vector2 size, Ogre::Vector2 numSeg, Ogre::Real rotation, Ogre::String materialname, Ogre::String normalname)
{
#if 0
Ogre::ManualObject *mo = gEnv->ogreSceneManager->createManualObject();
String oname = mo->getName();
SceneNode *mo_node = terrain_decals_snode->createChildSceneNode();
mo->begin(materialname, Ogre::RenderOperation::OT_TRIANGLE_LIST);
AxisAlignedBox *aab=new AxisAlignedBox();
float uTile = 1, vTile = 1;
Vector3 normal = Vector3(0,1,0); // UP
int offset = 0;
float ground_dist = 0.001f;
Ogre::Vector3 vX = normal.perpendicular();
Ogre::Vector3 vY = normal.crossProduct(vX);
Ogre::Vector3 delta1 = size.x / numSeg.x * vX;
Ogre::Vector3 delta2 = size.y / numSeg.y * vY;
// build one corner of the square
Ogre::Vector3 orig = -0.5*size.x*vX - 0.5*size.y*vY;
for (int i1 = 0; i1<=numSeg.x; i1++)
for (int i2 = 0; i2<=numSeg.y; i2++)
{
Vector3 pos = orig+i1*delta1+i2*delta2 + position;
pos.y = hfinder->getHeightAt(pos.x, pos.z) + ground_dist;
mo->position(pos);
aab->merge(pos);
mo->textureCoord(i1/(Ogre::Real)numSeg.x*uTile, i2/(Ogre::Real)numSeg.y*vTile);
mo->normal(normal);
}
bool reverse = false;
if (delta1.crossProduct(delta2).dotProduct(normal)>0)
reverse= true;
for (int n1 = 0; n1<numSeg.x; n1++)
{
for (int n2 = 0; n2<numSeg.y; n2++)
{
if (reverse)
{
mo->index(offset+0);
mo->index(offset+(numSeg.y+1));
mo->index(offset+1);
mo->index(offset+1);
mo->index(offset+(numSeg.y+1));
mo->index(offset+(numSeg.y+1)+1);
}
else
{
mo->index(offset+0);
mo->index(offset+1);
mo->index(offset+(numSeg.y+1));
mo->index(offset+1);
mo->index(offset+(numSeg.y+1)+1);
mo->index(offset+(numSeg.y+1));
}
offset++;
}
offset++;
}
offset+=numSeg.y+1;
mo->end();
mo->setBoundingBox(*aab);
// some optimizations
mo->setCastShadows(false);
mo->setDynamic(false);
delete(aab);
MeshPtr mesh = mo->convertToMesh(oname+"_mesh");
// build edgelist
mesh->buildEdgeList();
// remove the manualobject again, since we dont need it anymore
gEnv->ogreSceneManager->destroyManualObject(mo);
unsigned short src, dest;
if (!mesh->suggestTangentVectorBuildParams(VES_TANGENT, src, dest))
{
mesh->buildTangentVectors(VES_TANGENT, src, dest);
}
Entity *ent = gEnv->ogreSceneManager->createEntity(oname+"_ent", oname+"_mesh");
mo_node->attachObject(ent);
mo_node->setVisible(true);
//mo_node->showBoundingBox(true);
mo_node->setPosition(Vector3::ZERO); //(position.x, 0, position.z));
// RTSS
//Ogre::RTShader::ShaderGenerator::getSingleton().createShaderBasedTechnique(materialname, Ogre::MaterialManager::DEFAULT_SCHEME_NAME, Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
//Ogre::RTShader::ShaderGenerator::getSingleton().invalidateMaterial(RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME, materialname);
RTSSgenerateShadersForMaterial(materialname, normalname);
#endif
//.........这里部分代码省略.........
示例5: addTerrainSplineDecal
int DecalManager::addTerrainSplineDecal(Ogre::SimpleSpline *spline, float width, Ogre::Vector2 numSeg, Ogre::Vector2 uvSeg, Ogre::String materialname, float ground_offset, Ogre::String export_fn, bool debug)
{
#if 0
Ogre::ManualObject *mo = gEnv->ogreSceneManager->createManualObject();
String oname = mo->getName();
SceneNode *mo_node = terrain_decals_snode->createChildSceneNode();
mo->begin(materialname, Ogre::RenderOperation::OT_TRIANGLE_LIST);
AxisAlignedBox *aab=new AxisAlignedBox();
int offset = 0;
// how width is the road?
float delta_width = width / numSeg.x;
float steps_len = 1.0f / numSeg.x;
for (int l = 0; l<=numSeg.x; l++)
{
// get current position on that spline
Vector3 pos_cur = spline->interpolate(steps_len * (float)l);
Vector3 pos_next = spline->interpolate(steps_len * (float)(l + 1));
Ogre::Vector3 direction = (pos_next - pos_cur);
if (l == numSeg.x)
{
// last segment uses previous position
pos_next = spline->interpolate(steps_len * (float)(l - 1));
direction = (pos_cur - pos_next);
}
for (int w = 0; w<=numSeg.y; w++)
{
// build vector for the width
Vector3 wn = direction.normalisedCopy().crossProduct(Vector3::UNIT_Y);
// calculate the offset, spline in the middle
Vector3 offset = (-0.5 * wn * width) + (w/numSeg.y) * wn * width;
// push everything together
Ogre::Vector3 pos = pos_cur + offset;
// get ground height there
pos.y = hfinder->getHeightAt(pos.x, pos.z) + ground_offset;
// add the position to the mesh
mo->position(pos);
aab->merge(pos);
mo->textureCoord(l/(Ogre::Real)numSeg.x*uvSeg.x, w/(Ogre::Real)numSeg.y*uvSeg.y);
mo->normal(Vector3::UNIT_Y);
}
}
bool reverse = false;
for (int n1 = 0; n1<numSeg.x; n1++)
{
for (int n2 = 0; n2<numSeg.y; n2++)
{
if (reverse)
{
mo->index(offset+0);
mo->index(offset+(numSeg.y+1));
mo->index(offset+1);
mo->index(offset+1);
mo->index(offset+(numSeg.y+1));
mo->index(offset+(numSeg.y+1)+1);
}
else
{
mo->index(offset+0);
mo->index(offset+1);
mo->index(offset+(numSeg.y+1));
mo->index(offset+1);
mo->index(offset+(numSeg.y+1)+1);
mo->index(offset+(numSeg.y+1));
}
offset++;
}
offset++;
}
offset+=numSeg.y+1;
mo->end();
mo->setBoundingBox(*aab);
// some optimizations
mo->setCastShadows(false);
mo->setDynamic(false);
delete(aab);
MeshPtr mesh = mo->convertToMesh(oname+"_mesh");
// build edgelist
mesh->buildEdgeList();
// remove the manualobject again, since we dont need it anymore
gEnv->ogreSceneManager->destroyManualObject(mo);
unsigned short src, dest;
if (!mesh->suggestTangentVectorBuildParams(VES_TANGENT, src, dest))
{
mesh->buildTangentVectors(VES_TANGENT, src, dest);
//.........这里部分代码省略.........
示例6: CreateThrusterParticleGeometry
void ParticleFactory::CreateThrusterParticleGeometry(Ogre::String object_name, int num_particles, float loop_radius, float circle_radius){
//try {
/* 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;
object = scene_manager->createManualObject(object_name);
object->setDynamic(false);
/*
/* Create point list for the object */
object->begin("", Ogre::RenderOperation::OT_POINT_LIST);
/* Initialize random numbers */
std::srand(std::time(0));
/* Create a set of points which will be the particles */
/* This is similar to drawing a torus: we will sample points on the surface of the torus */
float maxspray = 1.5; // This is how much we allow the points to wander around
float u, v, w, theta, phi, spray; // Work variables
for (int i = 0; i < num_particles; i++){
// Randomly select two numbers to define a point on the torus
u = ((double) rand() / (RAND_MAX));
v = ((double) rand() / (RAND_MAX));
// Use u and v to define the point on the torus
theta = u * Ogre::Math::TWO_PI;
phi = v * Ogre::Math::TWO_PI;
Ogre::Vector3 center = Ogre::Vector3(loop_radius*cos(theta), loop_radius*sin(theta), 0.0);
Ogre::Vector3 normal = Ogre::Vector3(cos(theta)*cos(phi), sin(theta)*cos(phi), sin(phi));
object->position(center + normal*circle_radius); // Position of the point
object->colour(Ogre::ColourValue(((float) i)/((float) num_particles), 0.0, 1.0 - (((float) i)/((float) num_particles))));
object->textureCoord(Ogre::Vector2(0.0, 0.0));
// Now sample a point on a sphere to define a direction for points to wander around
u = ((double) rand() / (RAND_MAX));
v = ((double) rand() / (RAND_MAX));
w = ((double) rand() / (RAND_MAX));
theta = u * Ogre::Math::TWO_PI;
phi = acos(2.0*v * -1.0);
spray = maxspray*pow((float) w, (float) (1.0/4.0)); // Cubic root
Ogre::Vector3 wander = Ogre::Vector3(spray*cos(theta)*cos(phi), spray*cos(theta)*sin(phi), sin(phi)*-2);
object->normal(wander);
}
object->position(Ogre::Vector3(0.0f, 0.0f, -30.0f));
object->colour(Ogre::ColourValue(0.0f, 0.0f, 0.0f));
object->textureCoord(Ogre::Vector2(0.0f, 0.0f));
object->normal(Ogre::Vector3(0.0f, 0.0f, -30.0f));
object->end();
/* Convert triangle list to a mesh */
object->convertToMesh(object_name);
/* }
catch (Ogre::Exception &e){
throw(OgreAppException(std::string("Ogre::Exception: ") + std::string(e.what())));
}
catch(std::exception &e){
throw(OgreAppException(std::string("std::Exception: ") + std::string(e.what())));
}*/
}
示例7: CreateSplineControlPoints
void ParticleFactory::CreateSplineControlPoints(Ogre::String control_points_name, int num_control_points, Ogre::String material_name){
// Control points for the spline
Ogre::Vector3 *control_point;
/* Allocate memory for control points */
control_point = new Ogre::Vector3[num_control_points];
/* Create control points of a piecewise spline */
/* We store the control points in groups of 4 */
/* Each group represents the control points (p0, p1, p2, p3) of a cubic Bezier curve */
/* To ensure C1 continuity, we constrain the first and second point of each curve according to the previous curve */
// Initialize the first two control points to fixed values */
control_point[0] = Ogre::Vector3(-20.0, 0.0, 0.0);
control_point[1] = Ogre::Vector3(20.0, 0.0, 0.0);
// Create remaining points
for (int i = 2; i < num_control_points; i++){
// Check if we have the first or second point of a curve
// Then we need to constrain the points
if (i % 4 == 0){
// Constrain the first point of the curve
// p3 = q0, where the previous curve is (p0, p1, p2, p3) and the current curve is (q0, q1, q2, q3)
// p3 is at position -1 from the current point q0
control_point[i] = control_point[i - 1];
} else if (i % 4 == 1){
// Constrain the second point of the curve
// q1 = 2*p3 – p2
// p3 is at position -1 and we add another -1 since we are at i%4 == 1 (not i%4 == 0)
// p2 is at position -2 and we add another -1 since we are at i%4 == 1 (not i%4 == 0)
control_point[i] = 2.0*control_point[i -2] - control_point[i - 3];
} else {
// Other points: we can freely assign random values to them
// Get 3 random numbers
float u, v, w;
//u = ((double) rand() / (RAND_MAX));
//v = ((double) rand() / (RAND_MAX));
//w = ((double) rand() / (RAND_MAX));
// Define control points based on u, v, and w and scale by the control point index
//control_point[i] = Ogre::Vector3(u*3.0*(i/4 + 1), v*3.0*(i/4+1), w*3.0*(i/4+1));
//control_point[i] = Ogre::Vector3(u*3.0*(i/4 + 1), v*3.0*(i/4+1), 0.0); // Easier to visualize with the control points on the screen
//x = cx + r * cos(a)
//y = cy + r * sin(a)
u = 20 * cos(Ogre::Math::RangeRandom(-25,25));
v = 20 * sin(Ogre::Math::RangeRandom(-50,50));
w = (Ogre::Math::RangeRandom(-15,15));
control_point[i] = Ogre::Vector3(u, w, v);
}
}
/* Add control points to the material's shader */
/* Translate the array of Ogre::Vector3 to an accepted format */
float *shader_data;
shader_data = new float[num_control_points*4];
for (int i = 0; i < num_control_points; i++){
shader_data[i*4] = control_point[i].x;
shader_data[i*4 + 1] = control_point[i].y;
shader_data[i*4 + 2] = control_point[i].z;
shader_data[i*4 + 3] = 0.0;
}
/* Add array as a parameter to the shader of the specified material */
Ogre::MaterialPtr mat = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName(material_name));
mat->getBestTechnique()->getPass(0)->getVertexProgramParameters()->setNamedConstant("control_point", shader_data, num_control_points, 4);
/* Also create a mesh out of the control points, so that we can render them, if needed */
Ogre::ManualObject* object = NULL;
object = scene_manager->createManualObject(control_points_name);
object->setDynamic(false);
object->begin("", Ogre::RenderOperation::OT_POINT_LIST);
for (int i = 0; i < num_control_points; i++){
object->position(control_point[i]);
// Color allows us to keep track of control point ordering
object->colour(1.0 - ((float) i)/((float)num_control_points), 0.0, ((float) i)/((float)num_control_points));
}
object->end();
object->convertToMesh(control_points_name);
/* Free memory we used to store control points temporarily */
delete [] control_point;
}
示例8: CreateSplineParticleGeometry
void ParticleFactory::CreateSplineParticleGeometry(Ogre::String object_name, int num_particles, float loop_radius, float circle_radius){
/* Retrieve scene manager and root scene node */
Ogre::SceneNode* root_scene_node = scene_manager->getRootSceneNode();
/* Create the 3D object */
Ogre::ManualObject* object = NULL;
object = scene_manager->createManualObject(object_name);
object->setDynamic(false);
/* Create point list for the object */
object->begin("", Ogre::RenderOperation::OT_POINT_LIST);
/* Initialize random numbers */
std::srand(std::time(0));
/* Create a set of points which will be the particles */
/* This is similar to drawing a torus: we will sample points on a torus, but will allow the points to also
deviate a bit from the torus along the direction of a random vector */
float maxspray = 0.5; // This is how much we allow the points to deviate along a normalized vector
float u, v, w, theta, phi, spray; // Work variables
for (int i = 0; i < num_particles; i++){
// Get two random numbers
u = ((double) rand() / (RAND_MAX));
v = ((double) rand() / (RAND_MAX));
// Use u and v to define a point on the torus with angles theta and phi
theta = u * Ogre::Math::TWO_PI;
phi = v * Ogre::Math::TWO_PI;
// Get center of loop and point's normal on the torus
Ogre::Vector3 center = Ogre::Vector3(loop_radius*cos(theta), loop_radius*sin(theta), 0.0);
Ogre::Vector3 normal = Ogre::Vector3(cos(theta)*cos(phi), sin(theta)*cos(phi), sin(phi));
// Next, we want to let the points deviate along the direction of a random vector
// To obtain a random vector, we sample a point on the sphere
// The point on the sphere minus the origin (0, 0) is the random vector
// Randomly select two numbers to define a point in spherical coordinates
u = ((double) rand() / (RAND_MAX));
v = ((double) rand() / (RAND_MAX));
// Use u to define the angle theta along one direction of a sphere
theta = u * Ogre::Math::TWO_PI;
// Use v to define the angle phi along the other direction of the sphere
phi = acos(2.0*v - 1.0);
// Get the point on the sphere (equivalent to a normalized direction vector since the origin is zero)
Ogre::Vector3 direct = Ogre::Vector3(cos(theta)*sin(phi), sin(theta)*sin(phi), -cos(phi));
// We need z = -cos(phi) to make sure that the z coordinate runs from -1 to 1 as phi runs from 0 to pi
// Now, multiply a random amount of deviation by this vector, which is the deviation we will add to the point on the torus
w = ((double) rand() / (RAND_MAX));
spray = maxspray*pow((float) w, (float) (1.0/3.0)); // cbrt(w);
Ogre::Vector3 wander = Ogre::Vector3(spray*direct.x, spray*direct.y, direct.z);
// Add computed quantities to the object
object->position(center + normal*circle_radius);
object->normal(wander);
object->colour(Ogre::ColourValue(((float) i)/((float) num_particles), 0.0, 0.0)); // Store particle id in the red channel as a float
object->textureCoord(Ogre::Vector2(0.0, 0.0));
}
/* We finished the object */
object->end();
/* Convert triangle list to a mesh */
object->convertToMesh(object_name);
}
示例9: EngineSetup
//.........这里部分代码省略.........
//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);
ManualObject->position(1, 0, 1);
ManualObject->triangle(21, 22, 23);
//face 5
ManualObject->position(0, 1, 0);
ManualObject->position(1, 1, 0);
ManualObject->position(0, 1, 1);
ManualObject->triangle(24, 25, 26);
ManualObject->position(1, 1, 0);
ManualObject->position(1, 1, 1);
ManualObject->position(0, 1, 1);
ManualObject->triangle(27, 28, 29);
//face 6
ManualObject->position(0, 0, 0);
ManualObject->position(0, 1, 1);
ManualObject->position(0, 0, 1);
ManualObject->triangle(30, 31, 32);
ManualObject->position(0, 0, 0);
ManualObject->position(0, 1, 0);
ManualObject->position(0, 1, 1);
ManualObject->triangle(33, 34, 35);
ManualObject->end();
Ogre::MeshPtr MeshPtr = ManualObject->convertToMesh("Animation");
Ogre::SubMesh* sub = MeshPtr->getSubMesh(0);
Ogre::SkeletonPtr Skeleton = Ogre::SkeletonManager::getSingleton().create("Skeleton", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
MeshPtr.getPointer()->_notifySkeleton(Skeleton);
Ogre::Bone *Root1 = NULL;
Ogre::Bone *Child1 = NULL;
Ogre::Bone *Child2 = NULL;
Root1 = Skeleton.getPointer()->createBone("Root");
Root1->setPosition(Ogre::Vector3(0.0, 0.0, 0.0));
Root1->setOrientation(Ogre::Quaternion::IDENTITY);
Child1 = Root1->createChild(1);
Child1->setPosition(Ogre::Vector3(4.0, 0.0, 0.0));
Child1->setOrientation(Ogre::Quaternion::IDENTITY);
Child2 = Root1->createChild(2);
Child2->setPosition(Ogre::Vector3(5.0, 0.0, 0.0));
Child2->setOrientation(Ogre::Quaternion::IDENTITY);
Ogre::VertexBoneAssignment Assignment;
Assignment.boneIndex = 0;
Assignment.vertexIndex = 0;
Assignment.weight = 1.0;
Skeleton->setBindingPose();
sub->addBoneAssignment(Assignment);
Assignment.vertexIndex = 1;
sub->addBoneAssignment(Assignment);
Assignment.vertexIndex = 2;
开发者ID:southerlies,项目名称:OGRE-3D-1.7-Application-Development-Cookbook-Code,代码行数:67,代码来源:SceletalAnimationView.cpp
示例10: generateMeshObstacles
//.........这里部分代码省略.........
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);
}
if (planeNum / (double) m_width <= m_width || m_cubes[(planeNum - m_width) / (double) m_width][planeNum % m_width] != OBSTACLE) {
//front
obstacles->triangle(2 + planeNum * 8, 6 + planeNum * 8, 4 + planeNum * 8);
obstacles->triangle(4 + planeNum * 8, 6 + planeNum * 8, 2 + planeNum * 8);
obstacles->triangle(0 + planeNum * 8, 4 + planeNum * 8, 2 + planeNum * 8);
obstacles->triangle(2 + planeNum * 8, 4 + planeNum * 8, 0 + planeNum * 8);
}
}
planeNum++;
}
pos = pos + quat * Ogre::Vector3(0, 0, -100);
}
obstacles->end();
obstacles->setCastShadows(true);
//TODO: fix graphics bug when no obstacles
/*if (m_obstaclePositions.size() <= 0)
{
return;
}*/
m_mapMainNode->attachObject(obstacles);
MeshPtr ptr = obstacles->convertToMesh("obstaclesMesh");
Entity* obstaclesEntity = m_pSceneMgr->createEntity("obstaclesEntity", "obstaclesMesh");
}
示例11: generateMesh
//.........这里部分代码省略.........
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);
plane->triangle(7 + planeNum * 8, 3 + planeNum * 8, 1 + planeNum * 8);
}
if (planeNum / (double) m_width <= m_width || m_cubes[(planeNum - m_width) / (double) m_width][planeNum % m_width] == HOLE) {
//front
plane->triangle(2 + planeNum * 8, 6 + planeNum * 8, 4 + planeNum * 8);
plane->triangle(4 + planeNum * 8, 6 + planeNum * 8, 2 + planeNum * 8);
plane->triangle(0 + planeNum * 8, 4 + planeNum * 8, 2 + planeNum * 8);
plane->triangle(2 + planeNum * 8, 4 + planeNum * 8, 0 + planeNum * 8);
}
}
planeNum++;
}
pos = pos + quat * Ogre::Vector3(0, 0, -100);
}
plane->end();
plane->setCastShadows(false);
m_mapMainNode->attachObject(plane);
MeshPtr ptr = plane->convertToMesh("planeMesh");
Entity* planeEntity = m_pSceneMgr->createEntity("planeEntity", "planeMesh");
}
示例12: readModel
void AssetLoader::readModel(Ogre::SceneManager* sceneMgr, Ogre::SceneNode* scnNode, const aiScene* scene, aiNode* nd)
{
for (size_t n = 0; n < nd->mNumChildren; n++)
{
aiNode* cnd = nd->mChildren[n];
Ogre::SceneNode* cnode = createChildSceneNodeWithTransform(scnNode, cnd);
for (size_t i = 0; i < cnd->mNumMeshes; i++) {
aiMesh* m = scene->mMeshes[cnd->mMeshes[i]];
aiMaterial* mat = scene->mMaterials[m->mMaterialIndex];
std::string nodeName = getFullPathName(cnd);
Ogre::MaterialPtr omat = createMaterial(Ogre::String(nodeName), m->mMaterialIndex, mat);
aiVector3D* vec = m->mVertices;
aiVector3D* norm = m->mNormals;
aiVector3D* uv = m->mTextureCoords[0];
aiColor4D* vcol = NULL;
if (m->HasVertexColors(0)) vcol = m->mColors[0];
// 頂点情報の読み込み
Ogre::AxisAlignedBox aab;
Ogre::ManualObject* mobj = new Ogre::ManualObject(nodeName+"_MObj");
mobj->begin(omat->getName());
//mobj->begin("Ogre/Skin");
for (size_t n = 0; n < m->mNumVertices; n ++) {
Ogre::Vector3 position(vec->x, vec->y, vec->z);
aab.merge(position);
mobj->position(vec->x, vec->y, vec->z);
vec++;
mobj->normal(norm->x, norm->y, norm->z);
norm++;
if (uv) {
mobj->textureCoord(uv->x, uv->y);
uv++;
}
if (vcol) {
mobj->colour(vcol->r, vcol->g, vcol->b, vcol->a);
vcol++;
}
}
// ポリゴンの構築
for (size_t n = 0; n < m->mNumFaces; n++) {
aiFace* face = &m->mFaces[n];
for (size_t k = 0; k < face->mNumIndices; k++) {
mobj->index(face->mIndices[k]);
}
}
mobj->end();
mobj->setBoundingBox(aab);
Ogre::String meshName(nodeName+"_Mesh");
mobj->convertToMesh(meshName);
delete mobj;
Ogre::String entityName(nodeName+"_Entity");
std::cout << "entity: " << entityName << std::endl;
Ogre::Entity* ent = sceneMgr->createEntity(entityName, meshName);
cnode->attachObject(ent);
}
readModel(sceneMgr, cnode, scene, cnd);
}
}
示例13: 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())));
//.........这里部分代码省略.........
示例14: getMeshFromMdl
Ogre::MeshPtr Loader::getMeshFromMdl(unsigned int id){
if(!models[id].isNull()){
return models[id];
}
std::string name = "mesh"+Utils::toStr(id);
std::ifstream stream;
stream.open(("Models/"+name+".mdl").c_str(),std::ios::in|std::ios::binary);
Ogre::ManualObject* obj = OgreFramework::getSingletonPtr()->m_pSceneMgr->createManualObject();
unsigned int texture, normalmap, vertices, indices;
short endian;
stream.read((char*)&endian,sizeof(short));
stream.read((char*)&texture,sizeof(unsigned int));
stream.read((char*)&normalmap,sizeof(unsigned int));
stream.read((char*)&vertices,sizeof(unsigned int));
stream.read((char*)&indices,sizeof(unsigned int));
float bounds[6];//{minX,minY,minZ,maxX,maxY,maxZ}
stream.read((char*)bounds,sizeof(float)*6);
std::string textureFName,normalMapFName;
for(int i=0;i<texture;i++){
char c;
stream.read((char*)&c,sizeof(char));
textureFName+=c;
}
if(normalmap>0){
for(int i=0;i<texture;i++){
char c;
stream.read((char*)&c,sizeof(char));
normalMapFName+=c;
}
}
if(normalmap>0)
obj->begin("NormalMapTexture");
else
obj->begin("PlainTexture");
float * arrayV = new float[vertices*(3+3+2)];
stream.read((char*)arrayV,sizeof(float)*(3+3+2)*vertices);//should also work - automatically grab ALL vertex data to array in one operation :) C++ is great
for(int i=0;i<vertices;i++){
int ptr = i*(3+3+2);
obj->position(arrayV[ptr],arrayV[ptr+1],arrayV[ptr+2]);
obj->normal(arrayV[ptr+3],arrayV[ptr+4],arrayV[ptr+5]);
obj->textureCoord(arrayV[ptr+6],arrayV[ptr+7]);
}
delete [] arrayV;
unsigned int * arrayI = new unsigned int[indices];
stream.read((char*)arrayI,sizeof(unsigned int)*indices);
for(int i=0;i<indices;i++){
obj->index(arrayI[i]);
}
delete [] arrayI;
obj->end();
/*if(normalmap>0){
obj->setMaterialName("NormalMapTexture");
obj->addTextureAlias("normalmap",normalMapFName);
}
else{
obj->setMaterialName("OneTexture");
}
obj->addTextureAlias("textura",textureFName);*/
OgreFramework::getSingletonPtr()->m_pSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(obj);
Ogre::MeshPtr mesh = obj->convertToMesh(name);
mesh->getSubMesh(0)->addTextureAlias("textura",textureFName);//TODO normalmap
return mesh;
/*Ogre::MeshPtr meshM = Ogre::MeshManager::getSingletonPtr()->createManual(name,"General");
unsigned int texture, normalmap, vertices, indices;
short endian;
stream.read((char*)&endian,sizeof(short));
stream.read((char*)&texture,sizeof(unsigned int));
stream.read((char*)&normalmap,sizeof(unsigned int));
stream.read((char*)&vertices,sizeof(unsigned int));
stream.read((char*)&indices,sizeof(unsigned int));
float bounds[6];//{minX,minY,minZ,maxX,maxY,maxZ}
stream.read((char*)bounds,sizeof(float)*6);
std::string textureFName,normalMapFName;
for(int i=0;i<texture;i++){
char c;
stream.read((char*)&c,sizeof(char));
textureFName+=c;
}
if(normalmap>0){
for(int i=0;i<texture;i++){
char c;
stream.read((char*)&c,sizeof(char));
normalMapFName+=c;
}
}
Ogre::SubMesh* mesh = meshM->createSubMesh();
// We first create a VertexData
Ogre::VertexData* data = new Ogre::VertexData();
// Then, we link it to our Mesh/SubMesh :
#ifdef SHARED_GEOMETRY
meshM->sharedVertexData = data;
#else
mesh->useSharedVertices = false; // This value is 'true' by default
//.........这里部分代码省略.........
示例15: initScene
void Client::initScene() {
Ogre::Vector3 lightPosition = Ogre::Vector3(0,10,50);
// Set the scene's ambient light
mSceneMgr->setAmbientLight(Ogre::ColourValue(.1f, .1f, .1f));
Ogre::Light* pointLight = mSceneMgr->createLight("pointLight");
pointLight->setType(Ogre::Light::LT_POINT);
pointLight->setPosition(lightPosition);
// create a marker where the light is
Ogre::Entity* ogreHead2 = mSceneMgr->createEntity( "Head2", "ogrehead.mesh" );
Ogre::SceneNode* headNode2 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "HeadNode2", lightPosition );
headNode2->attachObject( ogreHead2 );
headNode2->scale( .5, .5, .5 );
// make a quad
Ogre::ManualObject* lManualObject = NULL;
Ogre::String lNameOfTheMesh = "TestQuad";
{
// params
Ogre::String lManualObjectName = "TestQuad";
bool lDoIWantToUpdateItLater = false;
// code
lManualObject = mSceneMgr->createManualObject(lManualObjectName);
lManualObject->setDynamic(lDoIWantToUpdateItLater);
lManualObject->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST);
{ // Specify Vertices
float xmin = 0.0f, xmax = 100.0f, zmin = -100.0f, zmax = 0.0f, ymin = -50.0f, ymax = 0.0f;
lManualObject->position(xmin, ymin, zmin);// a vertex
lManualObject->colour(Ogre::ColourValue::Red);
lManualObject->textureCoord(0.0,0.0);
lManualObject->position(xmax, ymin, zmin);// a vertex
lManualObject->colour(Ogre::ColourValue::Green);
lManualObject->textureCoord(1.0,0.0);
lManualObject->position(xmin, ymin, zmax);// a vertex
lManualObject->colour(Ogre::ColourValue::Blue);
lManualObject->textureCoord(0.0,1.0);
lManualObject->position(xmax, ymin, zmax);// a vertex
lManualObject->colour(Ogre::ColourValue::Blue);
lManualObject->textureCoord(1.0,1.0);
}
{ // specify geometry
lManualObject->triangle(0,2,1);
lManualObject->triangle(3,1,2);
}
lManualObject->end();
lManualObject->convertToMesh(lNameOfTheMesh);
}
Ogre::Entity* lEntity = mSceneMgr->createEntity(lNameOfTheMesh);
Ogre::SceneNode* lNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
lNode->attachObject(lEntity);
Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh");
// Create a SceneNode and attach the Entity to it
Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("HeadNode",Ogre::Vector3(0,-20,0));
headNode->attachObject(ogreHead);
ogreHead->setMaterialName("Hatching");
lEntity->setMaterialName("Hatching");
// postprocessing effects
//Ogre::CompositorManager::getSingleton().addCompositor(mViewport,"Sobel" );
//Ogre::CompositorManager::getSingleton().setCompositorEnabled(mCamera->getViewport(), "Sobel", true);
//Ogre::CompositorManager::getSingleton().addCompositor(mViewport,"CelShading" );
//Ogre::CompositorManager::getSingleton().setCompositorEnabled(mCamera->getViewport(), "CelShading", true);
}