本文整理汇总了C++中SubMesh::InitIndexData方法的典型用法代码示例。如果您正苦于以下问题:C++ SubMesh::InitIndexData方法的具体用法?C++ SubMesh::InitIndexData怎么用?C++ SubMesh::InitIndexData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SubMesh
的用法示例。
在下文中一共展示了SubMesh::InitIndexData方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreatePlaneMesh
//------------------------------------------------------------------------------------
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;
}
示例2: _InitMesh
//------------------------------------------------------------------------------------
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);
}
示例3: ARRAYSIZE
//----------------------------------------------------------------------------------------
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;
}
}
示例4: Entity
//------------------------------------------------------------------------------------
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;
}
示例5: Init
//------------------------------------------------------------------------------------
bool SceneManager::Init()
{
m_camera = new Camera;
m_camera->SetAspectRatio(m_pRenderSystem->GetWndWidth() / (float)m_pRenderSystem->GetWndHeight());
m_sunLight.lightDir.Set(1, -1, 2);
m_sunLight.lightDir.Normalize();
m_sunLight.lightColor.Set(0.8f, 0.8f, 0.8f);
m_pSSAO = new SSAO;
{
m_pDebugRTMesh = new Mesh;
SubMesh* pSubMesh = new SubMesh;
SVertex v[4] =
{
SVertex(VEC3(0.5f,1.0f,0), VEC2(0,0)),
SVertex(VEC3(1.0f,1.0f,0), VEC2(1,0)),
SVertex(VEC3(0.5f,0.4f,0), VEC2(0,1)),
SVertex(VEC3(1.0f,0.4f,0), VEC2(1,1))
};
DWORD index[6] = { 0,1,2, 1,3,2 };
pSubMesh->InitVertData(eVertexType_General, v, ARRAYSIZE(v), true);
pSubMesh->InitIndexData(index, ARRAYSIZE(index), true);
m_pDebugRTMesh->AddSubMesh(pSubMesh);
m_pDebugRTMaterial = new Material;
m_pDebugRTMaterial->InitShader(GetResPath("DebugRT.hlsl"), GetResPath("DebugRT.hlsl"));
pSubMesh->SetMaterial(m_pDebugRTMaterial);
}
_InitAllScene();
return true;
}
示例6: _InitWaterMesh
//------------------------------------------------------------------------------------
void Water::_InitWaterMesh(float waterHeight)
{
m_waterPlane.Set(VEC3::UNIT_Y, waterHeight);
// Construct terrain likely grids
const int vertsPerSide = 151, cellSpace = 200;
const float dimension = (vertsPerSide - 1.0f) * cellSpace;
const float halfDim = dimension / 2;
float uvInc = 1.0f / (vertsPerSide - 1);
int nVerts = vertsPerSide * vertsPerSide;
int nIndex = (vertsPerSide - 1) * (vertsPerSide - 1) * 2 * 3;
SVertex* vert = new SVertex[nVerts];
DWORD* pIndices = new DWORD[nIndex];
if(!vert || !pIndices)
throw std::exception("Error!Not enough memory!");
float posZ = -halfDim;
for (int z=0; z<vertsPerSide; ++z)
{
float posX = -halfDim;
for (int x=0; x<vertsPerSide; ++x)
{
int idx = z*vertsPerSide+x;
vert[idx].pos.Set(posX, m_waterPlane.d, posZ);
vert[idx].uv.Set(x*uvInc, z*uvInc);
posX += cellSpace;
}
posZ += cellSpace;
}
int idx = 0;
for (int z=0; z<vertsPerSide-1; ++z)
{
for (int x=0; x<vertsPerSide-1; ++x)
{
pIndices[idx + 0] = z * vertsPerSide + x;
pIndices[idx + 1] = (z + 1) * vertsPerSide + x;
pIndices[idx + 2] = (z + 1) * vertsPerSide + x + 1;
pIndices[idx + 3] = (z + 1) * vertsPerSide + x + 1;
pIndices[idx + 4] = z * vertsPerSide + x + 1;
pIndices[idx + 5] = z * vertsPerSide + x;
idx += 6;
}
}
m_waterMesh = new Mesh;
SubMesh* pSubMesh = new SubMesh;
m_waterMesh->AddSubMesh(pSubMesh);
pSubMesh->InitVertData(eVertexType_General, vert, nVerts, true);
pSubMesh->InitIndexData(pIndices, nIndex, true);
SAFE_DELETE_ARRAY(vert);
SAFE_DELETE_ARRAY(pIndices);
m_pEntity = new Entity(m_waterMesh);
m_pEntity->SetCastShadow(false);
m_pEntity->SetReceiveShadow(false);
}
示例7: CreateFrustumMesh
//------------------------------------------------------------------------------------
Mesh* SceneManager::CreateFrustumMesh( const VEC3& minBottom, const VEC3& maxBottom, const VEC3& minTop, const VEC3& maxTop )
{
Neo::SVertex vert[24];
// front side
vert[0].pos.Set(minBottom.x, minBottom.y, maxBottom.z);
vert[0].uv.Set(0, 1);
vert[1].pos.Set(maxBottom.x, minBottom.y, maxBottom.z);
vert[1].uv.Set(1, 1);
vert[2].pos.Set(maxTop.x, minTop.y, maxTop.z);
vert[2].uv.Set(1, 0);
vert[3].pos.Set(minTop.x, minTop.y, maxTop.z);
vert[3].uv.Set(0, 0);
// back side
vert[4].pos.Set(maxBottom.x, minBottom.y, minBottom.z);
vert[4].uv.Set(0, 1);
vert[5].pos.Set(minBottom.x, minBottom.y, minBottom.z);
vert[5].uv.Set(1, 1);
vert[6].pos.Set(minTop.x, minTop.y, minTop.z);
vert[6].uv.Set(1, 0);
vert[7].pos.Set(maxTop.x, minTop.y, minTop.z);
vert[7].uv.Set(0, 0);
// left side
vert[8].pos.Set(minBottom.x, minBottom.y, minBottom.z);
vert[9].pos.Set(minBottom.x, minBottom.y, maxBottom.z);
vert[10].pos.Set(minTop.x, minTop.y, maxTop.z);
vert[11].pos.Set(minTop.x, minTop.y, minTop.z);
vert[8].uv.Set(0, 1);
vert[9].uv.Set(1, 1);
vert[10].uv.Set(1, 0);
vert[11].uv.Set(0, 0);
// right side
vert[12].pos.Set(maxBottom.x, minBottom.y, maxBottom.z);
vert[13].pos.Set(maxBottom.x, minBottom.y, minBottom.z);
vert[14].pos.Set(maxTop.x, minTop.y, minTop.z);
vert[15].pos.Set(maxTop.x, minTop.y, maxTop.z);
vert[12].uv.Set(0, 1);
vert[13].uv.Set(1, 1);
vert[14].uv.Set(1, 0);
vert[15].uv.Set(0, 0);
// up side
vert[16].pos.Set(minTop.x, minTop.y, maxTop.z);
vert[17].pos.Set(maxTop.x, minTop.y, maxTop.z);
vert[18].pos.Set(maxTop.x, minTop.y, minTop.z);
vert[19].pos.Set(minTop.x, minTop.y, minTop.z);
vert[16].uv.Set(0, 1);
vert[17].uv.Set(1, 1);
vert[18].uv.Set(1, 0);
vert[19].uv.Set(0, 0);
// down side
vert[20].pos.Set(minBottom.x, minBottom.y, minBottom.z);
vert[21].pos.Set(maxBottom.x, minBottom.y, minBottom.z);
vert[22].pos.Set(maxBottom.x, minBottom.y, maxBottom.z);
vert[23].pos.Set(minBottom.x, minBottom.y, maxBottom.z);
vert[20].uv.Set(0, 1);
vert[21].uv.Set(1, 1);
vert[22].uv.Set(1, 0);
vert[23].uv.Set(0, 0);
DWORD faces[6*2*3] = {
// front
0,1,2,
0,2,3,
// back
4,5,6,
4,6,7,
// left
8,9,10,
8,10,11,
// right
12,13,14,
12,14,15,
// up
16,17,18,
16,18,19,
// down
20,21,22,
20,22,23
};
Mesh* pMesh = new Mesh;
SubMesh* pSubmesh = new SubMesh;
pSubmesh->InitVertData(eVertexType_General, vert, 24, true);
pSubmesh->InitIndexData(faces, 6*2*3, true);
pMesh->AddSubMesh(pSubmesh);
return pMesh;
//.........这里部分代码省略.........
示例8: CreateCubeMesh
//.........这里部分代码省略.........
vert[3].uv.Set(0, 0);
vert[0].normal = vert[1].normal = vert[2].normal = vert[3].normal = VEC3::UNIT_Z;
// back side
vert[4].pos.Set(maxPt.x, minPt.y, minPt.z);
vert[4].uv.Set(0, 1);
vert[5].pos.Set(minPt.x, minPt.y, minPt.z);
vert[5].uv.Set(1, 1);
vert[6].pos.Set(minPt.x, maxPt.y, minPt.z);
vert[6].uv.Set(1, 0);
vert[7].pos.Set(maxPt.x, maxPt.y, minPt.z);
vert[7].uv.Set(0, 0);
vert[4].normal = vert[5].normal = vert[6].normal = vert[7].normal = VEC3::NEG_UNIT_Z;
// left side
vert[8].pos.Set(minPt.x, minPt.y, minPt.z);
vert[9].pos.Set(minPt.x, minPt.y, maxPt.z);
vert[10].pos.Set(minPt.x, maxPt.y, maxPt.z);
vert[11].pos.Set(minPt.x, maxPt.y, minPt.z);
vert[8].uv.Set(0, 1);
vert[9].uv.Set(1, 1);
vert[10].uv.Set(1, 0);
vert[11].uv.Set(0, 0);
vert[8].normal = vert[9].normal = vert[10].normal = vert[11].normal = VEC3::NEG_UNIT_X;
// right side
vert[12].pos.Set(maxPt.x, minPt.y, maxPt.z);
vert[13].pos.Set(maxPt.x, minPt.y, minPt.z);
vert[14].pos.Set(maxPt.x, maxPt.y, minPt.z);
vert[15].pos.Set(maxPt.x, maxPt.y, maxPt.z);
vert[12].uv.Set(0, 1);
vert[13].uv.Set(1, 1);
vert[14].uv.Set(1, 0);
vert[15].uv.Set(0, 0);
vert[12].normal = vert[13].normal = vert[14].normal = vert[15].normal = VEC3::UNIT_X;
// up side
vert[16].pos.Set(minPt.x, maxPt.y, maxPt.z);
vert[17].pos.Set(maxPt.x, maxPt.y, maxPt.z);
vert[18].pos.Set(maxPt.x, maxPt.y, minPt.z);
vert[19].pos.Set(minPt.x, maxPt.y, minPt.z);
vert[16].uv.Set(0, 1);
vert[17].uv.Set(1, 1);
vert[18].uv.Set(1, 0);
vert[19].uv.Set(0, 0);
vert[16].normal = vert[17].normal = vert[18].normal = vert[19].normal = VEC3::UNIT_Y;
// down side
vert[20].pos.Set(minPt.x, minPt.y, minPt.z);
vert[21].pos.Set(maxPt.x, minPt.y, minPt.z);
vert[22].pos.Set(maxPt.x, minPt.y, maxPt.z);
vert[23].pos.Set(minPt.x, minPt.y, maxPt.z);
vert[20].uv.Set(0, 1);
vert[21].uv.Set(1, 1);
vert[22].uv.Set(1, 0);
vert[23].uv.Set(0, 0);
vert[20].normal = vert[21].normal = vert[22].normal = vert[23].normal = VEC3::NEG_UNIT_Y;
DWORD faces[6*2*3] = {
// front
0,1,2,
0,2,3,
// back
4,5,6,
4,6,7,
// left
8,9,10,
8,10,11,
// right
12,13,14,
12,14,15,
// up
16,17,18,
16,18,19,
// down
20,21,22,
20,22,23
};
Mesh* pCube = new Mesh;
SubMesh* pSubmesh = new SubMesh;
pSubmesh->InitVertData(eVertexType_General, vert, 24, true);
pSubmesh->InitIndexData(faces, 6*2*3, true);
pCube->AddSubMesh(pSubmesh);
return pCube;
}