本文整理汇总了C++中VertexElement类的典型用法代码示例。如果您正苦于以下问题:C++ VertexElement类的具体用法?C++ VertexElement怎么用?C++ VertexElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VertexElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: CreateVertexDeclation
VertexDeclaration DX::CreateVertexDeclation( VertexElements *ve )
{
LPDIRECT3DVERTEXDECLARATION9 decl = declMap[ve->description.c_str()];
if(decl)
return decl;
int size = ve->vertexElement.size();
D3DVERTEXELEMENT9 *elements = new D3DVERTEXELEMENT9[size + 1];
for(int i=0; i<size; ++i)
{
VertexElement *e = &ve->vertexElement[i];
e->GetD3DElemnts( &(elements[i]) );
}
//decl end
//D3DDECL_END()
elements[size].Stream = 0xFF;
elements[size].Offset = elements[size].Usage =
elements[size].UsageIndex = elements[size].Method = 0;
elements[size].Type = D3DDECLTYPE_UNUSED;
//DONE
if( SUCCEEDED(device->CreateVertexDeclaration(elements, &decl) ) )
{
SOCHashMap<const char *, LPDIRECT3DVERTEXDECLARATION9>::value_type value(ve->description.c_str(), decl);
declMap.insert(value);
}
return decl;
}
开发者ID:hsb0818,项目名称:SOC_Framework,代码行数:32,代码来源:DX.cpp
示例2: vertexElementLess
// Sort routine for VertexElement
bool vertexElementLess(const VertexElement& e1, const VertexElement& e2)
{
// Sort by source first
if (e1.getSource() < e2.getSource())
{
return true;
}
else if (e1.getSource() == e2.getSource())
{
// Use ordering of semantics to sort
if (e1.getSemantic() < e2.getSemantic())
{
return true;
}
else if (e1.getSemantic() == e2.getSemantic())
{
// Use index to sort
if (e1.getIndex() < e2.getIndex())
{
return true;
}
}
}
return false;
}
开发者ID:MrLobo,项目名称:El-Rayo-de-Zeus,代码行数:26,代码来源:main.cpp
示例3:
void G3djWriter::writeAttributes(Mesh * mesh){
if (mesh->getVertexCount() > 0 )
{
for(int i=0; i<mesh->getVertexElementCount(); i++){
if(i>0)
writer->nextValue(false);
VertexElement element = mesh->getVertexElement(i);
writer->writeString(element.usageStr(element.usage));
}
}
}
开发者ID:Lemoncog,项目名称:fbx-conv,代码行数:11,代码来源:G3djWriter.cpp
示例4:
uint32_t
VertexStream::id (const VertexElement& element)
{
uint32_t id = (1 << (element.usage() + 16));
if (element.usageIndex() >= 0)
{
id |= (1 << ((element.usageIndex()+1)));
}
//LOG ("Element Stream Id is " << id);
return id;
}
开发者ID:EiffelOberon,项目名称:IBLBaker,代码行数:12,代码来源:IblVertexStream.cpp
示例5: XMFLOAT3A
Mesh *LoadCM3DFile( char const *file )
{
int const nVertices = 3;
// DUMMY DATA ---------------------------------------------------------
// create vertices
XMFLOAT3A pos[nVertices];
pos[0] = XMFLOAT3A(0.0f, .5f, -1.0f);
pos[1] = XMFLOAT3A( -.5f, -.5f, -1.0f);
pos[2] = XMFLOAT3A(0.5f, -0.5f, -1.0f);
// colors
XMFLOAT4 colors[nVertices] =
{
XMFLOAT4(1, 1, 1, 1), XMFLOAT4(1, 0, 0, 1), XMFLOAT4(0, 0, 1, 1)
};
// 1) load mesh file
// 2) parse mesh file
// 3) mesh is made up of N subsets
// 4) for each subset:
// - get subset material
// - get subset geom info (vertex start, count, indices...)
// - create input element and add it to the mesh
// 5) load the shaders and create the input layout
// fill the Mesh object with geom data (positions, normals...) --------
(void)file;
Mesh *mesh = new Mesh(/*nVertices*/);
VertexElement *vePos = new VertexElement(sizeof(XMFLOAT3A), nVertices);
vePos->elementDesc.SemanticName = SemanticName::Position;
vePos->elementDesc.InputSlot = 0;
vePos->elementDesc.Format = DXGI_FORMAT_R32G32B32_FLOAT;
vePos->elementDesc.InputSlot = 0;
vePos->SetData((float *)pos);
VertexElement *veClr = new VertexElement(sizeof(XMFLOAT4), nVertices);
veClr->elementDesc.SemanticName = SemanticName::Color;
veClr->elementDesc.InputSlot = 0;
veClr->elementDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
veClr->elementDesc.InputSlot = 0;
veClr->elementDesc.AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
veClr->SetData((float *)colors);
mesh->AddVertexElement(vePos);
mesh->AddVertexElement(veClr);
//mesh->LoadToBuffers();
return mesh;
}
开发者ID:dotminic,项目名称:code,代码行数:51,代码来源:GeometryLoader.cpp
示例6: push_back
bool VertexDeclaration::push_back(const VertexElement& element)
{
if (has(element.usage())) return false;
_usageMask = _usageMask | vertexAttributeUsageMask(element.usage());
_totalSize += vertexAttributeTypeSize(element.type());
_list.push_back(element);
if (_interleaved)
{
for (auto& i : _list)
i.setStride(static_cast<int>(_totalSize));
}
return true;
}
开发者ID:celesius,项目名称:et-engine,代码行数:17,代码来源:vertexdeclaration.cpp
示例7: fill_ve_vec
void sefield::TetMesh::fill_ve_vec(set<VertexElement*> & veset, vector<VertexElement*> & vevec, queue<VertexElement*> & vequeue, uint ncons, VertexElement ** nbrs)
{
//cout << "Veset size: " << veset.size();
vector<uint>newindcs=std::vector<uint>();
for (uint i=0; i < ncons; ++i)
{
bool inserted = veset.insert(nbrs[i]).second;
if (inserted)
{
newindcs.push_back(i);
// This is the important one- in a vector to keep the ordering
vevec.push_back(nbrs[i]);
// And add to the queue too, to find their neighbours:
vequeue.push(nbrs[i]);
}
}
// Go to the next element in the queue
if (vequeue.empty() == true) return;
else
{
VertexElement * nextve = vequeue.front();
vequeue.pop();
VertexElement ** newneighbs = nextve->getNeighbours();
uint nextcons = nextve->getNCon();
fill_ve_vec(veset, vevec, vequeue, nextcons, newneighbs);
}
/*
for (uint i=0; i < newindcs.size(); ++i)
{
VertexElement ** newneighbs = nbrs[newindcs[i]]->getNeighbours();
uint newcons = nbrs[newindcs[i]]->getNCon();
fill_ve_vec(veset, vevec, newcons, newneighbs, false);
}
*/
}
开发者ID:delalond,项目名称:STEPS,代码行数:40,代码来源:tetmesh.cpp
示例8: setVertexAttribPointer
void RenderState::setVertexAttribPointer(const VertexElement& e, size_t baseIndex, bool force)
{
#if !defined(ET_CONSOLE_APPLICATION)
(void)force;
if (e.dataType() == DataType::Int)
{
glVertexAttribIPointer(GLuint(e.usage()), static_cast<GLint>(e.components()), dataTypeValue(e.dataType()),
e.stride(), reinterpret_cast<GLvoid*>(e.offset() + baseIndex));
}
else if (e.dataType() == DataType::Float)
{
glVertexAttribPointer(GLuint(e.usage()), static_cast<GLint>(e.components()), dataTypeValue(e.dataType()),
false, e.stride(), reinterpret_cast<GLvoid*>(e.offset() + baseIndex));
}
else
{
ET_FAIL("Unhandled vertex attribute data type.");
}
checkOpenGLError("glVertexAttribPointer");
#endif
}
开发者ID:sergeyreznik,项目名称:et-engine,代码行数:23,代码来源:renderstate.cpp
示例9:
bool
VertexElement::operator != (const VertexElement &src) const
{
if (_usageIndex != src.usageIndex())
return true;
if (_usage != src.usage())
return true;
if (_method != src.method())
return true;
if (_type != src.type())
return true;
if (_offset != src.offset())
return true;
if (_stream != src.stream())
return true;
return false;
}
开发者ID:EiffelOberon,项目名称:IBLBaker,代码行数:18,代码来源:IblVertexElement.cpp
示例10: rebuild
void VertexDeclaration::rebuild()
{
mHash = 0;
int nTexCoord = 0;
int nElem = 0;
int nVB = mParent->vertexBufferCount();
for (int v = 0; v<nVB; ++v) {
VertexBuffer* vb = mParent->vertexBuffer(v);
if (vb) {
nElem += vb->vertexElementCount();
}
}
delete[] mElements;
mElements = TD_NEW D3D11_INPUT_ELEMENT_DESC[nElem];
int eIdx = 0;
for (int v = 0; v<nVB; ++v) {
VertexBuffer* vb = mParent->vertexBuffer(v);
if (vb) {
int offset = 0;
int nVbElem = vb->vertexElementCount();
for (int e = 0; e<nVbElem; ++e)
{
VertexElement* ve = vb->vertexElement(e);
D3D11_INPUT_ELEMENT_DESC& elem = mElements[eIdx];
elem.SemanticName = s_SemanticNameLUT[ve->mUsage];
elem.SemanticIndex = (BYTE)ve->mIndex;
elem.Format = makeD3D11Type(ve->mType, ve->mCount);
elem.AlignedByteOffset = (WORD)offset;
elem.InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
elem.InputSlot = v;
elem.InstanceDataStepRate = 0;
offset += ve->size();
++eIdx;
// while we at this, create the hash (bitmask) that identifies this vertex structure
if (ve->mUsage == VEU_TEXCOORD)
nTexCoord++;
int mask = 0;
if (ve->mUsage != VEU_UNKNOWN) {
mask = 1 << ve->mUsage;
}
mHash |= mask;
}
}
}
// add the number of texcoords (if any) to the hash
mHash |= (nTexCoord << 16);
// release any existing declaration object
mLayout.Reset();
// it seems pretty ugly from a dependency perspective, but D3D11 forces us to have an
// existing vertex shader in order to make a vertex declaration (input format), so we
// need to fetch one that matches the submesh (or face the warnings that the D3D runtime
// will spew at us)
VertexShader* vs = static_cast<VertexShader*>(ShaderManager::instance().createOrFindInstanceOf(mParent));
// create the vertex declaration
HRESULT hr = mDevice->CreateInputLayout(
mElements,
nElem,
vs->bytecode(),
vs->bytecodeLength(),
&mLayout
);
if (FAILED(hr)) {
throw Exception("Failed to (re)build vertex input layout in VertexDeclaration::rebuild");
}
}
开发者ID:nbtdev,项目名称:teardrop,代码行数:80,代码来源:VertexDeclarationD3D11.cpp
示例11: generateFlatNormals
//--------------------------------------------------------------------
Status MeshManager::mLoad(std::shared_ptr<Mesh> mesh, const std::string &sid,
std::vector<glm::vec3> &positions,
std::vector<glm::vec2> &uvs,
std::vector<glm::vec3> &flatNormals,
std::vector<VertexIndices> &vertexIndices) const {
bool hasUv, hasFlat, hasSmooth;
hasUv = !uvs.empty();
if (!hasUv) {
Log::trace(TAG, "no UV mapping found for mesh \"%s\"", sid.c_str());
}
hasFlat = !flatNormals.empty();
if (!hasFlat) {
Log::trace(TAG, "no Flat normal mapping found for mesh \"%s\"", sid.c_str());
}
// generates normals
std::vector<glm::vec3> smoothNormals;
if (!hasFlat) {
generateFlatNormals(flatNormals, positions, vertexIndices);
}
generateSmoothNormals(smoothNormals, flatNormals, positions, vertexIndices, hasFlat);
hasSmooth = true; //TODO metadata
if(!hasFlat) { //TODO handle it with metadata
flatNormals.clear(); //no need from there
}
std::vector<U16> indices;
std::vector<Vertex> vertices;
// map one Vertex object to one or many VertexIndices
std::map<VertexIndices, U16> indexMap;
U16 currentVertexIndex = 0;
//create Vertex objects out of VertexIndices.
for (const VertexIndices& vi : vertexIndices) {
// if Vertex object of this indices doesn't exist already
if (indexMap.find(vi) == indexMap.end()) {
//create it & refer to it.
indexMap[vi] = currentVertexIndex;
indices.push_back(currentVertexIndex);
currentVertexIndex++;
Vertex v;
v.setPosition(positions[vi.p]);
if (hasUv) {
v.setUv(uvs[vi.uv]);
}
if (hasFlat) {
v.setFlatNormal(flatNormals[vi.fn]);
}
if (hasSmooth) {
v.setSmoothNormal(smoothNormals[vi.sn]);
}
vertices.push_back(v);
} else {
indices.push_back(indexMap[vi]);
}
}
U32 vertexSize = 0;
U32 vertexCount = (U32) vertices.size();
//Positions
VertexElement positionElement(VertexElement::Semantic::POSITION, 3, GL_FLOAT, vertexSize);
vertexSize += positionElement.getSizeInByte();
mesh->addVertexElement(positionElement);
//Normals
if (hasFlat) {
VertexElement flatNormalElement(VertexElement::Semantic::FLAT_NORMAL, 3, GL_FLOAT, vertexSize);
vertexSize += flatNormalElement.getSizeInByte();
mesh->addVertexElement(flatNormalElement);
}
if (hasSmooth) {
VertexElement smoothNormalElement(VertexElement::Semantic::SMOOTH_NORMAL, 3, GL_FLOAT, vertexSize);
vertexSize += smoothNormalElement.getSizeInByte();
mesh->addVertexElement(smoothNormalElement);
}
// UVs
if (hasUv) {
VertexElement uvElement(VertexElement::Semantic::UV, 2, GL_FLOAT, vertexSize);
vertexSize += uvElement.getSizeInByte();
mesh->addVertexElement(uvElement);
}
mesh->mVertexSize = vertexSize;
mesh->mVertexCount = vertexCount;
//Log::debug(TAG, "vertexSize=%d vertexCount=%d", vertexSize, vertexCount);
//Log::debug(TAG, "indices=%d", indices.size());
BYTE* data = new BYTE[vertexSize * vertexCount];
/////////////////////////////////////////////////////////////////////////
// Generate vertex buffer
//.........这里部分代码省略.........
开发者ID:e-biz,项目名称:arpi-gl,代码行数:101,代码来源:MeshManager.cpp
示例12: addVertexElement
//------------------------------------------------------------------------------
void Mesh::addVertexElement(const VertexElement& vertexElement) {
mVertexElements[vertexElement.getSemantic()] = vertexElement;
mVertexSemFlags |= (1L << vertexElement.getSemantic());
}
开发者ID:e-biz,项目名称:arpi-gl,代码行数:5,代码来源:Mesh.cpp
示例13: add
void VertexDeclaration::add( const VertexElement& element ) {
_stride += element.getSize();
_elements.push_back(element);
}
开发者ID:KasumiL5x,项目名称:ciri,代码行数:4,代码来源:VertexDeclaration.cpp
示例14: LOG
void*
StreamedMesh::internalStreamPtr()
{
if (vertexBufferSize() == 0)
{
LOG ("Error, internal vertex buffer size is 0");
return 0;
}
if (!_vertexBufferCpuMemory)
{
_vertexBufferCpuMemory = (float*)malloc(sizeof(float)*vertexBufferSize());
}
// stash the buffer and put it in an array
std::map <uint32_t, float*> streamMap;
for (auto it = _vertexStreams.begin();
it != _vertexStreams.end();
it++)
{
streamMap.insert (std::make_pair(it->first, it->second->stream()));
}
const std::vector <VertexElement>& declaration = _vertexDeclaration->getDeclaration();
float* vb = (float*)_vertexBufferCpuMemory;
for (uint32_t i = 0; i < vertexCount(); i++)
{
for (uint32_t j = 0; j < declaration.size()-1; j++)
{
VertexElement element = declaration[j];
VertexStream* stream = 0;
if (findStream (stream, element))
{
uint32_t streamId = VertexStream::id(*stream);
auto streamIt = streamMap.find(streamId);
if (streamIt != streamMap.end() &&
streamIt->second)
{
for (uint32_t k = 0; k < stream->stride(); k++)
{
*vb++ = streamIt->second[k];
}
streamIt->second += stream->stride();
}
else
{
uint32_t stride = IVertexDeclaration::elementToSize(element.type());
for (uint32_t k = 0; k < stride; stride++)
{
*vb++ = 0;
}
}
}
else
{
// can't find a stream for this element.
// warn user, and 0 the buffer for the stride size
uint32_t stride = IVertexDeclaration::elementToSize(element.type());
for (uint32_t k = 0; k < stride; stride++)
{
*vb++ = 0;
}
}
}
}
return _vertexBufferCpuMemory;
}
开发者ID:EiffelOberon,项目名称:IBLBaker,代码行数:71,代码来源:IblStreamedMesh.cpp
示例15: sizeof
void sefield::TetMesh::axisOrderElements(uint opt_method, std::string const & opt_file_name)
{
// Now this method provides a choice between Stefan and Robert's method
// and the new method by Iain. The original method is fast and suffices for
// simple geometries, Iain's method is superior and important for complex
// geometries, but slow.
if (opt_file_name != "")
{
std::fstream opt_file;
opt_file.open(opt_file_name.c_str(),
std::fstream::in | std::fstream::binary);
opt_file.seekg(0);
uint nelems = 0;
opt_file.read((char*)&nelems, sizeof(uint));
if (pElements.size() != nelems) {
std::ostringstream os;
os << "optimal data mismatch with simulator parameters: sefield::Tetmesh::nelems, ";
os << nelems << ":" << pElements.size();
throw steps::ArgErr(os.str());
}
opt_file.read((char*)pVertexPerm, sizeof(uint) * nelems);
VertexElementPVec elements_temp = pElements;
for (uint vidx = 0; vidx < nelems; ++vidx)
{
VertexElementP vep = elements_temp[vidx];
// sanity check
assert(vep->getIDX() == vidx);
uint new_idx = pVertexPerm[vidx];
pElements[new_idx] = vep;
}
reindexElements();
reordered();
opt_file.close();
return;
}
if (opt_method == 2)
{
// / / / / / / / / / / / / / / NEW / / / / / / / / / / / / / / / / / / //
// LOOPING OVER ALL VERTICES, APPLYING THE WALK METHOD AND FINDING WHICH
// STARTING VERTEX GIVES THE LOWEST MATRIX WIDTH.
uint pNVerts = pElements.size();
// the best vertex(narrowest width)
uint bestone = 0;
uint bestwidth = pNVerts;
std::vector<VertexElement*> orig_indices = pElements;
stringstream ss;
ss << "\nFinding optimal vertex indexing. This can take some time...";
cout << ss.str() << endl;
for (uint vidx = 0; vidx < pNVerts; ++vidx)
{
set<VertexElement*> verteleset = set<VertexElement*>();
vector<VertexElement*> vertelevec = vector<VertexElement*>();
queue<VertexElement*> vertelqueue = queue<VertexElement*>();
verteleset.insert(orig_indices[vidx]);
vertelevec.push_back(orig_indices[vidx]);
uint ve0ncons = orig_indices[vidx]->getNCon();
VertexElement ** ve0neighbs = orig_indices[vidx]->getNeighbours();
fill_ve_vec(verteleset, vertelevec, vertelqueue, ve0ncons, ve0neighbs);
pElements.clear();
vector<VertexElement*>::iterator vertele_end = vertelevec.end();
uint ielt = 0;
for (vector<VertexElement*>::iterator vertele = vertelevec.begin(); vertele != vertele_end; ++vertele)
{
pElements.push_back(*vertele);
pVertexPerm[(*vertele)->getIDX()]=ielt;
ielt++;
}
// Note: this will reorder the vertex indices as we go- not a problem in this loop
// but they must be reset for the final index setting to work
reindexElements();
uint maxdi = 0;
for (int iv = 0; iv < pNVerts; ++iv)
{
VertexElement* ve = getVertex(iv);
int ind = ve->getIDX();
for (int i = 0; i < ve->getNCon(); ++i)
{
int inbr = ve->nbrIdx(i);
//.........这里部分代码省略.........
开发者ID:delalond,项目名称:STEPS,代码行数:101,代码来源:tetmesh.cpp
注:本文中的VertexElement类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论