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


C++ SubMesh类代码示例

本文整理汇总了C++中SubMesh的典型用法代码示例。如果您正苦于以下问题:C++ SubMesh类的具体用法?C++ SubMesh怎么用?C++ SubMesh使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: SetMaterial

	bool Model::SetMaterial(const String& subMeshName, Material* material)
	{
		SubMesh* subMesh = m_mesh->GetSubMesh(subMeshName);
		if (!subMesh)
		{
			NazaraError("Mesh has no submesh \"" + subMeshName + '"');
			return false;
		}

		unsigned int matIndex = subMesh->GetMaterialIndex();
		if (matIndex >= m_matCount)
		{
			NazaraError("Material index out of range (" + String::Number(matIndex) + " >= " + String::Number(m_matCount) + ')');
			return false;
		}

		unsigned int index = m_skin * m_matCount + matIndex;

		if (material)
			m_materials[index] = material;
		else
			m_materials[index] = Material::GetDefault();

		return true;
	}
开发者ID:Ilearn32,项目名称:NazaraEngine,代码行数:25,代码来源:Model.cpp

示例2: updateSkinning

void FixedRenderer::updateSkinning(Mesh * mesh, Armature * armature)
{
	unsigned int s;
	unsigned int sSize = mesh->getSubMeshsNumber();
	for(s=0; s<sSize; s++)
	{
		SubMesh * subMesh = &mesh->getSubMeshs()[s];

		// data
		Vector3 * vertices = subMesh->getVertices();

		if(! vertices)
			continue;

		SkinData * skinData = subMesh->getSkinData();
		if(armature && skinData)
		{
			unsigned int verticesSize = subMesh->getVerticesSize();
			Vector3 * skinVertices = getVertices(verticesSize);

			computeSkinning(armature, skinData, vertices, NULL, NULL, skinVertices, NULL, NULL);
			subMesh->getBoundingBox()->initFromPoints(skinVertices, verticesSize);
		}
	}

	mesh->updateBoundingBox();
}
开发者ID:joewan,项目名称:NeoEditor,代码行数:27,代码来源:FixedRenderer.cpp

示例3: SVertex

	//------------------------------------------------------------------------------------
	Mesh* SceneManager::CreatePlaneMesh( float w, float h )
	{
		float halfW = w / 2;
		float halfH = h / 2;

		SVertex vert[4] =
		{
			SVertex(VEC3(-w,0,+h), VEC2(0,0), VEC3::UNIT_Y),
			SVertex(VEC3(+w,0,+h), VEC2(1,0), VEC3::UNIT_Y),
			SVertex(VEC3(+w,0,-h), VEC2(1,1), VEC3::UNIT_Y),
			SVertex(VEC3(-w,0,-h), VEC2(0,1), VEC3::UNIT_Y),
		};

		DWORD dwIndex[6] = {0,1,3,1,2,3};

		Mesh* pMesh =  new Mesh;
		SubMesh* pSubmesh = new SubMesh;

		pSubmesh->InitVertData(eVertexType_General, vert, 4, true);
		pSubmesh->InitIndexData(dwIndex, 6, true);

		pMesh->AddSubMesh(pSubmesh);

		return pMesh;
	}
开发者ID:whztt07,项目名称:NeoEngine,代码行数:26,代码来源:SceneManager.cpp

示例4: NazaraError

	bool Model::SetMaterial(unsigned int skinIndex, const String& subMeshName, Material* material)
	{
		#if NAZARA_GRAPHICS_SAFE
		if (skinIndex >= m_skinCount)
		{
			NazaraError("Skin index out of range (" + String::Number(skinIndex) + " >= " + String::Number(m_skinCount));
			return false;
		}
		#endif

		SubMesh* subMesh = m_mesh->GetSubMesh(subMeshName);
		if (!subMesh)
		{
			NazaraError("Mesh has no submesh \"" + subMeshName + '"');
			return false;
		}

		unsigned int matIndex = subMesh->GetMaterialIndex();
		if (matIndex >= m_matCount)
		{
			NazaraError("Material index out of range (" + String::Number(matIndex) + " >= " + String::Number(m_matCount));
			return false;
		}

		unsigned int index = skinIndex * m_matCount + matIndex;

		if (material)
			m_materials[index] = material;
		else
			m_materials[index] = Material::GetDefault();

		return true;
	}
