本文整理汇总了C++中bgfx::VertexDecl::getStride方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexDecl::getStride方法的具体用法?C++ VertexDecl::getStride怎么用?C++ VertexDecl::getStride使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bgfx::VertexDecl
的用法示例。
在下文中一共展示了VertexDecl::getStride方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
void Model::create(const bgfx::VertexDecl& def,
Material* material,
const int* indices_data,
int indices_size,
const void* attributes_data,
int attributes_size)
{
m_geometry_buffer_object.setAttributesData(
attributes_data, attributes_size, def);
m_geometry_buffer_object.setIndicesData(indices_data, indices_size);
m_meshes.emplace(def,
material,
0,
attributes_size,
0,
indices_size / sizeof(int),
"default",
m_allocator);
Model::LOD lod;
lod.m_distance = FLT_MAX;
lod.m_from_mesh = 0;
lod.m_to_mesh = 0;
m_lods.push(lod);
m_indices.resize(indices_size / sizeof(m_indices[0]));
memcpy(&m_indices[0], indices_data, indices_size);
m_vertices.resize(attributes_size / def.getStride());
computeRuntimeData((const uint8_t*)attributes_data);
onReady();
}
示例2: write
void write(bx::WriterI* _writer, const uint8_t* _vertices, uint32_t _numVertices, const bgfx::VertexDecl& _decl, const uint16_t* _indices, uint32_t _numIndices, const std::string& _material, const PrimitiveArray& _primitives)
{
uint32_t stride = _decl.getStride();
bx::write(_writer, BGFX_CHUNK_MAGIC_VB);
writeBounds(_writer, _vertices, _numVertices, stride);
bx::write(_writer, _decl);
bx::write(_writer, uint16_t(_numVertices) );
bx::write(_writer, _vertices, _numVertices*stride);
bx::write(_writer, BGFX_CHUNK_MAGIC_IB);
bx::write(_writer, _numIndices);
bx::write(_writer, _indices, _numIndices*2);
bx::write(_writer, BGFX_CHUNK_MAGIC_PRI);
uint16_t nameLen = uint16_t(_material.size() );
bx::write(_writer, nameLen);
bx::write(_writer, _material.c_str(), nameLen);
bx::write(_writer, uint16_t(_primitives.size() ) );
for (PrimitiveArray::const_iterator primIt = _primitives.begin(); primIt != _primitives.end(); ++primIt)
{
const Primitive& prim = *primIt;
nameLen = uint16_t(prim.m_name.size() );
bx::write(_writer, nameLen);
bx::write(_writer, prim.m_name.c_str(), nameLen);
bx::write(_writer, prim.m_startIndex);
bx::write(_writer, prim.m_numIndices);
bx::write(_writer, prim.m_startVertex);
bx::write(_writer, prim.m_numVertices);
writeBounds(_writer, &_vertices[prim.m_startVertex*stride], prim.m_numVertices, stride);
}
}
示例3: create
void Model::create(const bgfx::VertexDecl& def,
Material* material,
const int* indices_data,
int indices_size,
const void* attributes_data,
int attributes_size)
{
ASSERT(!bgfx::isValid(m_vertices_handle));
m_vertices_handle = bgfx::createVertexBuffer(bgfx::copy(attributes_data, attributes_size), def);
m_vertices_size = attributes_size;
ASSERT(!bgfx::isValid(m_indices_handle));
auto* mem = bgfx::copy(indices_data, indices_size);
m_indices_handle = bgfx::createIndexBuffer(mem, BGFX_BUFFER_INDEX32);
m_indices_size = indices_size;
m_meshes.emplace(def,
material,
0,
attributes_size,
0,
indices_size / int(sizeof(int)),
"default",
m_allocator);
Model::LOD lod;
lod.m_distance = FLT_MAX;
lod.m_from_mesh = 0;
lod.m_to_mesh = 0;
m_lods.push(lod);
m_indices.resize(indices_size / sizeof(m_indices[0]));
copyMemory(&m_indices[0], indices_data, indices_size);
m_vertices.resize(attributes_size / def.getStride());
computeRuntimeData((const uint8*)attributes_data);
onCreated(State::READY);
}
示例4: load
void load(const void* _vertices, uint32_t _numVertices, const bgfx::VertexDecl _decl, const uint16_t* _indices, uint32_t _numIndices)
{
Group group;
const bgfx::Memory* mem;
uint32_t size;
size = _numVertices*_decl.getStride();
mem = bgfx::makeRef(_vertices, size);
group.m_vbh = bgfx::createVertexBuffer(mem, _decl);
size = _numIndices*2;
mem = bgfx::makeRef(_indices, size);
group.m_ibh = bgfx::createIndexBuffer(mem);
//TODO:
// group.m_sphere = ...
// group.m_aabb = ...
// group.m_obb = ...
// group.m_prims = ...
m_groups.push_back(group);
}
示例5: parseMeshesOld
bool Model::parseMeshesOld(bgfx::VertexDecl global_vertex_decl, FS::IFile& file, FileVersion version, u32 global_flags)
{
int object_count = 0;
file.read(&object_count, sizeof(object_count));
if (object_count <= 0) return false;
m_meshes.reserve(object_count);
char model_dir[MAX_PATH_LENGTH];
PathUtils::getDir(model_dir, MAX_PATH_LENGTH, getPath().c_str());
struct Offsets
{
i32 attribute_array_offset;
i32 attribute_array_size;
i32 indices_offset;
i32 mesh_tri_count;
};
Array<Offsets> mesh_offsets(m_allocator);
for (int i = 0; i < object_count; ++i)
{
i32 str_size;
file.read(&str_size, sizeof(str_size));
char material_name[MAX_PATH_LENGTH];
file.read(material_name, str_size);
if (str_size >= MAX_PATH_LENGTH) return false;
material_name[str_size] = 0;
char material_path[MAX_PATH_LENGTH];
copyString(material_path, model_dir);
catString(material_path, material_name);
catString(material_path, ".mat");
auto* material_manager = m_resource_manager.getOwner().get(Material::TYPE);
Material* material = static_cast<Material*>(material_manager->load(Path(material_path)));
Offsets& offsets = mesh_offsets.emplace();
file.read(&offsets.attribute_array_offset, sizeof(offsets.attribute_array_offset));
file.read(&offsets.attribute_array_size, sizeof(offsets.attribute_array_size));
file.read(&offsets.indices_offset, sizeof(offsets.indices_offset));
file.read(&offsets.mesh_tri_count, sizeof(offsets.mesh_tri_count));
file.read(&str_size, sizeof(str_size));
if (str_size >= MAX_PATH_LENGTH)
{
material_manager->unload(*material);
return false;
}
char mesh_name[MAX_PATH_LENGTH];
mesh_name[str_size] = 0;
file.read(mesh_name, str_size);
bgfx::VertexDecl vertex_decl = global_vertex_decl;
if (version <= FileVersion::SINGLE_VERTEX_DECL)
{
parseVertexDecl(file, &vertex_decl);
if (i != 0 && global_vertex_decl.m_hash != vertex_decl.m_hash)
{
g_log_error.log("Renderer") << "Model " << getPath().c_str()
<< " contains meshes with different vertex declarations.";
}
if(i == 0) global_vertex_decl = vertex_decl;
}
m_meshes.emplace(material,
vertex_decl,
mesh_name,
m_allocator);
addDependency(*material);
}
i32 indices_count = 0;
file.read(&indices_count, sizeof(indices_count));
if (indices_count <= 0) return false;
u32 INDICES_16BIT_FLAG = 1;
int index_size = global_flags & INDICES_16BIT_FLAG ? 2 : 4;
Array<u8> indices(m_allocator);
indices.resize(indices_count * index_size);
file.read(&indices[0], indices.size());
i32 vertices_size = 0;
file.read(&vertices_size, sizeof(vertices_size));
if (vertices_size <= 0) return false;
Array<u8> vertices(m_allocator);
vertices.resize(vertices_size);
file.read(&vertices[0], vertices.size());
int vertex_count = 0;
for (const Offsets& offsets : mesh_offsets)
{
vertex_count += offsets.attribute_array_size / global_vertex_decl.getStride();
}
if (version > FileVersion::BOUNDING_SHAPES_PRECOMPUTED)
{
file.read(&m_bounding_radius, sizeof(m_bounding_radius));
file.read(&m_aabb, sizeof(m_aabb));
//.........这里部分代码省略.........