本文整理汇总了C++中GraphicsDevice::createVertexDeclaration方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsDevice::createVertexDeclaration方法的具体用法?C++ GraphicsDevice::createVertexDeclaration怎么用?C++ GraphicsDevice::createVertexDeclaration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsDevice
的用法示例。
在下文中一共展示了GraphicsDevice::createVertexDeclaration方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
void FBXModel::load(const GraphicsDevice& device, const std::string& filename, unsigned keyframes)
{
if (effect.resource == 0)
effect = Effect::createFromFile<FBXEffect>(device, Config::getValue(ConfigKeys::fbxEffectPath));
defaultTexture = Texture::createFromFile(device, defaultTexturePath);
vertexDeclaration = device.createVertexDeclaration(FBXInstance::vertexElements);
KFbxSdkManager* sdkManager = KFbxSdkManager::Create();
KFbxIOSettings* ios = KFbxIOSettings::Create(sdkManager, IOSROOT);
sdkManager->SetIOSettings(ios);
// Create an importer using our sdk manager.
KFbxImporter* importer = KFbxImporter::Create(sdkManager, "");
importer->Initialize(filename.c_str(), -1, sdkManager->GetIOSettings());
// Create a new scene so it can be populated by the imported file.
KFbxScene* scene = KFbxScene::Create(sdkManager, "");
// Import the contents of the file into the scene.
importer->Import(scene);
KFbxNode* rootBone = 0;
KFbxNode* rootNode = scene->GetRootNode();
KFbxAnimStack* animStack = KFbxCast<KFbxAnimStack>(scene->GetSrcObject(FBX_TYPE(KFbxAnimStack), 0));
KFbxAnimLayer* animLayer = 0;
if (animStack)
{
animLayer = animStack->GetMember(FBX_TYPE(KFbxAnimLayer), 0);
scene->GetEvaluator()->SetContext(animStack);
}
loadBones(rootNode, &rootBone, animLayer);
loadMeshes(rootNode, device, KFbxGeometryConverter(sdkManager));
if (animLayer)
{
for (unsigned i = 0; i <= keyframes; ++i)
boneMatricesMap[i] = traverseBones(i, rootBone, Matrix::identity, MatrixCollection(bones.size()));
}
sdkManager->Destroy();
loaded = true;
}
示例2: init
void TerrainTessellator::init(const GraphicsDevice& device, unsigned size, unsigned numPatches, unsigned stripeSize)
{
this->size = size;
this->stripeSize = stripeSize;
this->numPatches = numPatches;
numVertices = (size + 3) * (size + 3);
unsigned lod = (unsigned)MathHelper::log2(size) + 1;
patchIndexBuffers = IndexBufferCollection(lod);
skirtIndexBuffers = IndexBufferCollection(lod);
for (unsigned i = 0; i < lod; ++i)
{
patchIndexBuffers[i] = createPatchIndexBuffer(device, i);
skirtIndexBuffers[i] = createSkirtIndexBuffer(device, i);
}
VertexCollection vertices(numVertices);
for (int row = -1; row <= (int)size + 1; ++row)
for (int col = -1; col <= (int)size + 1; ++col)
{
int r = MathHelper::clamp(row, 0, (int)size);
int c = MathHelper::clamp(col, 0, (int)size);
float y = (r == row && c == col) ? 0.0f : -1.0f;
vertices[getIndex(row, col)].position = Vector3((float)c, y, (float)r);
}
vertexBuffer = device.createVertexBuffer(sizeof(TerrainVertex) * numVertices, TerrainVertex::fvf, D3DUSAGE_WRITEONLY);
vertexBuffer.setData(vertices);
instanceVertexDeclaration = device.createVertexDeclaration(TerrainGeometry::vertexElements);
}