开发者ID:Ilearn32,项目名称:NazaraEngine,代码行数:33,代码来源:Model.cpp

示例5: SAFE_DELETE_ARRAY

	//------------------------------------------------------------------------------------
	void Sky::_InitMesh()
	{
		SVertex* vert = new SVertex[8];
		DWORD* pIndices = new DWORD[6*2*3];

		if(!vert || !pIndices)
			throw std::exception("Error!Not enough memory!");

		vert[0].pos.Set(-1, -1, -1);
		vert[1].pos.Set( 1, -1, -1);
		vert[2].pos.Set( 1, -1, 1);
		vert[3].pos.Set(-1, -1, 1);
		vert[4].pos.Set(-1, 1, -1);
		vert[5].pos.Set( 1, 1, -1);
		vert[6].pos.Set( 1, 1, 1);
		vert[7].pos.Set(-1, 1, 1);

		pIndices[0] = 0; pIndices[1] = 2; pIndices[2] = 1;
		pIndices[3] = 0; pIndices[4] = 3; pIndices[5] = 2;
		pIndices[6] = 5; pIndices[7] = 7; pIndices[8] = 4;
		pIndices[9] = 5; pIndices[10] = 6; pIndices[11] = 7;
		pIndices[12] = 3; pIndices[13] = 6; pIndices[14] = 2;
		pIndices[15] = 3; pIndices[16] = 7; pIndices[17] = 6;
		pIndices[18] = 1; pIndices[19] = 4; pIndices[20] = 0;
		pIndices[21] = 1; pIndices[22] = 5; pIndices[23] = 4;
		pIndices[24] = 0; pIndices[25] = 7; pIndices[26] = 3;
		pIndices[27] = 0; pIndices[28] = 4; pIndices[29] = 7;
		pIndices[30] = 2; pIndices[31] = 5; pIndices[32] = 1;
		pIndices[33] = 2; pIndices[34] = 6; pIndices[35] = 5;

		m_pMesh = new Mesh;
		SubMesh* pSubMesh = new SubMesh;

		pSubMesh->InitVertData(eVertexType_General, vert, 8, true);
		pSubMesh->InitIndexData(pIndices, 6*2*3, true);

		m_pMesh->AddSubMesh(pSubMesh);

		SAFE_DELETE_ARRAY(vert);
		SAFE_DELETE_ARRAY(pIndices);

		Neo::Material* pMaterial = new Neo::Material;
		pMaterial->SetTexture(0, new Neo::D3D11Texture(GetResPath("Skybox.dds"), eTextureType_CubeMap));
		pMaterial->InitShader(GetResPath("Sky.hlsl"), GetResPath("Sky.hlsl"), eShaderFlag_EnableClipPlane);

		pSubMesh->SetMaterial(pMaterial);
		pMaterial->Release();

		D3D11_SAMPLER_DESC& sampler = pMaterial->GetSamplerStateDesc(0);
		sampler.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
		sampler.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
		
		pMaterial->SetSamplerStateDesc(0, sampler);

		m_pEntity = new Entity(m_pMesh);

		m_pEntity->SetCastShadow(false);
		m_pEntity->SetReceiveShadow(false);
	}
开发者ID:whztt07,项目名称:NeoEngine,代码行数:60,代码来源:Sky.cpp

示例6: addSubMesh

 SubMesh *addSubMesh(GLenum mode, size_t first, size_t count)
 {
     SubMesh *res = addSubMesh();
     res->setMode(mode);
     res->setFirstIndex(first);
     res->setIndexCount(count);
     return res;
 }
开发者ID:ronsaldo,项目名称:graphics-demos,代码行数:8,代码来源:Mesh.hpp

