当前位置: 首页>>代码示例>>C++>>正文


C++ ManualObject::textureCoord方法代码示例

本文整理汇总了C++中ogre::ManualObject::textureCoord方法的典型用法代码示例。如果您正苦于以下问题:C++ ManualObject::textureCoord方法的具体用法?C++ ManualObject::textureCoord怎么用?C++ ManualObject::textureCoord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ogre::ManualObject的用法示例。


在下文中一共展示了ManualObject::textureCoord方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateRegion

//-------------------------------------------------------
Ogre::MeshPtr Ground::CreateRegion(size_t id, const std::string & material, const Ogre::Box & roi, const Ogre::Vector3 & offset, const Ogre::Vector3 & steps, const Ogre::Vector2 & texOffset)
{
    assert(mSceneManager != nullptr);

    Ogre::ManualObject* object = mSceneManager->createManualObject();
    object->begin(material, Ogre::RenderOperation::OT_TRIANGLE_LIST);
    {
        size_t lastIdx = 0;
        for (size_t y = 0; y < REGION_SIZE; ++y)
        {
            size_t texY = static_cast<size_t>(static_cast<float>(y) / REGION_SIZE * (roi.getHeight() - 1));
            size_t texYn = static_cast<size_t>(static_cast<float>(y + 1) / REGION_SIZE * (roi.getHeight() - 1));

            //Flip texture vertically
            texY  = roi.getHeight() - 1 - texY;
            texYn = roi.getHeight() - 1 - texYn;

            float texCrdT = texOffset[1] + static_cast<float>(texY) / (mImage->getHeight() - 1);
            float texCrdTn = texOffset[1] + static_cast<float>(texYn) / (mImage->getHeight() - 1);

            for (size_t x = 0; x < REGION_SIZE; ++x)
            {
                size_t texX = static_cast<size_t>(static_cast<float>(x) / REGION_SIZE * (roi.getWidth() - 1));
                size_t texXn = static_cast<size_t>(static_cast<float>(x + 1) / REGION_SIZE * (roi.getWidth() - 1));

                float texCrdS = texOffset[0] + static_cast<float>(texX) / (mImage->getWidth() - 1);
                float texCrdSn = texOffset[0] + static_cast<float>(texXn) / (mImage->getWidth() - 1);

                float h00 = mImage->getColourAt(roi.left + texX,  roi.top + texY, 0)[0];
                float h10 = mImage->getColourAt(roi.left + texXn, roi.top + texY, 0)[0];
                float h01 = mImage->getColourAt(roi.left + texX,  roi.top + texYn, 0)[0];
                float h11 = mImage->getColourAt(roi.left + texXn, roi.top + texYn, 0)[0];

                object->position(x * steps[0] + offset[0], y * steps[1] + offset[1], h00 * steps[2]);
                object->textureCoord(texCrdS, texCrdT);
                object->colour(h00, h00, h00);
                
                object->position((x + 1) * steps[0] + offset[0], y * steps[1] + offset[1], h10 * steps[2]);
                object->textureCoord(texCrdSn, texCrdT);
                object->colour(h10, h10, h10);

                object->position(x * steps[0] + offset[0], (y + 1) * steps[1] + offset[1], h01 * steps[2]);
                object->textureCoord(texCrdS, texCrdTn);
                object->colour(h01, h01, h01);

                object->position((x + 1) * steps[0] + offset[0], (y + 1) * steps[1] + offset[1], h11 * steps[2]);
                object->textureCoord(texCrdSn, texCrdTn);
                object->colour(h11, h11, h11);

                object->triangle(lastIdx + 1, lastIdx + 2, lastIdx);
                object->triangle(lastIdx + 3, lastIdx + 2, lastIdx + 1);
                lastIdx += 4;
            }
        }
    }
    object->end();
    return object->convertToMesh("Mesh/" + CLASS_NAME  + "/" + mName + "/" + std::to_string(id));
}
开发者ID:agruzdev,项目名称:OgreNature,代码行数:59,代码来源:Ground.cpp

示例2: toMesh

