2012-07-01 12:38:14 +00:00
|
|
|
/*
|
|
|
|
Open Asset Import Library (assimp)
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
2020-01-20 13:53:12 +00:00
|
|
|
Copyright (c) 2006-2020, assimp team
|
2018-01-28 18:42:05 +00:00
|
|
|
|
2017-05-09 17:57:36 +00:00
|
|
|
|
2012-07-01 12:38:14 +00:00
|
|
|
All rights reserved.
|
|
|
|
|
2015-05-19 03:52:10 +00:00
|
|
|
Redistribution and use of this software in source and binary forms,
|
|
|
|
with or without modification, are permitted provided that the
|
2012-07-01 12:38:14 +00:00
|
|
|
following conditions are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer.
|
|
|
|
|
|
|
|
* Redistributions in binary form must reproduce the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer in the documentation and/or other
|
|
|
|
materials provided with the distribution.
|
|
|
|
|
|
|
|
* Neither the name of the assimp team, nor the names of its
|
|
|
|
contributors may be used to endorse or promote products
|
|
|
|
derived from this software without specific prior
|
|
|
|
written permission of the assimp team.
|
|
|
|
|
2015-05-19 03:52:10 +00:00
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
2012-07-01 12:38:14 +00:00
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
2015-05-19 03:52:10 +00:00
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
2012-07-01 12:38:14 +00:00
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
2015-05-19 03:52:10 +00:00
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
2012-07-01 12:38:14 +00:00
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
2015-05-19 03:52:10 +00:00
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
2012-07-01 12:38:14 +00:00
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @file FBXMeshGeometry.cpp
|
2012-07-02 13:57:51 +00:00
|
|
|
* @brief Assimp::FBX::MeshGeometry implementation
|
2012-07-01 12:38:14 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ASSIMP_BUILD_NO_FBX_IMPORTER
|
|
|
|
|
2013-01-19 16:00:14 +00:00
|
|
|
#include <functional>
|
|
|
|
|
2016-03-03 14:19:38 +00:00
|
|
|
#include "FBXMeshGeometry.h"
|
2012-07-01 12:38:14 +00:00
|
|
|
#include "FBXDocument.h"
|
|
|
|
#include "FBXImporter.h"
|
|
|
|
#include "FBXImportSettings.h"
|
|
|
|
#include "FBXDocumentUtil.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace Assimp {
|
|
|
|
namespace FBX {
|
|
|
|
|
2016-03-03 14:19:38 +00:00
|
|
|
using namespace Util;
|
2012-07-26 17:13:19 +00:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Geometry::Geometry(uint64_t id, const Element& element, const std::string& name, const Document& doc)
|
2019-01-06 18:37:30 +00:00
|
|
|
: Object(id, element, name)
|
2015-05-19 03:57:13 +00:00
|
|
|
, skin()
|
2012-07-26 17:13:19 +00:00
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID(),"Deformer");
|
2016-04-05 20:53:54 +00:00
|
|
|
for(const Connection* con : conns) {
|
2015-05-19 03:57:13 +00:00
|
|
|
const Skin* const sk = ProcessSimpleConnection<Skin>(*con, false, "Skin -> Geometry", element);
|
|
|
|
if(sk) {
|
|
|
|
skin = sk;
|
2019-01-06 18:37:30 +00:00
|
|
|
}
|
|
|
|
const BlendShape* const bsp = ProcessSimpleConnection<BlendShape>(*con, false, "BlendShape -> Geometry", element);
|
|
|
|
if (bsp) {
|
|
|
|
blendShapes.push_back(bsp);
|
2015-05-19 03:57:13 +00:00
|
|
|
}
|
|
|
|
}
|
2012-07-26 17:13:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Geometry::~Geometry()
|
|
|
|
{
|
2018-03-22 21:14:10 +00:00
|
|
|
// empty
|
2012-07-26 17:13:19 +00:00
|
|
|
}
|
|
|
|
|
2019-01-06 18:37:30 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const std::vector<const BlendShape*>& Geometry::GetBlendShapes() const {
|
|
|
|
return blendShapes;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-03 14:19:38 +00:00
|
|
|
const Skin* Geometry::DeformerSkin() const {
|
|
|
|
return skin;
|
|
|
|
}
|
2012-07-26 17:13:19 +00:00
|
|
|
|
2012-07-01 12:38:14 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2012-07-04 13:07:57 +00:00
|
|
|
MeshGeometry::MeshGeometry(uint64_t id, const Element& element, const std::string& name, const Document& doc)
|
2012-07-26 17:13:19 +00:00
|
|
|
: Geometry(id, element,name, doc)
|
2012-07-01 12:38:14 +00:00
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
const Scope* sc = element.Compound();
|
|
|
|
if (!sc) {
|
|
|
|
DOMError("failed to read Geometry object (class: Mesh), no data scope found");
|
|
|
|
}
|
|
|
|
|
|
|
|
// must have Mesh elements:
|
|
|
|
const Element& Vertices = GetRequiredElement(*sc,"Vertices",&element);
|
|
|
|
const Element& PolygonVertexIndex = GetRequiredElement(*sc,"PolygonVertexIndex",&element);
|
|
|
|
|
|
|
|
// optional Mesh elements:
|
|
|
|
const ElementCollection& Layer = sc->GetCollection("Layer");
|
|
|
|
|
|
|
|
std::vector<aiVector3D> tempVerts;
|
|
|
|
ParseVectorDataArray(tempVerts,Vertices);
|
|
|
|
|
|
|
|
if(tempVerts.empty()) {
|
|
|
|
FBXImporter::LogWarn("encountered mesh with no vertices");
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<int> tempFaces;
|
|
|
|
ParseVectorDataArray(tempFaces,PolygonVertexIndex);
|
|
|
|
|
|
|
|
if(tempFaces.empty()) {
|
|
|
|
FBXImporter::LogWarn("encountered mesh with no faces");
|
|
|
|
}
|
|
|
|
|
2016-09-28 14:16:06 +00:00
|
|
|
m_vertices.reserve(tempFaces.size());
|
|
|
|
m_faces.reserve(tempFaces.size() / 3);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
2016-09-28 14:16:06 +00:00
|
|
|
m_mapping_offsets.resize(tempVerts.size());
|
|
|
|
m_mapping_counts.resize(tempVerts.size(),0);
|
|
|
|
m_mappings.resize(tempFaces.size());
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
const size_t vertex_count = tempVerts.size();
|
|
|
|
|
|
|
|
// generate output vertices, computing an adjacency table to
|
|
|
|
// preserve the mapping from fbx indices to *this* indexing.
|
|
|
|
unsigned int count = 0;
|
2016-04-05 20:53:54 +00:00
|
|
|
for(int index : tempFaces) {
|
2015-05-19 03:57:13 +00:00
|
|
|
const int absi = index < 0 ? (-index - 1) : index;
|
|
|
|
if(static_cast<size_t>(absi) >= vertex_count) {
|
|
|
|
DOMError("polygon vertex index out of range",&PolygonVertexIndex);
|
|
|
|
}
|
|
|
|
|
2016-09-28 14:16:06 +00:00
|
|
|
m_vertices.push_back(tempVerts[absi]);
|
2015-05-19 03:57:13 +00:00
|
|
|
++count;
|
|
|
|
|
2016-09-28 14:16:06 +00:00
|
|
|
++m_mapping_counts[absi];
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
if (index < 0) {
|
2016-09-28 14:16:06 +00:00
|
|
|
m_faces.push_back(count);
|
2015-05-19 03:57:13 +00:00
|
|
|
count = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int cursor = 0;
|
|
|
|
for (size_t i = 0, e = tempVerts.size(); i < e; ++i) {
|
2016-09-28 14:16:06 +00:00
|
|
|
m_mapping_offsets[i] = cursor;
|
|
|
|
cursor += m_mapping_counts[i];
|
2015-05-19 03:57:13 +00:00
|
|
|
|
2016-09-28 14:16:06 +00:00
|
|
|
m_mapping_counts[i] = 0;
|
2015-05-19 03:57:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cursor = 0;
|
2016-04-05 20:53:54 +00:00
|
|
|
for(int index : tempFaces) {
|
2015-05-19 03:57:13 +00:00
|
|
|
const int absi = index < 0 ? (-index - 1) : index;
|
2016-09-28 14:16:06 +00:00
|
|
|
m_mappings[m_mapping_offsets[absi] + m_mapping_counts[absi]++] = cursor++;
|
2015-05-19 03:57:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// if settings.readAllLayers is true:
|
|
|
|
// * read all layers, try to load as many vertex channels as possible
|
|
|
|
// if settings.readAllLayers is false:
|
|
|
|
// * read only the layer with index 0, but warn about any further layers
|
|
|
|
for (ElementMap::const_iterator it = Layer.first; it != Layer.second; ++it) {
|
|
|
|
const TokenList& tokens = (*it).second->Tokens();
|
|
|
|
|
|
|
|
const char* err;
|
|
|
|
const int index = ParseTokenAsInt(*tokens[0], err);
|
|
|
|
if(err) {
|
|
|
|
DOMError(err,&element);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(doc.Settings().readAllLayers || index == 0) {
|
|
|
|
const Scope& layer = GetRequiredScope(*(*it).second);
|
|
|
|
ReadLayer(layer);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
FBXImporter::LogWarn("ignoring additional geometry layers");
|
|
|
|
}
|
|
|
|
}
|
2012-07-01 12:38:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2018-03-22 21:14:10 +00:00
|
|
|
MeshGeometry::~MeshGeometry() {
|
|
|
|
// empty
|
2012-07-01 12:38:14 +00:00
|
|
|
}
|
|
|
|
|
2016-03-03 14:19:38 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const std::vector<aiVector3D>& MeshGeometry::GetVertices() const {
|
2016-09-28 14:16:06 +00:00
|
|
|
return m_vertices;
|
2016-03-03 14:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const std::vector<aiVector3D>& MeshGeometry::GetNormals() const {
|
2016-09-28 14:16:06 +00:00
|
|
|
return m_normals;
|
2016-03-03 14:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const std::vector<aiVector3D>& MeshGeometry::GetTangents() const {
|
2016-09-28 14:16:06 +00:00
|
|
|
return m_tangents;
|
2016-03-03 14:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const std::vector<aiVector3D>& MeshGeometry::GetBinormals() const {
|
2016-09-28 14:16:06 +00:00
|
|
|
return m_binormals;
|
2016-03-03 14:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const std::vector<unsigned int>& MeshGeometry::GetFaceIndexCounts() const {
|
2016-09-28 14:16:06 +00:00
|
|
|
return m_faces;
|
2016-03-03 14:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const std::vector<aiVector2D>& MeshGeometry::GetTextureCoords( unsigned int index ) const {
|
2018-03-22 22:08:25 +00:00
|
|
|
static const std::vector<aiVector2D> empty;
|
2016-09-28 14:16:06 +00:00
|
|
|
return index >= AI_MAX_NUMBER_OF_TEXTURECOORDS ? empty : m_uvs[ index ];
|
2016-03-03 14:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string MeshGeometry::GetTextureCoordChannelName( unsigned int index ) const {
|
2016-09-28 14:16:06 +00:00
|
|
|
return index >= AI_MAX_NUMBER_OF_TEXTURECOORDS ? "" : m_uvNames[ index ];
|
2016-03-03 14:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const std::vector<aiColor4D>& MeshGeometry::GetVertexColors( unsigned int index ) const {
|
2018-03-22 22:08:25 +00:00
|
|
|
static const std::vector<aiColor4D> empty;
|
2016-09-28 14:16:06 +00:00
|
|
|
return index >= AI_MAX_NUMBER_OF_COLOR_SETS ? empty : m_colors[ index ];
|
2016-03-03 14:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const MatIndexArray& MeshGeometry::GetMaterialIndices() const {
|
2016-09-28 14:16:06 +00:00
|
|
|
return m_materials;
|
2016-03-03 14:19:38 +00:00
|
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const unsigned int* MeshGeometry::ToOutputVertexIndex( unsigned int in_index, unsigned int& count ) const {
|
2016-09-28 14:16:06 +00:00
|
|
|
if ( in_index >= m_mapping_counts.size() ) {
|
2016-03-03 14:19:38 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-09-28 14:16:06 +00:00
|
|
|
ai_assert( m_mapping_counts.size() == m_mapping_offsets.size() );
|
|
|
|
count = m_mapping_counts[ in_index ];
|
2016-03-03 14:19:38 +00:00
|
|
|
|
2016-09-28 14:16:06 +00:00
|
|
|
ai_assert( m_mapping_offsets[ in_index ] + count <= m_mappings.size() );
|
2016-03-03 14:19:38 +00:00
|
|
|
|
2016-09-28 14:16:06 +00:00
|
|
|
return &m_mappings[ m_mapping_offsets[ in_index ] ];
|
2016-03-03 14:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
unsigned int MeshGeometry::FaceForVertexIndex( unsigned int in_index ) const {
|
2016-09-28 14:16:06 +00:00
|
|
|
ai_assert( in_index < m_vertices.size() );
|
2016-03-03 14:19:38 +00:00
|
|
|
|
|
|
|
// in the current conversion pattern this will only be needed if
|
|
|
|
// weights are present, so no need to always pre-compute this table
|
2016-09-28 14:16:06 +00:00
|
|
|
if ( m_facesVertexStartIndices.empty() ) {
|
|
|
|
m_facesVertexStartIndices.resize( m_faces.size() + 1, 0 );
|
2016-03-03 14:19:38 +00:00
|
|
|
|
2016-09-28 14:16:06 +00:00
|
|
|
std::partial_sum( m_faces.begin(), m_faces.end(), m_facesVertexStartIndices.begin() + 1 );
|
|
|
|
m_facesVertexStartIndices.pop_back();
|
2016-03-03 14:19:38 +00:00
|
|
|
}
|
2012-07-01 12:38:14 +00:00
|
|
|
|
2016-09-28 14:16:06 +00:00
|
|
|
ai_assert( m_facesVertexStartIndices.size() == m_faces.size() );
|
2016-03-03 14:19:38 +00:00
|
|
|
const std::vector<unsigned int>::iterator it = std::upper_bound(
|
2016-09-28 14:16:06 +00:00
|
|
|
m_facesVertexStartIndices.begin(),
|
|
|
|
m_facesVertexStartIndices.end(),
|
2016-03-03 14:19:38 +00:00
|
|
|
in_index
|
|
|
|
);
|
|
|
|
|
2016-09-28 14:16:06 +00:00
|
|
|
return static_cast< unsigned int >( std::distance( m_facesVertexStartIndices.begin(), it - 1 ) );
|
2016-03-03 14:19:38 +00:00
|
|
|
}
|
2012-07-04 13:07:57 +00:00
|
|
|
|
2012-07-01 12:38:14 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void MeshGeometry::ReadLayer(const Scope& layer)
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
const ElementCollection& LayerElement = layer.GetCollection("LayerElement");
|
|
|
|
for (ElementMap::const_iterator eit = LayerElement.first; eit != LayerElement.second; ++eit) {
|
|
|
|
const Scope& elayer = GetRequiredScope(*(*eit).second);
|
2012-07-01 12:38:14 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
ReadLayerElement(elayer);
|
|
|
|
}
|
2012-07-01 12:38:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void MeshGeometry::ReadLayerElement(const Scope& layerElement)
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
const Element& Type = GetRequiredElement(layerElement,"Type");
|
|
|
|
const Element& TypedIndex = GetRequiredElement(layerElement,"TypedIndex");
|
2012-07-01 12:38:14 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::string& type = ParseTokenAsString(GetRequiredToken(Type,0));
|
|
|
|
const int typedIndex = ParseTokenAsInt(GetRequiredToken(TypedIndex,0));
|
2012-07-01 12:38:14 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
const Scope& top = GetRequiredScope(element);
|
|
|
|
const ElementCollection candidates = top.GetCollection(type);
|
2012-07-01 12:38:14 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
for (ElementMap::const_iterator it = candidates.first; it != candidates.second; ++it) {
|
|
|
|
const int index = ParseTokenAsInt(GetRequiredToken(*(*it).second,0));
|
|
|
|
if(index == typedIndex) {
|
|
|
|
ReadVertexData(type,typedIndex,GetRequiredScope(*(*it).second));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2012-07-01 12:38:14 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
FBXImporter::LogError(Formatter::format("failed to resolve vertex layer element: ")
|
|
|
|
<< type << ", index: " << typedIndex);
|
2012-07-01 12:38:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void MeshGeometry::ReadVertexData(const std::string& type, int index, const Scope& source)
|
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::string& MappingInformationType = ParseTokenAsString(GetRequiredToken(
|
|
|
|
GetRequiredElement(source,"MappingInformationType"),0)
|
|
|
|
);
|
|
|
|
|
|
|
|
const std::string& ReferenceInformationType = ParseTokenAsString(GetRequiredToken(
|
|
|
|
GetRequiredElement(source,"ReferenceInformationType"),0)
|
|
|
|
);
|
|
|
|
|
|
|
|
if (type == "LayerElementUV") {
|
|
|
|
if(index >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
|
|
|
|
FBXImporter::LogError(Formatter::format("ignoring UV layer, maximum number of UV channels exceeded: ")
|
|
|
|
<< index << " (limit is " << AI_MAX_NUMBER_OF_TEXTURECOORDS << ")" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Element* Name = source["Name"];
|
2016-09-28 14:16:06 +00:00
|
|
|
m_uvNames[index] = "";
|
2015-05-19 03:57:13 +00:00
|
|
|
if(Name) {
|
2016-09-28 14:16:06 +00:00
|
|
|
m_uvNames[index] = ParseTokenAsString(GetRequiredToken(*Name,0));
|
2015-05-19 03:57:13 +00:00
|
|
|
}
|
|
|
|
|
2016-09-28 14:16:06 +00:00
|
|
|
ReadVertexDataUV(m_uvs[index],source,
|
2015-05-19 03:57:13 +00:00
|
|
|
MappingInformationType,
|
|
|
|
ReferenceInformationType
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else if (type == "LayerElementMaterial") {
|
2016-09-28 14:16:06 +00:00
|
|
|
if (m_materials.size() > 0) {
|
2015-05-19 03:57:13 +00:00
|
|
|
FBXImporter::LogError("ignoring additional material layer");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<int> temp_materials;
|
|
|
|
|
|
|
|
ReadVertexDataMaterials(temp_materials,source,
|
|
|
|
MappingInformationType,
|
|
|
|
ReferenceInformationType
|
|
|
|
);
|
|
|
|
|
|
|
|
// sometimes, there will be only negative entries. Drop the material
|
|
|
|
// layer in such a case (I guess it means a default material should
|
|
|
|
// be used). This is what the converter would do anyway, and it
|
2016-04-03 00:38:00 +00:00
|
|
|
// avoids losing the material if there are more material layers
|
2015-05-19 03:57:13 +00:00
|
|
|
// coming of which at least one contains actual data (did observe
|
|
|
|
// that with one test file).
|
2017-07-05 00:01:03 +00:00
|
|
|
const size_t count_neg = std::count_if(temp_materials.begin(),temp_materials.end(),[](int n) { return n < 0; });
|
2015-05-19 03:57:13 +00:00
|
|
|
if(count_neg == temp_materials.size()) {
|
|
|
|
FBXImporter::LogWarn("ignoring dummy material layer (all entries -1)");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-28 14:16:06 +00:00
|
|
|
std::swap(temp_materials, m_materials);
|
2015-05-19 03:57:13 +00:00
|
|
|
}
|
|
|
|
else if (type == "LayerElementNormal") {
|
2016-09-28 14:16:06 +00:00
|
|
|
if (m_normals.size() > 0) {
|
2015-05-19 03:57:13 +00:00
|
|
|
FBXImporter::LogError("ignoring additional normal layer");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-28 14:16:06 +00:00
|
|
|
ReadVertexDataNormals(m_normals,source,
|
2015-05-19 03:57:13 +00:00
|
|
|
MappingInformationType,
|
|
|
|
ReferenceInformationType
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else if (type == "LayerElementTangent") {
|
2016-09-28 14:16:06 +00:00
|
|
|
if (m_tangents.size() > 0) {
|
2015-05-19 03:57:13 +00:00
|
|
|
FBXImporter::LogError("ignoring additional tangent layer");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-28 14:16:06 +00:00
|
|
|
ReadVertexDataTangents(m_tangents,source,
|
2015-05-19 03:57:13 +00:00
|
|
|
MappingInformationType,
|
|
|
|
ReferenceInformationType
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else if (type == "LayerElementBinormal") {
|
2016-09-28 14:16:06 +00:00
|
|
|
if (m_binormals.size() > 0) {
|
2015-05-19 03:57:13 +00:00
|
|
|
FBXImporter::LogError("ignoring additional binormal layer");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-28 14:16:06 +00:00
|
|
|
ReadVertexDataBinormals(m_binormals,source,
|
2015-05-19 03:57:13 +00:00
|
|
|
MappingInformationType,
|
|
|
|
ReferenceInformationType
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else if (type == "LayerElementColor") {
|
|
|
|
if(index >= AI_MAX_NUMBER_OF_COLOR_SETS) {
|
|
|
|
FBXImporter::LogError(Formatter::format("ignoring vertex color layer, maximum number of color sets exceeded: ")
|
|
|
|
<< index << " (limit is " << AI_MAX_NUMBER_OF_COLOR_SETS << ")" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-28 14:16:06 +00:00
|
|
|
ReadVertexDataColors(m_colors[index],source,
|
2015-05-19 03:57:13 +00:00
|
|
|
MappingInformationType,
|
|
|
|
ReferenceInformationType
|
|
|
|
);
|
|
|
|
}
|
2012-07-01 12:38:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// Lengthy utility function to read and resolve a FBX vertex data array - that is, the
|
|
|
|
// output is in polygon vertex order. This logic is used for reading normals, UVs, colors,
|
|
|
|
// tangents ..
|
|
|
|
template <typename T>
|
2015-05-19 03:52:10 +00:00
|
|
|
void ResolveVertexDataArray(std::vector<T>& data_out, const Scope& source,
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::string& MappingInformationType,
|
|
|
|
const std::string& ReferenceInformationType,
|
|
|
|
const char* dataElementName,
|
|
|
|
const char* indexDataElementName,
|
|
|
|
size_t vertex_count,
|
|
|
|
const std::vector<unsigned int>& mapping_counts,
|
|
|
|
const std::vector<unsigned int>& mapping_offsets,
|
|
|
|
const std::vector<unsigned int>& mappings)
|
2012-07-01 12:38:14 +00:00
|
|
|
{
|
2018-01-24 14:45:20 +00:00
|
|
|
bool isDirect = ReferenceInformationType == "Direct";
|
|
|
|
bool isIndexToDirect = ReferenceInformationType == "IndexToDirect";
|
2015-12-08 11:26:41 +00:00
|
|
|
|
2018-03-22 21:14:10 +00:00
|
|
|
// fall-back to direct data if there is no index data element
|
2018-01-24 14:45:20 +00:00
|
|
|
if ( isIndexToDirect && !HasElement( source, indexDataElementName ) ) {
|
|
|
|
isDirect = true;
|
|
|
|
isIndexToDirect = false;
|
|
|
|
}
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
// handle permutations of Mapping and Reference type - it would be nice to
|
|
|
|
// deal with this more elegantly and with less redundancy, but right
|
|
|
|
// now it seems unavoidable.
|
2018-01-24 14:45:20 +00:00
|
|
|
if (MappingInformationType == "ByVertice" && isDirect) {
|
2018-09-11 14:07:43 +00:00
|
|
|
if (!HasElement(source, dataElementName)) {
|
2018-06-23 18:25:31 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-01-04 11:37:35 +00:00
|
|
|
std::vector<T> tempData;
|
2015-12-08 11:26:41 +00:00
|
|
|
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
|
|
|
|
|
2020-01-29 15:06:48 +00:00
|
|
|
if (tempData.size() != vertex_count) {
|
|
|
|
FBXImporter::LogError(Formatter::format("length of input data unexpected for ByVertice mapping: ")
|
|
|
|
<< tempData.size() << ", expected " << vertex_count);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
data_out.resize(vertex_count);
|
2015-12-08 11:26:41 +00:00
|
|
|
for (size_t i = 0, e = tempData.size(); i < e; ++i) {
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
const unsigned int istart = mapping_offsets[i], iend = istart + mapping_counts[i];
|
|
|
|
for (unsigned int j = istart; j < iend; ++j) {
|
2015-12-08 11:26:41 +00:00
|
|
|
data_out[mappings[j]] = tempData[i];
|
2015-05-19 03:57:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-01-24 14:45:20 +00:00
|
|
|
else if (MappingInformationType == "ByVertice" && isIndexToDirect) {
|
2015-12-08 11:26:41 +00:00
|
|
|
std::vector<T> tempData;
|
|
|
|
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
|
|
|
|
|
2020-01-29 15:06:48 +00:00
|
|
|
if (tempData.size() != vertex_count) {
|
|
|
|
FBXImporter::LogError(Formatter::format("length of input data unexpected for ByVertice mapping: ")
|
|
|
|
<< tempData.size() << ", expected " << vertex_count);
|
|
|
|
return;
|
|
|
|
}
|
2015-05-19 03:57:13 +00:00
|
|
|
|
2018-01-04 12:09:43 +00:00
|
|
|
std::vector<int> uvIndices;
|
|
|
|
ParseVectorDataArray(uvIndices,GetRequiredElement(source,indexDataElementName));
|
2020-01-29 15:06:48 +00:00
|
|
|
|
|
|
|
if (uvIndices.size() != vertex_count) {
|
|
|
|
FBXImporter::LogError(Formatter::format("length of input data unexpected for ByVertice mapping: ")
|
|
|
|
<< uvIndices.size() << ", expected " << vertex_count);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
data_out.resize(vertex_count);
|
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
for (size_t i = 0, e = uvIndices.size(); i < e; ++i) {
|
|
|
|
|
|
|
|
const unsigned int istart = mapping_offsets[i], iend = istart + mapping_counts[i];
|
|
|
|
for (unsigned int j = istart; j < iend; ++j) {
|
2015-12-08 11:26:41 +00:00
|
|
|
if (static_cast<size_t>(uvIndices[i]) >= tempData.size()) {
|
2015-05-19 03:57:13 +00:00
|
|
|
DOMError("index out of range",&GetRequiredElement(source,indexDataElementName));
|
|
|
|
}
|
2015-12-08 11:26:41 +00:00
|
|
|
data_out[mappings[j]] = tempData[uvIndices[i]];
|
2015-05-19 03:57:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-01-24 14:45:20 +00:00
|
|
|
else if (MappingInformationType == "ByPolygonVertex" && isDirect) {
|
2015-12-08 11:26:41 +00:00
|
|
|
std::vector<T> tempData;
|
|
|
|
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
|
|
|
|
|
|
|
|
if (tempData.size() != vertex_count) {
|
2015-05-19 03:57:13 +00:00
|
|
|
FBXImporter::LogError(Formatter::format("length of input data unexpected for ByPolygon mapping: ")
|
2015-12-08 11:26:41 +00:00
|
|
|
<< tempData.size() << ", expected " << vertex_count
|
2015-05-19 03:57:13 +00:00
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-12-08 11:26:41 +00:00
|
|
|
data_out.swap(tempData);
|
2015-05-19 03:57:13 +00:00
|
|
|
}
|
2018-01-24 14:45:20 +00:00
|
|
|
else if (MappingInformationType == "ByPolygonVertex" && isIndexToDirect) {
|
2015-12-08 11:26:41 +00:00
|
|
|
std::vector<T> tempData;
|
|
|
|
ParseVectorDataArray(tempData, GetRequiredElement(source, dataElementName));
|
|
|
|
|
2020-01-29 15:06:48 +00:00
|
|
|
if (tempData.size() != vertex_count) {
|
|
|
|
FBXImporter::LogError(Formatter::format("length of input data unexpected for ByPolygonVertex mapping: ")
|
|
|
|
<< tempData.size() << ", expected " << vertex_count);
|
|
|
|
return;
|
|
|
|
}
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
std::vector<int> uvIndices;
|
|
|
|
ParseVectorDataArray(uvIndices,GetRequiredElement(source,indexDataElementName));
|
|
|
|
|
2020-01-29 15:06:48 +00:00
|
|
|
if (uvIndices.size() != vertex_count) {
|
|
|
|
FBXImporter::LogError(Formatter::format("length of input data unexpected for ByPolygonVertex mapping: ")
|
|
|
|
<< uvIndices.size() << ", expected " << vertex_count);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
data_out.resize(vertex_count);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
2018-03-22 21:14:10 +00:00
|
|
|
const T empty;
|
2015-05-19 03:57:13 +00:00
|
|
|
unsigned int next = 0;
|
2016-04-05 20:53:54 +00:00
|
|
|
for(int i : uvIndices) {
|
2018-03-22 21:14:10 +00:00
|
|
|
if ( -1 == i ) {
|
|
|
|
data_out[ next++ ] = empty;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (static_cast<size_t>(i) >= tempData.size()) {
|
2015-05-19 03:57:13 +00:00
|
|
|
DOMError("index out of range",&GetRequiredElement(source,indexDataElementName));
|
|
|
|
}
|
|
|
|
|
2015-12-08 11:26:41 +00:00
|
|
|
data_out[next++] = tempData[i];
|
2015-05-19 03:57:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
FBXImporter::LogError(Formatter::format("ignoring vertex data channel, access type not implemented: ")
|
|
|
|
<< MappingInformationType << "," << ReferenceInformationType);
|
|
|
|
}
|
2012-07-01 12:38:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-05-19 03:52:10 +00:00
|
|
|
void MeshGeometry::ReadVertexDataNormals(std::vector<aiVector3D>& normals_out, const Scope& source,
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::string& MappingInformationType,
|
|
|
|
const std::string& ReferenceInformationType)
|
2012-07-01 12:38:14 +00:00
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
ResolveVertexDataArray(normals_out,source,MappingInformationType,ReferenceInformationType,
|
|
|
|
"Normals",
|
|
|
|
"NormalsIndex",
|
2016-09-28 14:16:06 +00:00
|
|
|
m_vertices.size(),
|
|
|
|
m_mapping_counts,
|
|
|
|
m_mapping_offsets,
|
|
|
|
m_mappings);
|
2012-07-01 12:38:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-05-19 03:52:10 +00:00
|
|
|
void MeshGeometry::ReadVertexDataUV(std::vector<aiVector2D>& uv_out, const Scope& source,
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::string& MappingInformationType,
|
|
|
|
const std::string& ReferenceInformationType)
|
2012-07-01 12:38:14 +00:00
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
ResolveVertexDataArray(uv_out,source,MappingInformationType,ReferenceInformationType,
|
|
|
|
"UV",
|
|
|
|
"UVIndex",
|
2016-09-28 14:16:06 +00:00
|
|
|
m_vertices.size(),
|
|
|
|
m_mapping_counts,
|
|
|
|
m_mapping_offsets,
|
|
|
|
m_mappings);
|
2012-07-01 12:38:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-05-19 03:52:10 +00:00
|
|
|
void MeshGeometry::ReadVertexDataColors(std::vector<aiColor4D>& colors_out, const Scope& source,
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::string& MappingInformationType,
|
|
|
|
const std::string& ReferenceInformationType)
|
2012-07-01 12:38:14 +00:00
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
ResolveVertexDataArray(colors_out,source,MappingInformationType,ReferenceInformationType,
|
|
|
|
"Colors",
|
|
|
|
"ColorIndex",
|
2016-09-28 14:16:06 +00:00
|
|
|
m_vertices.size(),
|
|
|
|
m_mapping_counts,
|
|
|
|
m_mapping_offsets,
|
|
|
|
m_mappings);
|
2012-07-01 12:38:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2019-05-06 18:51:04 +00:00
|
|
|
static const char *TangentIndexToken = "TangentIndex";
|
|
|
|
static const char *TangentsIndexToken = "TangentsIndex";
|
2016-02-03 20:09:20 +00:00
|
|
|
|
2015-05-19 03:52:10 +00:00
|
|
|
void MeshGeometry::ReadVertexDataTangents(std::vector<aiVector3D>& tangents_out, const Scope& source,
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::string& MappingInformationType,
|
|
|
|
const std::string& ReferenceInformationType)
|
2012-07-01 12:38:14 +00:00
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
const char * str = source.Elements().count( "Tangents" ) > 0 ? "Tangents" : "Tangent";
|
2019-05-06 19:21:58 +00:00
|
|
|
const char * strIdx = source.Elements().count( "Tangents" ) > 0 ? TangentsIndexToken : TangentIndexToken;
|
2015-05-19 03:57:13 +00:00
|
|
|
ResolveVertexDataArray(tangents_out,source,MappingInformationType,ReferenceInformationType,
|
|
|
|
str,
|
2016-02-03 20:09:20 +00:00
|
|
|
strIdx,
|
2016-09-28 14:16:06 +00:00
|
|
|
m_vertices.size(),
|
|
|
|
m_mapping_counts,
|
|
|
|
m_mapping_offsets,
|
|
|
|
m_mappings);
|
2012-07-01 12:38:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-03 20:09:20 +00:00
|
|
|
static const std::string BinormalIndexToken = "BinormalIndex";
|
|
|
|
static const std::string BinormalsIndexToken = "BinormalsIndex";
|
|
|
|
|
2015-05-19 03:52:10 +00:00
|
|
|
void MeshGeometry::ReadVertexDataBinormals(std::vector<aiVector3D>& binormals_out, const Scope& source,
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::string& MappingInformationType,
|
|
|
|
const std::string& ReferenceInformationType)
|
2012-07-01 12:38:14 +00:00
|
|
|
{
|
2015-05-19 03:57:13 +00:00
|
|
|
const char * str = source.Elements().count( "Binormals" ) > 0 ? "Binormals" : "Binormal";
|
2016-02-03 20:09:20 +00:00
|
|
|
const char * strIdx = source.Elements().count( "Binormals" ) > 0 ? BinormalsIndexToken.c_str() : BinormalIndexToken.c_str();
|
2015-05-19 03:57:13 +00:00
|
|
|
ResolveVertexDataArray(binormals_out,source,MappingInformationType,ReferenceInformationType,
|
|
|
|
str,
|
2016-02-03 20:09:20 +00:00
|
|
|
strIdx,
|
2016-09-28 14:16:06 +00:00
|
|
|
m_vertices.size(),
|
|
|
|
m_mapping_counts,
|
|
|
|
m_mapping_offsets,
|
|
|
|
m_mappings);
|
2012-07-01 12:38:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-05-19 03:52:10 +00:00
|
|
|
void MeshGeometry::ReadVertexDataMaterials(std::vector<int>& materials_out, const Scope& source,
|
2015-05-19 03:57:13 +00:00
|
|
|
const std::string& MappingInformationType,
|
|
|
|
const std::string& ReferenceInformationType)
|
2012-07-01 12:38:14 +00:00
|
|
|
{
|
2016-09-28 14:16:06 +00:00
|
|
|
const size_t face_count = m_faces.size();
|
2019-08-28 07:14:51 +00:00
|
|
|
if( 0 == face_count )
|
2019-08-26 21:44:25 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2019-08-26 21:39:20 +00:00
|
|
|
|
2015-05-19 03:57:13 +00:00
|
|
|
// materials are handled separately. First of all, they are assigned per-face
|
|
|
|
// and not per polyvert. Secondly, ReferenceInformationType=IndexToDirect
|
|
|
|
// has a slightly different meaning for materials.
|
|
|
|
ParseVectorDataArray(materials_out,GetRequiredElement(source,"Materials"));
|
|
|
|
|
|
|
|
if (MappingInformationType == "AllSame") {
|
|
|
|
// easy - same material for all faces
|
|
|
|
if (materials_out.empty()) {
|
|
|
|
FBXImporter::LogError(Formatter::format("expected material index, ignoring"));
|
|
|
|
return;
|
2019-08-28 07:14:51 +00:00
|
|
|
} else if (materials_out.size() > 1) {
|
2015-05-19 03:57:13 +00:00
|
|
|
FBXImporter::LogWarn(Formatter::format("expected only a single material index, ignoring all except the first one"));
|
|
|
|
materials_out.clear();
|
|
|
|
}
|
|
|
|
|
2019-04-10 17:16:42 +00:00
|
|
|
materials_out.resize(m_vertices.size());
|
|
|
|
std::fill(materials_out.begin(), materials_out.end(), materials_out.at(0));
|
2019-08-28 07:14:51 +00:00
|
|
|
} else if (MappingInformationType == "ByPolygon" && ReferenceInformationType == "IndexToDirect") {
|
2019-04-10 17:16:42 +00:00
|
|
|
materials_out.resize(face_count);
|
2015-05-19 03:57:13 +00:00
|
|
|
|
|
|
|
if(materials_out.size() != face_count) {
|
|
|
|
FBXImporter::LogError(Formatter::format("length of input data unexpected for ByPolygon mapping: ")
|
|
|
|
<< materials_out.size() << ", expected " << face_count
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
2019-08-28 07:14:51 +00:00
|
|
|
} else {
|
2015-05-19 03:57:13 +00:00
|
|
|
FBXImporter::LogError(Formatter::format("ignoring material assignments, access type not implemented: ")
|
|
|
|
<< MappingInformationType << "," << ReferenceInformationType);
|
|
|
|
}
|
2012-07-01 12:38:14 +00:00
|
|
|
}
|
2019-01-06 18:37:30 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
ShapeGeometry::ShapeGeometry(uint64_t id, const Element& element, const std::string& name, const Document& doc)
|
2019-08-28 07:14:51 +00:00
|
|
|
: Geometry(id, element, name, doc) {
|
|
|
|
const Scope *sc = element.Compound();
|
|
|
|
if (nullptr == sc) {
|
2019-01-06 18:37:30 +00:00
|
|
|
DOMError("failed to read Geometry object (class: Shape), no data scope found");
|
|
|
|
}
|
|
|
|
const Element& Indexes = GetRequiredElement(*sc, "Indexes", &element);
|
|
|
|
const Element& Normals = GetRequiredElement(*sc, "Normals", &element);
|
|
|
|
const Element& Vertices = GetRequiredElement(*sc, "Vertices", &element);
|
|
|
|
ParseVectorDataArray(m_indices, Indexes);
|
|
|
|
ParseVectorDataArray(m_vertices, Vertices);
|
|
|
|
ParseVectorDataArray(m_normals, Normals);
|
|
|
|
}
|
2012-07-01 12:38:14 +00:00
|
|
|
|
2019-01-06 18:37:30 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
ShapeGeometry::~ShapeGeometry() {
|
|
|
|
// empty
|
|
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const std::vector<aiVector3D>& ShapeGeometry::GetVertices() const {
|
|
|
|
return m_vertices;
|
|
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const std::vector<aiVector3D>& ShapeGeometry::GetNormals() const {
|
|
|
|
return m_normals;
|
|
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const std::vector<unsigned int>& ShapeGeometry::GetIndices() const {
|
|
|
|
return m_indices;
|
|
|
|
}
|
2019-01-17 11:26:22 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
LineGeometry::LineGeometry(uint64_t id, const Element& element, const std::string& name, const Document& doc)
|
|
|
|
: Geometry(id, element, name, doc)
|
|
|
|
{
|
|
|
|
const Scope* sc = element.Compound();
|
|
|
|
if (!sc) {
|
|
|
|
DOMError("failed to read Geometry object (class: Line), no data scope found");
|
|
|
|
}
|
|
|
|
const Element& Points = GetRequiredElement(*sc, "Points", &element);
|
|
|
|
const Element& PointsIndex = GetRequiredElement(*sc, "PointsIndex", &element);
|
|
|
|
ParseVectorDataArray(m_vertices, Points);
|
|
|
|
ParseVectorDataArray(m_indices, PointsIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
LineGeometry::~LineGeometry() {
|
|
|
|
// empty
|
|
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const std::vector<aiVector3D>& LineGeometry::GetVertices() const {
|
|
|
|
return m_vertices;
|
|
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const std::vector<int>& LineGeometry::GetIndices() const {
|
|
|
|
return m_indices;
|
|
|
|
}
|
2012-07-01 12:38:14 +00:00
|
|
|
} // !FBX
|
|
|
|
} // !Assimp
|
|
|
|
#endif
|
|
|
|
|