示例7: getVertexDataRecord

	//------------------------------------------------------------------------------------
	void TerrainQuadTreeNode::CreateEntity()
	{
		// Create the entity.
		if (isRenderedAtCurrentLod() && !mEntity)
		{
			Mesh* pMesh = new Mesh;
			SubMesh* pSubmesh = new SubMesh;

			pMesh->SetPrimitiveType(ePrimitive_TriangleStrip);
			pSubmesh->InitTerrainVertData(getVertexDataRecord()->gpuPosVertexBuf, getVertexDataRecord()->gpuDeltaVertexBuf,
				mLodLevels[mCurrentLod]->pIndexBuf, mLodLevels[mCurrentLod]->nIndexCount);

			pMesh->AddSubMesh(pSubmesh);
			mEntity = new Entity(pMesh);
			mEntity->SetCastShadow(false);

			// vertex data is generated in terrain space
			mEntity->SetPosition(mTerrain->getPosition());

			static uint32 iMat = 0;
			++iMat;
			char szMatName[64];
			sprintf_s(szMatName, 64, "Mtl_TerrainSector_%d", iMat);

			Material* pMaterial = MaterialManager::GetSingleton().NewMaterial(szMatName, eVertexType_Terrain);

			pMaterial->SetTexture(0, mTerrain->getTerrainNormalMap());
			pMaterial->SetTexture(1, mTerrain->getLayerBlendTexture(0));

			SSamplerDesc& samDesc = pMaterial->GetSamplerStateDesc(0);
			samDesc.AddressU = eTextureAddressMode_WRAP;
			samDesc.AddressV = eTextureAddressMode_WRAP;
			samDesc.Filter = SF_MIN_MAG_MIP_LINEAR;
			pMaterial->SetSamplerStateDesc(0, samDesc);
			pMaterial->SetSamplerStateDesc(1, samDesc);

			for (uint32 i = 0; i < mTerrain->getLayerCount(); ++i)
			{
				pMaterial->SetTexture(2+i*2, g_env.pRenderer->GetRenderSys()->LoadTexture(mTerrain->getLayerTextureName(i, 0), eTextureType_2D, 0, true));
				pMaterial->SetTexture(2+i*2+1, g_env.pRenderer->GetRenderSys()->LoadTexture(mTerrain->getLayerTextureName(i, 1)));

				pMaterial->SetSamplerStateDesc(2 + i * 2, samDesc);
				pMaterial->SetSamplerStateDesc(2 + i * 2 + 1, samDesc);
			}

			pMaterial->InitShader("Terrain", eShader_Terrain, 0, nullptr, "VS_GBuffer", "PS_GBuffer");
			mEntity->SetMaterial(pMaterial);
		}

		if (mChildren[0])
		{
			mChildren[0]->CreateEntity();
			mChildren[1]->CreateEntity();
			mChildren[2]->CreateEntity();
			mChildren[3]->CreateEntity();
		}
	}
开发者ID:mavaL,项目名称:NeoEngine,代码行数:58,代码来源:TerrainQuadTreeNode.cpp

示例8: ushort

//-----------------------------------------------------------------------
bool HardwareSkinningFactory::extractSkeletonData(const Entity* pEntity, size_t subEntityIndex, ushort& boneCount, ushort& weightCount)
{
    bool isValidData = false;
    boneCount = 0;
    weightCount = 0;

    //Check if we have pose animation which the HS sub render state does not 
    //know how to handle
    bool hasVertexAnim = pEntity->getMesh()->hasVertexAnimation();

    //gather data on the skeleton
    if (!hasVertexAnim && pEntity->hasSkeleton())
    {
        //get weights count
        MeshPtr pMesh = pEntity->getMesh();

        RenderOperation ro;
        SubMesh* pSubMesh = pMesh->getSubMesh(subEntityIndex);
        pSubMesh->_getRenderOperation(ro,0);

        //get the largest bone assignment
        boneCount = ushort(std::max(pMesh->sharedBlendIndexToBoneIndexMap.size(), pSubMesh->blendIndexToBoneIndexMap.size()));
            
        //go over vertex deceleration 
        //check that they have blend indices and blend weights
        const VertexElement* pDeclWeights = ro.vertexData->vertexDeclaration->findElementBySemantic(VES_BLEND_WEIGHTS,0);
        const VertexElement* pDeclIndexes = ro.vertexData->vertexDeclaration->findElementBySemantic(VES_BLEND_INDICES,0);
        if ((pDeclWeights != NULL) && (pDeclIndexes != NULL))
        {
            isValidData = true;
            switch (pDeclWeights->getType())
            {
            case VET_FLOAT1:
                weightCount = 1;
                break;
            case VET_USHORT2_NORM:
            case VET_FLOAT2:
                weightCount = 2;
                break;
            case VET_FLOAT3:
                weightCount = 3;
                break;
            case VET_USHORT4_NORM:
            case VET_UBYTE4_NORM:
            case VET_FLOAT4:
                weightCount = 4;
                break;
            default:
                isValidData = false;
                break;
            }
        }
    }
    return isValidData;
}
开发者ID:terakuran,项目名称:ogre,代码行数:56,代码来源:OgreShaderExHardwareSkinning.cpp