Ogre::MeshPtr STLLoader::toMesh(const std::string& name)
{
  Ogre::ManualObject* object = new Ogre::ManualObject( "the one and only" );
  object->begin( "BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST );

  unsigned int vertexCount = 0;
  V_Triangle::const_iterator it = triangles_.begin();
  V_Triangle::const_iterator end = triangles_.end();
  for (; it != end; ++it )
  {
    if( vertexCount >= 2004 )
    {
      // Subdivide large meshes into submeshes with at most 2004
      // vertices to prevent problems on some graphics cards.
      object->end();
      object->begin( "BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST );
      vertexCount = 0;
    }

    const STLLoader::Triangle& tri = *it;

    float u, v;
    u = v = 0.0f;
    object->position( tri.vertices_[0] );
    object->normal( tri.normal_);
    calculateUV( tri.vertices_[0], u, v );
    object->textureCoord( u, v );

    object->position( tri.vertices_[1] );
    object->normal( tri.normal_);
    calculateUV( tri.vertices_[1], u, v );
    object->textureCoord( u, v );

    object->position( tri.vertices_[2] );
    object->normal( tri.normal_);
    calculateUV( tri.vertices_[2], u, v );
    object->textureCoord( u, v );

    object->triangle( vertexCount + 0, vertexCount + 1, vertexCount + 2 );

    vertexCount += 3;
  }

  object->end();

  Ogre::MeshPtr mesh = object->convertToMesh( name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
  mesh->buildEdgeList();

  delete object;

  return mesh;
}
开发者ID:carnoot,项目名称:gazebo_pcl_project,代码行数:52,代码来源:stl_loader.cpp

示例3: addQuad

void addQuad(
	const std::vector<Ogre::Vector3>& i_clockwiseQuad,
	const Ogre::Vector3& i_normal,
	size_t i_nRows,
	size_t i_nCols,
	const Ogre::String& i_material,
	Ogre::ManualObject& io_object)
{
	assert(i_clockwiseQuad.size() == 4);
	assert(i_nRows != 0 && i_nCols != 0);

	const std::vector<Ogre::Vector3>& box = i_clockwiseQuad;
	const Ogre::Vector3& n = i_normal;
	float ratioCol = 1.f / (float)(i_nCols);
	float ratioRow = 1.f / (float)(i_nRows);
	Ogre::Vector3 stepCol = (box[1] - box[0]) * ratioCol;
	Ogre::Vector3 stepRow = (box[3] - box[0]) * ratioRow;

	std::vector<Ogre::Vector3> cur(4);

	for (size_t r = 0; r < i_nRows; ++r)
	{
		io_object.begin(i_material, Ogre::RenderOperation::OT_TRIANGLE_LIST);
		for (size_t c = 0; c < i_nCols; ++c)
		{
			cur[0] = box[0] + stepRow * (float)r + stepCol * (float)c;
			cur[1] = box[0] + stepRow * (float)r + stepCol * (float)(c+1);
			cur[2] = box[0] + stepRow * (float)(r+1) + stepCol * (float)(c+1);
			cur[3] = box[0] + stepRow * (float)(r+1) + stepCol * (float)(c);

			io_object.position(cur[0].x, cur[0].y, cur[0].z);
			io_object.normal(n.x, n.y, n.z);
			io_object.textureCoord(ratioRow*(float)r, ratioCol*(float)c);

			io_object.position(cur[3].x, cur[3].y, cur[3].z);
			io_object.normal(n.x, n.y, n.z);
			io_object.textureCoord(ratioRow*(float)(r+1), ratioCol*(float)c);

			io_object.position(cur[1].x, cur[1].y, cur[1].z);
			io_object.normal(n.x, n.y, n.z);
			io_object.textureCoord(ratioRow*(float)r, ratioCol*(float)(c+1));

			io_object.position(cur[1].x, cur[1].y, cur[1].z);
			io_object.normal(n.x, n.y, n.z);
			io_object.textureCoord(ratioRow*(float)r, ratioCol*(float)(c + 1));

			io_object.position(cur[3].x, cur[3].y, cur[3].z);
			io_object.normal(n.x, n.y, n.z);
			io_object.textureCoord(ratioRow*(float)(r + 1), ratioCol*(float)c);

			io_object.position(cur[2].x, cur[2].y, cur[2].z);
			io_object.normal(n.x, n.y, n.z);
			io_object.textureCoord(ratioRow*(float)(r+1), ratioCol*(float)(c + 1));

		}
		io_object.end();
	}
}
开发者ID:BeanOfLight,项目名称:BeanOfLight,代码行数:58,代码来源:ProceduralShape.cpp

示例4: ExportWallMesh

void OgreExporter_c::ExportWallMesh(Ogre::ManualObject &manualMesh, int floorHeight, int ceilingHeight, Name_u textureName, int offsetX, int offsetY, const Vertex_s *vertices, const LineDef_s &lineDef, const WadFile_c &wad)
{
	std::stringstream stream;
	stream << textureName.ToString();
	manualMesh.begin(stream.str(), Ogre::RenderOperation::OT_TRIANGLE_LIST);

	const Texture_s &tex = wad.GetTextureInfo(textureName);

	const Vertex_s &startVertex = vertices[lineDef.iStartVertex];
	const Vertex_s &endVertex = vertices[lineDef.iEndVertex];

	int height = ceilingHeight - floorHeight;	
	int width = Ogre::Vector2(startVertex.iX, startVertex.iY).distance(Ogre::Vector2(endVertex.iX, endVertex.iY));
	
	float offsetU = offsetX / (float) tex.uWidth;
	float offsetV = offsetY / (float) tex.uHeight;	

	float endV = (height / (float)tex.uHeight) + offsetV;
	float endU = (width / (float) tex.uWidth) + offsetU;

	manualMesh.position(-startVertex.iX, floorHeight, startVertex.iY);
	manualMesh.textureCoord(offsetU, endV);

	manualMesh.position(-startVertex.iX, ceilingHeight, startVertex.iY);
	manualMesh.textureCoord(offsetU, offsetV);
	
	manualMesh.position(-endVertex.iX, ceilingHeight, endVertex.iY);
	manualMesh.textureCoord(endU, offsetV);		

	manualMesh.position(-endVertex.iX, floorHeight, endVertex.iY);
	manualMesh.textureCoord(endU, endV);	

	manualMesh.triangle(2, 1, 0);
	manualMesh.triangle(0, 3, 2);

	manualMesh.end();
}
开发者ID:jlsandell,项目名称:wadlib,代码行数:37,代码来源:OgreExporter.cpp

示例5: malloc

//-------------------------------------------------------------------------------------
Ogre::ManualObject* const DigitalForensicsVisualisation::rectangle(std::string matName)
{

	char* name = (char*) malloc (32);
	sprintf(name, "rect%d", app.rectCount++);

	Ogre::ManualObject* rect = mSceneMgr->createManualObject(name);
	rect->begin(matName, Ogre::RenderOperation::OT_TRIANGLE_LIST);

	rect->position(100,100.1,0);
	rect->textureCoord(1,0);
	rect->normal(50,500,50);

	rect->position(0,100.1,100);
	rect->textureCoord(0,1);
	rect->normal(50,500,50);

	rect->position(0,100.1,0);
	rect->textureCoord(0,0);
	rect->normal(50,500,50);

	rect->position(100,100.1,100);
	rect->textureCoord(1,1);
	rect->normal(50,500,50);

	rect->triangle(2,1,0);
	rect->triangle(1,3,0);
	
	rect->end();
	free(name);


	return rect;


}
开发者ID:ljmu-cms,项目名称:digital-forensics-visualisation,代码行数:37,代码来源:DigitalForensicsVisualisation.cpp

示例6:

 void RenderSystem::RenderLightMesh3DWithTexture(std::string meshName, std::string materialName, const MagicDGP::LightMesh3D* pMesh)
 {
     InfoLog << "RenderSystem::RenderMesh3D" << std::endl;
     Ogre::ManualObject* pMObj = NULL;
     if (mpSceneMgr->hasManualObject(meshName))
     {
         pMObj = mpSceneMgr->getManualObject(meshName);
         pMObj->clear();
     }
     else
     {
         pMObj = mpSceneMgr->createManualObject(meshName);
         if (mpSceneMgr->hasSceneNode("ModelNode"))
         {
             mpSceneMgr->getSceneNode("ModelNode")->attachObject(pMObj);
         }
         else
         {
             mpSceneMgr->getRootSceneNode()->createChildSceneNode("ModelNode")->attachObject(pMObj);
         }
     }
     pMObj->begin(materialName, Ogre::RenderOperation::OT_TRIANGLE_LIST);
     int vertNum = pMesh->GetVertexNumber();
     for (int i = 0; i < vertNum; i++)
     {
         const MagicDGP::Vertex3D* pVert = pMesh->GetVertex(i);
         MagicMath::Vector3 pos = pVert->GetPosition();
         MagicMath::Vector3 nor = pVert->GetNormal();
         MagicMath::Vector3 texCord = pVert->GetTexCord();
         pMObj->position(pos[0], pos[1], pos[2]);
         pMObj->normal(nor[0], nor[1], nor[2]);
         pMObj->textureCoord(texCord[0], texCord[1]);
     }
     int faceNum = pMesh->GetFaceNumber();
     for (int i = 0; i < faceNum; i++)
     {
         MagicDGP::FaceIndex faceIdx = pMesh->GetFace(i);
         pMObj->triangle(faceIdx.mIndex[0], faceIdx.mIndex[1], faceIdx.mIndex[2]);
     }
     pMObj->end();
 }
开发者ID:jinghuaguo,项目名称:magic3d,代码行数:41,代码来源:RenderSystem.cpp

示例7: createTerrainDecal

Ogre::ManualObject* TerrainManager::createTerrainDecal(Ogre::String& name, Ogre::String& material, Ogre::String& resourceGroup)
{
	if(!_OgreManager)
		return NULL;

	Ogre::ManualObject* meshDecal = new Ogre::ManualObject(name);

	_OgreManager->getSceneManager()->getRootSceneNode()->attachObject(meshDecal);
	
	int x_size = 4;  // number of polygons
	int z_size = 4;
 
	meshDecal->begin(material, Ogre::RenderOperation::OT_TRIANGLE_LIST, resourceGroup);
	for (int i=0; i<=x_size; i++)
	{
		for (int j=0; j<=z_size; j++)
		{
			meshDecal->position(Ogre::Vector3(i, 0, j));
			meshDecal->textureCoord((float)i / (float)x_size, (float)j / (float)z_size);
		}
	}
 
	for (int i=0; i<x_size; i++)
	{
		for (int j=0; j<z_size; j++)
		{
			meshDecal->quad( i * (x_size+1) + j,
							 i * (x_size+1) + j + 1,
							(i + 1) * (x_size+1) + j + 1,
							(i + 1) * (x_size+1) + j);
		}
	}
	meshDecal->end();

	return meshDecal;
}
开发者ID:dj2gcc,项目名称:AGT-Game,代码行数:36,代码来源:TerrainManager.cpp

示例8: UpdateTerrain

// Given a scene node for a terrain, find the manual object on that scene node and
// update the manual object with the heightmap passed. If  there is no manual object on
// the scene node, remove all it's attachments and add the manual object.
// The heightmap is passed in a 1D array ordered by width rows (for(width) {for(length) {hm[w,l]}})
// This must be called between frames since it touches the scene graph
// BETWEEN FRAME OPERATION
void Region::UpdateTerrain(const int hmWidth, const int hmLength, const float* hm) {
	Ogre::SceneNode* node = this->TerrainSceneNode;
	LG::Log("Region::UpdateTerrain: updating terrain for region %s", this->Name.c_str());

	if (node == NULL) {
		LG::Log("Region::UpdateTerrain: terrain scene node doesn't exist. Not updating terrain.");
		return;
	}

	// Find the movable object attached to the scene node. If not found remove all.
	if (node->numAttachedObjects() > 0) {
		Ogre::MovableObject* attached = node->getAttachedObject(0);
		if (attached->getMovableType() != "ManualObject") {
            // don't know why this would ever happen but clean out the odd stuff
            LG::Log("Found extra stuff on terrain scene node");
			node->detachAllObjects();
		}
	}
	// if there is not a manual object on the node, create a new one
	if (node->numAttachedObjects() == 0) {
		LG::Log("Region::UpdateTerrain: creating terrain ManualObject for region %s", this->Name.c_str());
        // if no attached objects, we add our dynamic ManualObject
		Ogre::ManualObject* mob = LG::RendererOgre::Instance()->m_sceneMgr->createManualObject("ManualObject/" + node->getName());
		mob->addQueryFlags(Ogre::SceneManager::WORLD_GEOMETRY_TYPE_MASK);
		mob->setDynamic(true);
		mob->setCastShadows(true);
		mob->setVisible(true);
		node->attachObject(mob);
		// m_visCalc->RecalculateVisibility();
	}

	Ogre::ManualObject* mo = (Ogre::ManualObject*)node->getAttachedObject(0);

	// stuff our heightmap information into the dynamic manual object
	mo->estimateVertexCount(hmWidth * hmLength);
	mo->estimateIndexCount(hmWidth * hmLength * 6);

	if (mo->getNumSections() == 0) {
		// if first time
		mo->begin(LG::GetParameter("Renderer.Ogre.DefaultTerrainMaterial"));
	}
	else {
		mo->beginUpdate(0);					// we've been here before
	}

	int loc = 0;
	for (int xx = 0; xx < hmWidth; xx++) {
		for (int yy = 0; yy < hmLength; yy++) {
			mo->position((Ogre::Real)xx, (Ogre::Real)yy, hm[loc++]);
			mo->textureCoord((float)xx / (float)hmWidth, (float)yy / (float)hmLength);
			mo->normal(0.0, 1.0, 0.0);	// always up (for the moment)
		}
	}

	for (int px = 0; px < hmLength-1; px++) {
		for (int py = 0; py < hmWidth-1; py++) {
			mo->quad(px      + py       * hmWidth,
					 px      + (py + 1) * hmWidth,
					(px + 1) + (py + 1) * hmWidth,
					(px + 1) + py       * hmWidth
					 );
		}
	}

	mo->end();

	return;
}
开发者ID:Misterblue,项目名称:LookingGlass-Viewer,代码行数:74,代码来源:Region.cpp

示例9: createCubeMesh

//Copied from BetaCairo demo : http://www.ogre3d.org/forums/viewtopic.php?t=26987 (created by betajaen)
Ogre::ManualObject* OgreAppLogic::createCubeMesh(const std::string& name, const std::string& matName)
{
	Ogre::ManualObject* cube = new Ogre::ManualObject(name);
	cube->begin(matName);

	cube->position(0.500000,-0.500000,1.000000);
	cube->normal(0.408248f,-0.816497f,0.408248f);
	cube->textureCoord(1,0);


	cube->position(-0.500000,-0.500000,0.000000);
	cube->normal(-0.408248f,-0.816497f,-0.408248f);
	cube->textureCoord(0,1);

	cube->position(0.500000,-0.500000,0.000000);
	cube->normal(0.666667f,-0.333333f,-0.666667f);
	cube->textureCoord(1,1);

	cube->position(-0.500000,-0.500000,1.000000);
	cube->normal(-0.666667f,-0.333333f,0.666667f);
	cube->textureCoord(0,0);

	cube->position(0.500000,0.500000,1.000000);
	cube->normal(0.666667f,0.333333f,0.666667f);
	cube->textureCoord(1,0);

	cube->position(-0.500000,-0.500000,1.000000);
	cube->normal(-0.666667f,-0.333333f,0.666667f);
	cube->textureCoord(0,1);

	cube->position(0.500000,-0.500000,1.000000);
	cube->normal(0.408248f,-0.816497f,0.408248f);
	cube->textureCoord(1,1);

	cube->position(-0.500000,0.500000,1.000000);
	cube->normal(-0.408248f,0.816497f,0.408248f);
	cube->textureCoord(0,0);

	cube->position(-0.500000,0.500000,0.000000);
	cube->normal(-0.666667f,0.333333f,-0.666667f);
	cube->textureCoord(0,1);

	cube->position(-0.500000,-0.500000,0.000000);
	cube->normal(-0.408248f,-0.816497f,-0.408248f);
	cube->textureCoord(1,1);

	cube->position(-0.500000,-0.500000,1.000000);
	cube->normal(-0.666667f,-0.333333f,0.666667f);
	cube->textureCoord(1,0);

	cube->position(0.500000,-0.500000,0.000000);
	cube->normal(0.666667f,-0.333333f,-0.666667f);
	cube->textureCoord(0,1);

	cube->position(0.500000,0.500000,0.000000);
	cube->normal(0.408248f,0.816497f,-0.408248f);
	cube->textureCoord(1,1);

	cube->position(0.500000,-0.500000,1.000000);
	cube->normal(0.408248f,-0.816497f,0.408248f);
	cube->textureCoord(0,0);

	cube->position(0.500000,-0.500000,0.000000);
	cube->normal(0.666667f,-0.333333f,-0.666667f);
	cube->textureCoord(1,0);

	cube->position(-0.500000,-0.500000,0.000000);
	cube->normal(-0.408248f,-0.816497f,-0.408248f);
	cube->textureCoord(0,0);

	cube->position(-0.500000,0.500000,1.000000);
	cube->normal(-0.408248f,0.816497f,0.408248f);
	cube->textureCoord(1,0);

	cube->position(0.500000,0.500000,0.000000);
	cube->normal(0.408248f,0.816497f,-0.408248f);
	cube->textureCoord(0,1);

	cube->position(-0.500000,0.500000,0.000000);
	cube->normal(-0.666667f,0.333333f,-0.666667f);
	cube->textureCoord(1,1);

	cube->position(0.500000,0.500000,1.000000);
	cube->normal(0.666667f,0.333333f,0.666667f);
	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(); 
//.........这里部分代码省略.........
开发者ID:aufheben1,项目名称:visual-experiments,代码行数:101,代码来源:OgreAppLogic.cpp

示例10: generateMesh

void Map::generateMesh(std::string materialName)
{
    Ogre::ManualObject* plane = new Ogre::ManualObject("plane");
    plane->estimateIndexCount(m_length * m_width * 8);
    plane->estimateVertexCount(m_length * m_width * 8);
    plane->clear();
    plane->begin(materialName);

    Ogre::Vector3 pos = Ogre::Vector3(0, 0, 0);
    Ogre::Quaternion quat;
    Ogre::Quaternion quatNext;
    unsigned long planeNum = 0;

    for (unsigned int i = 0; i < m_length; i++) {
        quat = m_rotationalSpline.getPoint(i);
        quatNext = m_rotationalSpline.getPoint(i + 1);

        for (int x = -100 * (m_width / (double) 2), j = 0; (unsigned) j < m_width; j++, x += 100) {
            int back = -100;
            int left = x;
            int right = x + 100;
            int down = -20 ;

            Ogre::Vector3 nextPos =             pos + quat * Ogre::Vector3(0, 0, back);
            Ogre::Vector3 posMinus50 =          pos + quat * Ogre::Vector3(left, 0, 0);
            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);
//.........这里部分代码省略.........
开发者ID:prettyv,项目名称:rauschabstand,代码行数:101,代码来源:Map.cpp

示例11: EngineSetup

void CTransparentMaterialView::EngineSetup(void)
{
	Ogre::Root *Root = ((CTransparentMaterialApp*)AfxGetApp())->m_Engine->GetRoot();

	Ogre::SceneManager *SceneManager = NULL;

	SceneManager = Root->createSceneManager(Ogre::ST_GENERIC, "MFCOgre");

    //
    // Create a render window
    // This window should be the current ChildView window using the externalWindowHandle
    // value pair option.
    //

    Ogre::NameValuePairList parms;
    parms["externalWindowHandle"] = Ogre::StringConverter::toString((long)m_hWnd);
    parms["vsync"] = "true";

	CRect   rect;
    GetClientRect(&rect);

	Ogre::RenderTarget *RenderWindow = Root->getRenderTarget("Ogre in MFC");

	if (RenderWindow == NULL)
	{
	try
	{
		m_RenderWindow = Root->createRenderWindow("Ogre in MFC", rect.Width(), rect.Height(), false, &parms);
	}
    catch(...)
	{
		MessageBox("Cannot initialize\nCheck that graphic-card driver is up-to-date", "Initialize Render System", MB_OK | MB_ICONSTOP);
		exit(EXIT_SUCCESS);
	}
	}
// Load resources
	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

    // Create the camera
    m_Camera = SceneManager->createCamera("Camera");
    m_Camera->setNearClipDistance(0.5);
	m_Camera->setFarClipDistance(5000); 
	m_Camera->setCastShadows(false);
	m_Camera->setUseRenderingDistance(true);
	m_Camera->setPosition(Ogre::Vector3(320.0, 240.0, 500.0));
	Ogre::SceneNode *CameraNode = NULL;
	CameraNode = SceneManager->getRootSceneNode()->createChildSceneNode("CameraNode");

	Ogre::Viewport* Viewport = NULL;
	
	if (0 == m_RenderWindow->getNumViewports())
	{
		Viewport = m_RenderWindow->addViewport(m_Camera);
		Viewport->setBackgroundColour(Ogre::ColourValue(0.8f, 1.0f, 0.8f));
	}

    // Alter the camera aspect ratio to match the viewport
    m_Camera->setAspectRatio(Ogre::Real(rect.Width()) / Ogre::Real(rect.Height()));

	Ogre::ManualObject *Screen = SceneManager->createManualObject("Screen");
	Screen->setDynamic(true);
	Screen->begin("window", Ogre::RenderOperation::OT_TRIANGLE_LIST);

	Screen->position(-100,-100,50);
	Screen->textureCoord(0,0);

	Screen->position(300,-100,50);
	Screen->textureCoord(1,0);

	Screen->position(300,300,50);
	Screen->textureCoord(1,1);

	Screen->triangle(0, 1, 2);
		
	Screen->position(-100,-100,50);
	Screen->textureCoord(0,0);

	Screen->position(300,300,50);
	Screen->textureCoord(1,1);

	Screen->position(-100,300,50);
	Screen->textureCoord(0,1);

	Screen->triangle(3, 4, 5);
	 
	Screen->end();
	
	Ogre::Entity *RobotEntity = SceneManager->createEntity("Robot", "robot.mesh");
	Ogre::SceneNode *RobotNode = SceneManager->getRootSceneNode()->createChildSceneNode();
	RobotNode->attachObject(RobotEntity);

	Ogre::SceneNode *WindowNode = SceneManager->getRootSceneNode()->createChildSceneNode();
	WindowNode->attachObject(Screen);
}
开发者ID:southerlies,项目名称:OGRE-3D-1.7-Application-Development-Cookbook-Code,代码行数:94,代码来源:TransparentMaterialView.cpp

示例12: 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
//.........这里部分代码省略.........
开发者ID:Aperion,项目名称:rigsofrods-next-stable,代码行数:101,代码来源:DecalManager.cpp

示例13: cosf

Ogre::ManualObject * CCone::CreateCone(Ogre::Real Intensity)
{
	Ogre::ManualObject *Cone = NULL;
	Ogre::SceneManager *SceneManager = Ogre::Root::getSingleton().getSceneManager("DynamicEffects");
	Cone = SceneManager->createManualObject("Cone");
	Cone->setDynamic(false);
    Cone->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST);

	Ogre::Real deltaAngle = (Ogre::Math::TWO_PI / m_BaseSegments);
	Ogre::Real deltaHeight = m_Height/(Ogre::Real)m_HeightSegments;
	
	Ogre::Vector3 Normal = Ogre::Vector3(m_Radius, m_Height, 0.f).normalisedCopy();
	Ogre::Quaternion Quaternion;
	
	int Offset = 0;

	for (int HeightSegmentIndex = 0; HeightSegmentIndex <= m_HeightSegments; HeightSegmentIndex++)
	{
		Ogre::Real Radius = m_Radius * (1 - HeightSegmentIndex / (Ogre::Real)m_HeightSegments);
		
		for (int BaseSegmentIndex = 0; BaseSegmentIndex <= m_BaseSegments; BaseSegmentIndex++)
		{
			Ogre::Real x = Radius* cosf(BaseSegmentIndex * deltaAngle);
			Ogre::Real z = Radius * sinf(BaseSegmentIndex * deltaAngle);
			Cone->position(x, HeightSegmentIndex * deltaHeight, z);
			
			Cone->colour(Intensity, Intensity, 0.0, 1.0);
			Quaternion.FromAngleAxis(Ogre::Radian(-BaseSegmentIndex*deltaAngle), Ogre::Vector3::NEGATIVE_UNIT_Y);
			Cone->normal(Quaternion * Normal);
			Cone->textureCoord(BaseSegmentIndex / (Ogre::Real)m_BaseSegments, HeightSegmentIndex / (Ogre::Real)m_HeightSegments);

			if (HeightSegmentIndex != m_HeightSegments && BaseSegmentIndex != m_BaseSegments)
			{
				Cone->index(Offset + m_BaseSegments + 2);
				Cone->index(Offset);
				Cone->index(Offset + m_BaseSegments + 1);
				Cone->index(Offset + m_BaseSegments + 2);
				Cone->index(Offset + 1);
				Cone->index(Offset);
			}

			Offset++;
		}
	}

	int centerIndex = Offset;
	
	Cone->position(0,0,0);
	Cone->normal(Ogre::Vector3::NEGATIVE_UNIT_Y);
	Cone->textureCoord(0.0,1);
	Offset++;
	
	for (int BaseSegmentIndex=0; BaseSegmentIndex <= m_BaseSegments; BaseSegmentIndex++)
	{
		Ogre::Real x = m_Radius * cosf(BaseSegmentIndex*deltaAngle);
		Ogre::Real z = m_Radius * sinf(BaseSegmentIndex*deltaAngle);

		Cone->position(x, 0.0f, z);
		Cone->colour(Intensity, Intensity, 0.0, 0.0);
		Cone->normal(Ogre::Vector3::NEGATIVE_UNIT_Y);
		Cone->textureCoord(BaseSegmentIndex/(Ogre::Real)m_BaseSegments,0.0);
		if (BaseSegmentIndex != m_BaseSegments)
		{
			Cone->index(centerIndex);
			Cone->index(Offset);
			Cone->index(Offset+1);
		}
		Offset++;
	}

	Cone->end();

	return Cone;
}
开发者ID:southerlies,项目名称:OGRE-3D-1.7-Application-Development-Cookbook-Code,代码行数:74,代码来源:Cone.cpp

示例14: assembleScene

void AerialMapDisplay::assembleScene() {
  if (!dirty_) {
    return; //  nothing to update
  }
  dirty_ = false;
  
  if (!loader_) {
    return; //  no tiles loaded, don't do anything
  }
  
  //  get rid of old geometry, we will re-build this
  clearGeometry();
  
  //  iterate over all tiles and create an object for each of them
  const double resolution = loader_->resolution();
  const std::vector<TileLoader::MapTile> &tiles = loader_->tiles();
  for (const TileLoader::MapTile &tile : tiles) {
    const int w = tile.image().width();
    const int h = tile.image().height();
    //  we here assume that the tiles are uniformly sized...
    const double tileW = w * resolution;
    const double tileH = h * resolution;
    const double origin_x = -loader_->originX() * tileW;
    const double origin_y = -(1 - loader_->originY()) * tileH;

    //  determine location of this tile
    const double x = (tile.x() - loader_->tileX()) * tileW + origin_x;
    const double y = -(tile.y() - loader_->tileY()) * tileH + origin_y;
    //  don't re-use any ids
    const std::string name_suffix =
        std::to_string(tile.x()) + "_" + std::to_string(tile.y()) + "_" +
        std::to_string(map_id_) + "_" + std::to_string(scene_id_);

    Ogre::TexturePtr tex;
    if (tile.hasImage()) {
      //  one material per texture
      std::string matName = "material_" + name_suffix;
      Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create(
          matName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
      material->setReceiveShadows(false);
      material->getTechnique(0)->setLightingEnabled(false);
      material->setDepthBias(-16.0f,
                             0.0f); /// @todo: what the fuck does this do?
      material->setCullingMode(Ogre::CULL_NONE);
      material->setDepthWriteEnabled(false);

      //  create textureing unit
      Ogre::Pass *pass = material->getTechnique(0)->getPass(0);
      Ogre::TextureUnitState *tex_unit = NULL;
      if (pass->getNumTextureUnitStates() > 0) {
        tex_unit = pass->getTextureUnitState(0);
      } else {
        tex_unit = pass->createTextureUnitState();
      }

      //  only add if we have a texture for it
      tex = textureFromImage(tile.image(), "texture_" + name_suffix);

      ROS_INFO("Rendering with texture: %s", tex->getName().c_str());
      tex_unit->setTextureName(tex->getName());
      tex_unit->setTextureFiltering(Ogre::TFO_BILINEAR);

      //  create an object
      const std::string obj_name = "object_" + name_suffix;
      Ogre::ManualObject *obj = scene_manager_->createManualObject(obj_name);
      scene_node_->attachObject(obj);

      //  configure depth & alpha properties
      if (alpha_ >= 0.9998) {
        material->setDepthWriteEnabled(!draw_under_);
        material->setSceneBlending(Ogre::SBT_REPLACE);
      } else {
        material->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
        material->setDepthWriteEnabled(false);
      }

      if (draw_under_) {
        obj->setRenderQueueGroup(Ogre::RENDER_QUEUE_4);
      } else {
        obj->setRenderQueueGroup(Ogre::RENDER_QUEUE_MAIN);
      }

      tex_unit->setAlphaOperation(Ogre::LBX_SOURCE1, Ogre::LBS_MANUAL,
                                  Ogre::LBS_CURRENT, alpha_);

      //  create a quad for this tile
      obj->begin(material->getName(), Ogre::RenderOperation::OT_TRIANGLE_LIST);

      //  bottom left
      obj->position(x, y, 0.0f);
      obj->textureCoord(0.0f, 0.0f);
      obj->normal(0.0f, 0.0f, 1.0f);

      // top right
      obj->position(x + tileW, y + tileH, 0.0f);
      obj->textureCoord(1.0f, 1.0f);
      obj->normal(0.0f, 0.0f, 1.0f);

      // top left
      obj->position(x, y + tileH, 0.0f);
//.........这里部分代码省略.........
开发者ID:Exchizz,项目名称:rviz_satellite,代码行数:101,代码来源:aerialmap_display.cpp

示例15: 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())));
    }*/
}
开发者ID:WilliamCreber,项目名称:COMP3501_EOY_Project,代码行数:71,代码来源:ParticleFactory.cpp


注:本文中的ogre::ManualObject::textureCoord方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。