本文整理汇总了C++中Surface::SetEffect方法的典型用法代码示例。如果您正苦于以下问题:C++ Surface::SetEffect方法的具体用法?C++ Surface::SetEffect怎么用?C++ Surface::SetEffect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Surface
的用法示例。
在下文中一共展示了Surface::SetEffect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FillData
void FBXFactory::FillData(ModelData* someData, Model* outData, Effect* aEffect)
{
VertexIndexWrapper* indexWrapper = new VertexIndexWrapper();
indexWrapper->myFormat = DXGI_FORMAT_R32_UINT;
unsigned int* indexData = new unsigned int[someData->myIndexCount];
memcpy(indexData, someData->myIndicies, someData->myIndexCount*sizeof(unsigned int));
indexWrapper->myIndexData = (char*)indexData;
indexWrapper->mySize = someData->myIndexCount*sizeof(unsigned int);
outData->myIndexBaseData = indexWrapper;
VertexDataWrapper* vertexData = new VertexDataWrapper();
someData->myVertexBuffer;
int sizeOfBuffer = someData->myVertexCount*someData->myVertexStride*sizeof(float);
char* vertexRawData = new char[sizeOfBuffer];
memcpy(vertexRawData, someData->myVertexBuffer, sizeOfBuffer);
vertexData->myVertexData = vertexRawData;
vertexData->myNumberOfVertices = someData->myVertexCount;
vertexData->mySize = sizeOfBuffer;
vertexData->myStride = someData->myVertexStride*sizeof(float);
outData->myVertexBaseData = vertexData;
for (int i = 0; i < someData->myLayout.Size(); ++i)
{
auto currentLayout = someData->myLayout[i];
D3D11_INPUT_ELEMENT_DESC* desc = new D3D11_INPUT_ELEMENT_DESC();
desc->SemanticIndex = 0;
desc->AlignedByteOffset = currentLayout.myOffset;
desc->InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
desc->InputSlot = 0;
desc->InstanceDataStepRate = 0;
if (currentLayout.myType == ModelData::VERTEX_POS)
{
desc->SemanticName = "POSITION";
desc->Format = DXGI_FORMAT_R32G32B32_FLOAT;
}
else if (currentLayout.myType == ModelData::VERTEX_NORMAL)
{
desc->SemanticName = "NORMAL";
desc->Format = DXGI_FORMAT_R32G32B32_FLOAT;
}
else if (currentLayout.myType == ModelData::VERTEX_UV)
{
desc->SemanticName = "TEXCOORD";
desc->Format = DXGI_FORMAT_R32G32_FLOAT;
}
else if (currentLayout.myType == ModelData::VERTEX_BINORMAL)
{
desc->SemanticName = "BINORMAL";
desc->Format = DXGI_FORMAT_R32G32B32_FLOAT;
}
else if (currentLayout.myType == ModelData::VERTEX_TANGENT)
{
desc->SemanticName = "TANGENT";
desc->Format = DXGI_FORMAT_R32G32B32_FLOAT;
}
else if (currentLayout.myType == ModelData::VERTEX_SKINWEIGHTS)
{
break;
desc->SemanticName = "WEIGHTS";
desc->Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
}
else if (currentLayout.myType == ModelData::VERTEX_BONEID)
{
break;
desc->SemanticName = "BONES";
desc->Format = DXGI_FORMAT_R32G32B32A32_SINT;
}
outData->myVertexFormat.Add(desc);
}
outData->myIsNULLObject = false;
Surface surface;
surface.SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
surface.SetIndexCount(someData->myIndexCount);
surface.SetVertexStart(0);
surface.SetIndexStart(0);
surface.SetVertexCount(someData->myVertexCount);
surface.SetEffect(aEffect);
bool useSRGB = true;
for (unsigned int i = 0; i < someData->myTextures.size(); ++i)
{
auto& currentTexture = someData->myTextures[i];
std::string resourceName;
if (currentTexture.myType == DIFFUSE)
{
resourceName = "DiffuseTexture";
}
if (currentTexture.myType == NORMALMAP)
{
resourceName = "NormalTexture";
useSRGB = false;
}
if (currentTexture.myType == ROUGHNESS)
{
resourceName = "RoughnessTexture";
}
if (currentTexture.myType == SUBSTANCE)
//.........这里部分代码省略.........
示例2: InitCube
//.........这里部分代码省略.........
myVertices.Add({ { 1.0f, -1.0f, 1.0f }, { 0.f, -1.f, 0.f }, { 1.0f, 1.0f } });
myVertices.Add({ { -1.0f, -1.0f, 1.0f }, { 0.f, -1.f, 0.f }, { 0.0f, 1.0f } });
//8 - 11 (Left)
myVertices.Add({ { -1.0f, -1.0f, 1.0f }, { -1.f, 0.f, 0.f }, { 0.0f, 0.0f } });
myVertices.Add({ { -1.0f, -1.0f, -1.0f }, { -1.f, 0.f, 0.f }, { 1.0f, 0.0f } });
myVertices.Add({ { -1.0f, 1.0f, -1.0f }, { -1.f, 0.f, 0.f }, { 1.0f, 1.0f } });
myVertices.Add({ { -1.0f, 1.0f, 1.0f }, { -1.f, 0.f, 0.f }, { 0.0f, 1.0f } });
//12 - 15 (Right)
myVertices.Add({ { 1.0f, -1.0f, 1.0f }, { 1.f, 0.f, 0.f }, { 0.0f, 0.0f } });
myVertices.Add({ { 1.0f, -1.0f, -1.0f }, { 1.f, 0.f, 0.f }, { 1.0f, 0.0f } });
myVertices.Add({ { 1.0f, 1.0f, -1.0f }, { 1.f, 0.f, 0.f }, { 1.0f, 1.0f } });
myVertices.Add({ { 1.0f, 1.0f, 1.0f }, { 1.f, 0.f, 0.f }, { 0.0f, 1.0f } });
//16 - 19 (Front)
myVertices.Add({ { -1.0f, -1.0f, -1.0f }, { 0.f, 0.f, -1.f }, { 0.0f, 0.0f } });
myVertices.Add({ { 1.0f, -1.0f, -1.0f }, { 0.f, 0.f, -1.f }, { 1.0f, 0.0f } });
myVertices.Add({ { 1.0f, 1.0f, -1.0f }, { 0.f, 0.f, -1.f }, { 1.0f, 1.0f } });
myVertices.Add({ { -1.0f, 1.0f, -1.0f }, { 0.f, 0.f, -1.f }, { 0.0f, 1.0f } });
//20 - 23 (Back)
myVertices.Add({ { -1.0f, -1.0f, 1.0f }, { 0.f, 0.f, 1.f }, { 0.0f, 0.0f } });
myVertices.Add({ { 1.0f, -1.0f, 1.0f }, { 0.f, 0.f, 1.f }, { 1.0f, 0.0f } });
myVertices.Add({ { 1.0f, 1.0f, 1.0f }, { 0.f, 0.f, 1.f }, { 1.0f, 1.0f } });
myVertices.Add({ { -1.0f, 1.0f, 1.0f }, { 0.f, 0.f, 1.f }, { 0.0f, 1.0f } });
#pragma region Indices
//Top
myVerticeIndices.Add(3);
myVerticeIndices.Add(1);
myVerticeIndices.Add(0);
myVerticeIndices.Add(2);
myVerticeIndices.Add(1);
myVerticeIndices.Add(3);
//Bottom
myVerticeIndices.Add(6);
myVerticeIndices.Add(4);
myVerticeIndices.Add(5);
myVerticeIndices.Add(7);
myVerticeIndices.Add(4);
myVerticeIndices.Add(6);
//Left
myVerticeIndices.Add(11);
myVerticeIndices.Add(9);
myVerticeIndices.Add(8);
myVerticeIndices.Add(10);
myVerticeIndices.Add(9);
myVerticeIndices.Add(11);
//Right
myVerticeIndices.Add(14);
myVerticeIndices.Add(12);
myVerticeIndices.Add(13);
myVerticeIndices.Add(15);
myVerticeIndices.Add(12);
myVerticeIndices.Add(14);
//Front
myVerticeIndices.Add(19);
myVerticeIndices.Add(17);
myVerticeIndices.Add(16);
myVerticeIndices.Add(18);
myVerticeIndices.Add(17);
myVerticeIndices.Add(19);
//Back
myVerticeIndices.Add(22);
myVerticeIndices.Add(20);
myVerticeIndices.Add(21);
myVerticeIndices.Add(23);
myVerticeIndices.Add(20);
myVerticeIndices.Add(22);
#pragma endregion
InitBuffers(VertexType::POS_NORM_UV);
Surface surf;
surf.SetEffect(myEffect);
surf.SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
surf.SetVertexStart(0);
surf.SetVertexCount(myVertices.Size());
surf.SetIndexStart(0);
surf.SetIndexCount(myVerticeIndices.Size());
surf.SetTexture("DiffuseTexture", "Data/resources/texture/seafloor.dds", true);
mySurfaces.Add(surf);
}