示例9: _update

	void PS_Mesh::_update(Particle * p)
	{
		Float3 Position = p->Position;
		if (mParent->IsLocalSpace())
			Position.TransformA(mParent->GetParent()->GetWorldTM());

		mMesh->SetPosition(Position);
		mMesh->SetOpacity(p->Color.a);
		mMesh->SetRotationEx(p->Rotation);
		mMesh->SetScale(p->Size);
		mMesh->_updateTM();

		int blendMode = mParent->GetBlendMode();

		for (int i = 0; i < mMesh->GetSubMeshCount(); ++i)
		{
			SubMesh * submesh = mMesh->GetSubMesh(i);
			Material * mtl = submesh->GetMaterial();
			
			mtl->diffuse = Float3(p->Color.r, p->Color.g, p->Color.b);
			if (mParent->_getTexture() != NULL)
			{
				mtl->maps[eMapType::DIFFUSE] = mParent->_getTexture();
			}

			if (mParent->GetShaderEnable())
			{
				mtl->depthMode = eDepthMode::N_LESS_EQUAL;

				if (blendMode == PS_BlendMode::ADD)
				{
					mtl->blendMode = eBlendMode::ADD;
				}
				else if (blendMode == PS_BlendMode::ALPHA_BLEND)
				{
					mtl->blendMode = eBlendMode::ALPHA_BLEND;
				}
				else if (blendMode == PS_BlendMode::COLOR_BLEND)
				{
					mtl->blendMode = eBlendMode::COLOR_BLEND;
				}
				else
				{
					mtl->blendMode = eBlendMode::OPACITY;
					mtl->depthMode = eDepthMode::LESS_EQUAL;
				}

				submesh->SetShaderFX(mParent->_getShaderFX());
				submesh->SetRenderCallBack(eRenderCallBack::SHADER, mParent->GetShader().c_ptr());
			}
		}
	}
开发者ID:MSoft1115,项目名称:Rad3D,代码行数:52,代码来源:PSMesh.cpp

示例10: SVertex

	//----------------------------------------------------------------------------------------
	D3D11RenderTarget::D3D11RenderTarget()
	:m_pRenderSystem(g_env.pRenderSystem)
	,m_pRenderTexture(nullptr)
	,m_clearColor(SColor::BLACK)
	,m_bClearColor(true)
	,m_bClearZBuffer(true)
	,m_bHasDepthBuffer(false)
	,m_bNoFrameBuffer(false)
	,m_bUpdateRatioAspect(true)
	,m_phaseFlag(eRenderPhase_Geometry)
	,m_pDepthStencil(nullptr)
	,m_sizeRatio(0, 0)
	{
		// Create screen quad
		static bool bCreate = false;
		if (!bCreate)
		{
			m_pQuadMesh = new Mesh;
			SubMesh* pSubMesh = new SubMesh;

			SVertex v[4] = 
			{
				SVertex(VEC3(-1,1,0), VEC2(0,0)),
				SVertex(VEC3(1,1,0), VEC2(1,0)),
				SVertex(VEC3(-1,-1,0), VEC2(0,1)),
				SVertex(VEC3(1,-1,0), VEC2(1,1))
			};
			DWORD index[6] = { 0,1,2, 1,3,2 };

			// Store index to frustum far corner
			v[0].normal.x = 0;
			v[1].normal.x = 1;
			v[2].normal.x = 2;
			v[3].normal.x = 3;

			pSubMesh->InitVertData(eVertexType_General, v, ARRAYSIZE(v), true);
			pSubMesh->InitIndexData(index, ARRAYSIZE(index), true);

			m_pQuadMesh->AddSubMesh(pSubMesh);

			m_pQuadEntity = new Entity(m_pQuadMesh);

			m_pQuadEntity->SetCastShadow(false);
			m_pQuadEntity->SetReceiveShadow(false);

			bCreate = true;
		}
	}
