本文整理汇总了C++中ManualObject::textureCoord方法的典型用法代码示例。如果您正苦于以下问题:C++ ManualObject::textureCoord方法的具体用法?C++ ManualObject::textureCoord怎么用?C++ ManualObject::textureCoord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ManualObject
的用法示例。
在下文中一共展示了ManualObject::textureCoord方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// 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;
}
示例2: 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;
}
示例3: 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);
}
示例4: createProceduralParticleSystem
ProceduralManualObject* createProceduralParticleSystem()
{
particleSystem = static_cast<ProceduralManualObject*>
(mSceneMgr->createMovableObject("ParticleGSEntity", ProceduralManualObjectFactory::FACTORY_TYPE_NAME));
particleSystem->setMaterial("Ogre/ParticleGS/Display");
//Generate the geometry that will seed the particle system
ManualObject* particleSystemSeed = mSceneMgr->createManualObject("ParticleSeed");
//This needs to be the initial launcher particle
particleSystemSeed->begin("Ogre/ParticleGS/Display", RenderOperation::OT_POINT_LIST);
particleSystemSeed->position(0,0,0); //Position
particleSystemSeed->textureCoord(1); //Timer
particleSystemSeed->textureCoord(0); //Type
particleSystemSeed->textureCoord(0,0,0); //Velocity
particleSystemSeed->end();
//Generate the RenderToBufferObject
RenderToVertexBufferSharedPtr r2vbObject =
HardwareBufferManager::getSingleton().createRenderToVertexBuffer();
r2vbObject->setRenderToBufferMaterialName("Ogre/ParticleGS/Generate");
//Apply the random texture
TexturePtr randomTexture = RandomTools::generateRandomVelocityTexture();
r2vbObject->getRenderToBufferMaterial()->getTechnique(0)->getPass(0)->
getTextureUnitState("RandomTexture")->setTextureName(
randomTexture->getName(), randomTexture->getTextureType());
r2vbObject->setOperationType(RenderOperation::OT_POINT_LIST);
r2vbObject->setMaxVertexCount(16000);
r2vbObject->setResetsEveryUpdate(false);
VertexDeclaration* vertexDecl = r2vbObject->getVertexDeclaration();
size_t offset = 0;
offset += vertexDecl->addElement(0, offset, VET_FLOAT3, VES_POSITION).getSize(); //Position
offset += vertexDecl->addElement(0, offset, VET_FLOAT1, VES_TEXTURE_COORDINATES, 0).getSize(); //Timer
offset += vertexDecl->addElement(0, offset, VET_FLOAT1, VES_TEXTURE_COORDINATES, 1).getSize(); //Type
offset += vertexDecl->addElement(0, offset, VET_FLOAT3, VES_TEXTURE_COORDINATES, 2).getSize(); //Velocity
//Bind the two together
particleSystem->setRenderToVertexBuffer(r2vbObject);
particleSystem->setManualObject(particleSystemSeed);
//Set bounds
AxisAlignedBox aabb;
aabb.setMinimum(-100,-100,-100);
aabb.setMaximum(100,100,100);
particleSystem->setBoundingBox(aabb);
return particleSystem;
}
示例5: 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);
}
示例6: 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);
}