开发者ID:whztt07,项目名称:NeoEngine,代码行数:49,代码来源:D3D11RenderTarget.cpp

示例11: SubEntity

//-----------------------------------------------------------------------
void Entity::buildSubEntityList(Mesh* mesh, SubEntityList* sublist) {
  // Create SubEntities
  int i, numSubMeshes;
  SubMesh* subMesh;
  SubEntity* subEnt;

  numSubMeshes = mesh->getNumSubMeshes();
  for (i = 0; i < numSubMeshes; ++i) {
    subMesh = mesh->getSubMesh(i);
    subEnt = new SubEntity();
    subEnt->mParentEntity = this;
    subEnt->mSubMesh = subMesh;
    if (subMesh->isMatInitialised())
      subEnt->setMaterialName(subMesh->getMaterialName());
    sublist->push_back(subEnt);
  }
}
开发者ID:zgpxgame,项目名称:iEngine,代码行数:18,代码来源:Entity.cpp

示例12: m_vPos

	//------------------------------------------------------------------------------------
	Decal::Decal(const VEC3& pos, float size, const QUATERNION& rot)
		: m_vPos(pos)
		, m_fSize(size)
		, m_pMaterial(nullptr)
	{
		if (!m_pUnitCube)
		{
			SVertex vert[8] =
			{
				SVertex(VEC3(-0.5f, -0.5f, +0.5f), VEC2(0, 0)),
				SVertex(VEC3(+0.5f, -0.5f, +0.5f), VEC2(0, 0)),
				SVertex(VEC3(+0.5f, -0.5f, -0.5f), VEC2(0, 0)),
				SVertex(VEC3(-0.5f, -0.5f, -0.5f), VEC2(0, 0)),
				SVertex(VEC3(-0.5f, +0.5f, +0.5f), VEC2(0, 0)),
				SVertex(VEC3(+0.5f, +0.5f, +0.5f), VEC2(0, 0)),
				SVertex(VEC3(+0.5f, +0.5f, -0.5f), VEC2(0, 0)),
				SVertex(VEC3(-0.5f, +0.5f, -0.5f), VEC2(0, 0)),
			};

			DWORD dwIndex[36] = {
				0,2,1,0,3,2,		// bottom
				4,5,7,5,6,7,		// top
				4,7,0,7,3,0,		// left
				6,5,2,5,1,2,		// right
				7,6,3,6,2,3,		// behind
				5,4,1,4,0,1,		// front
			};

			Mesh* pMesh = new Mesh;
			SubMesh* pSubmesh = new SubMesh;

			pSubmesh->InitVertData(eVertexType_General, vert, 8, true);
			pSubmesh->InitIndexData(dwIndex, 36, true);

			pMesh->AddSubMesh(pSubmesh);

			m_pUnitCube = new Entity(pMesh);
			m_pUnitCube->SetCastShadow(false);

			m_pCB_Decal = g_env.pRenderer->GetRenderSys()->CreateConstantBuffer(sizeof(cBufferDecal), 10);
		}

		m_cbDecal.matRotation = rot.ToRotationMatrix().Transpose();
		m_cbDecal.fProjClip = 10000.f;
	}
开发者ID:mavaL,项目名称:NeoEngine,代码行数:46,代码来源:Decal.cpp

示例13: fi

bool Mesh::load(const std::string& fname)
{
    std::ifstream fi(fname.c_str());
    assert(fi);
    int subCnt = 0;
    {
        StreamBlockReader r("MeshDescription", fi);
        if (!r.read("subCount", &subCnt)) assert(0);
    }
    while (subCnt-- > 0) {
        SubMesh *sub = new SubMesh();
        fi >> *sub;
        sub->genVertexNormals();
        sub->genTriangleNormals();
        addSubMesh(sub);
    }
    m_fname = fname;
    return !!fi;
}
开发者ID:GHScan,项目名称:DailyProjects,代码行数:19,代码来源:Mesh.cpp

示例14: retrieve

	void EtoileMeshPassTextureInputSocket::retrieve(Texture* signal)
	{
		if(signal == NULL) return;
		GLMeshRenderPass* plugin = (GLMeshRenderPass*)(this->getNode());
		std::vector<RenderUnit*>& units = plugin->getRenderUnits();
		for(unsigned int i = 0; i < units.size(); ++i)
		{
			RenderUnit* unit = units[i];
			MeshRenderUnit* munit = dynamic_cast<MeshRenderUnit*>(unit);
			if(munit != NULL)
			{
				Mesh* m = munit->getMesh();
				for(unsigned int j = 0; j < m->getSubMeshList().size(); ++j)
				{
					SubMesh* submesh = m->getSubMeshList()[j];
					Material* mt = submesh->getMaterial();
					mt->removeTexture(this->getName());
				}
			}
		}
	}
开发者ID:billhj,项目名称:Etoile,代码行数:21,代码来源:EtoileGLMeshRenderPassPlugin.cpp

示例15: Mesh

RenderViewer::RenderViewer()
{
	mLayout = new MGUI::Layout(NULL, NULL);
	mTextBox = new MGUI::TextBox(NULL, mLayout);
	mTextBox->SetAlign(MGUI::eAlign::LEFT | MGUI::eAlign::BOTTOM);

	// create grid mesh
	mGridMesh = new Mesh();
	SubMesh * pMeshBuffer = mGridMesh->NewSubMesh();

	pMeshBuffer->GetRenderOp()->vertexDeclarations[0].AddElement(eVertexSemantic::POSITION, eVertexType::FLOAT2);

	pMeshBuffer->GetRenderOp()->vertexBuffers[0] = HWBufferManager::Instance()->NewVertexBuffer(2 * sizeof(float), (GRID_SIZE + 1) * 2 * 2);

	int index = 0;
	float * data = (float *)pMeshBuffer->GetRenderOp()->vertexBuffers[0]->Lock(eLockFlag::WRITE);
	{
		float _s = -GRID_SIZE / 2 * METER_LEN;
		float _e = GRID_SIZE / 2 * METER_LEN;

		float y = _s;
		float dy = METER_LEN;
		for (int i = 0; i < GRID_SIZE + 1; ++i)
		{
			data[index++] = _s; data[index++] = y;
			data[index++] = _e; data[index++] = y;

			y += dy;
		}

		float x = _s;
		float dx = METER_LEN;
		for (int i = 0; i < GRID_SIZE + 1; ++i)
		{
			data[index++] = x; data[index++] = _s;
			data[index++] = x; data[index++] = _e;

			x += dx;
		}
	}
	pMeshBuffer->GetRenderOp()->vertexBuffers[0]->Unlock();

	pMeshBuffer->GetRenderOp()->primCount = (GRID_SIZE + 1) * 2;
	pMeshBuffer->GetRenderOp()->primType = ePrimType::LINE_LIST;

	ShaderFX * pShaderFX = ShaderFXManager::Instance()->Load("Grid", "Grid.mfx");
	d_assert(pShaderFX != NULL);
	pMeshBuffer->SetShaderFX(pShaderFX);

	mGridMesh->SetLocalAabb(Aabb::Infinite);

	Layout();

	World::Instance()->E_RenderEnd += new cListener0<RenderViewer>(this, &RenderViewer::OnUpdate);
}
开发者ID:MSoft1115,项目名称:Rad3D,代码行数:55,代码来源:RenderViewer.cpp


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