Skip to content

Commit

Permalink
Merge pull request assimp#3196 from assimp/kimkulling_dev
Browse files Browse the repository at this point in the history
Kimkulling dev
  • Loading branch information
kimkulling authored May 2, 2020
2 parents 08609fe + f8e6512 commit a874fac
Show file tree
Hide file tree
Showing 344 changed files with 12,037 additions and 13,184 deletions.
705 changes: 0 additions & 705 deletions code/AMF/AMFImporter.cpp

This file was deleted.

978 changes: 0 additions & 978 deletions code/AMF/AMFImporter_Postprocess.cpp

This file was deleted.

564 changes: 253 additions & 311 deletions code/3DS/3DSConverter.cpp → code/AssetLib/3DS/3DSConverter.cpp

Large diffs are not rendered by default.

229 changes: 107 additions & 122 deletions code/3DS/3DSExporter.cpp → code/AssetLib/3DS/3DSExporter.cpp

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
777 changes: 345 additions & 432 deletions code/3DS/3DSLoader.cpp → code/AssetLib/3DS/3DSLoader.cpp

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
250 changes: 120 additions & 130 deletions code/3MF/D3MFExporter.cpp → code/AssetLib/3MF/D3MFExporter.cpp

Large diffs are not rendered by default.

File renamed without changes.
278 changes: 138 additions & 140 deletions code/3MF/D3MFImporter.cpp → code/AssetLib/3MF/D3MFImporter.cpp

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
74 changes: 37 additions & 37 deletions code/AC/ACLoader.cpp → code/AssetLib/AC/ACLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void AC3DImporter::LoadObjectSection(std::vector<Object> &objects) {
objects.push_back(Object());
Object &obj = objects.back();

aiLight *light = NULL;
aiLight *light = nullptr;
if (!ASSIMP_strincmp(buffer, "light", 5)) {
// This is a light source. Add it to the list
mLights->push_back(light = new aiLight());
Expand Down Expand Up @@ -472,29 +472,29 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,
}

switch ((*it).flags & 0xf) {
// closed line
case 0x1:
needMat[idx].first += (unsigned int)(*it).entries.size();
needMat[idx].second += (unsigned int)(*it).entries.size() << 1u;
break;
// closed line
case 0x1:
needMat[idx].first += (unsigned int)(*it).entries.size();
needMat[idx].second += (unsigned int)(*it).entries.size() << 1u;
break;

// unclosed line
case 0x2:
needMat[idx].first += (unsigned int)(*it).entries.size() - 1;
needMat[idx].second += ((unsigned int)(*it).entries.size() - 1) << 1u;
break;
// unclosed line
case 0x2:
needMat[idx].first += (unsigned int)(*it).entries.size() - 1;
needMat[idx].second += ((unsigned int)(*it).entries.size() - 1) << 1u;
break;

// 0 == polygon, else unknown
default:
if ((*it).flags & 0xf) {
ASSIMP_LOG_WARN("AC3D: The type flag of a surface is unknown");
(*it).flags &= ~(0xf);
}
// 0 == polygon, else unknown
default:
if ((*it).flags & 0xf) {
ASSIMP_LOG_WARN("AC3D: The type flag of a surface is unknown");
(*it).flags &= ~(0xf);
}

// the number of faces increments by one, the number
// of vertices by surface.numref.
needMat[idx].first++;
needMat[idx].second += (unsigned int)(*it).entries.size();
// the number of faces increments by one, the number
// of vertices by surface.numref.
needMat[idx].first++;
needMat[idx].second += (unsigned int)(*it).entries.size();
};
}
unsigned int *pip = node->mMeshes = new unsigned int[node->mNumMeshes];
Expand Down Expand Up @@ -535,7 +535,7 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,

// allocate UV coordinates, but only if the texture name for the
// surface is not empty
aiVector3D *uv = NULL;
aiVector3D *uv = nullptr;
if (object.texture.length()) {
uv = mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices];
mesh->mNumUVComponents[0] = 2;
Expand Down Expand Up @@ -644,20 +644,20 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,
else {
// generate a name depending on the type of the node
switch (object.type) {
case Object::Group:
node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACGroup_%i", mGroupsCounter++);
break;
case Object::Poly:
node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACPoly_%i", mPolysCounter++);
break;
case Object::Light:
node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACLight_%i", mLightsCounter++);
break;

// there shouldn't be more than one world, but we don't care
case Object::World:
node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACWorld_%i", mWorldsCounter++);
break;
case Object::Group:
node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACGroup_%i", mGroupsCounter++);
break;
case Object::Poly:
node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACPoly_%i", mPolysCounter++);
break;
case Object::Light:
node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACLight_%i", mLightsCounter++);
break;

// there shouldn't be more than one world, but we don't care
case Object::World:
node->mName.length = ::ai_snprintf(node->mName.data, MAXLEN, "ACWorld_%i", mWorldsCounter++);
break;
}
}

Expand Down Expand Up @@ -696,7 +696,7 @@ void AC3DImporter::InternReadFile(const std::string &pFile,
std::unique_ptr<IOStream> file(pIOHandler->Open(pFile, "rb"));

// Check whether we can read from the file
if ( file.get() == nullptr ) {
if (file.get() == nullptr) {
throw DeadlyImportError("Failed to open AC3D file " + pFile + ".");
}

Expand Down
95 changes: 33 additions & 62 deletions code/AC/ACLoader.h → code/AssetLib/AC/ACLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,20 @@ struct aiMesh;
struct aiMaterial;
struct aiLight;


namespace Assimp {
namespace Assimp {

// ---------------------------------------------------------------------------
/** AC3D (*.ac) importer class
*/
class AC3DImporter : public BaseImporter
{
class AC3DImporter : public BaseImporter {
public:
AC3DImporter();
~AC3DImporter();

// Represents an AC3D material
struct Material
{
Material()
: rgb (0.6f,0.6f,0.6f)
, spec (1.f,1.f,1.f)
, shin (0.f)
, trans (0.f)
{}
struct Material {
Material() :
rgb(0.6f, 0.6f, 0.6f), spec(1.f, 1.f, 1.f), shin(0.f), trans(0.f) {}

// base color of the material
aiColor3D rgb;
Expand All @@ -101,43 +94,25 @@ class AC3DImporter : public BaseImporter
};

// Represents an AC3D surface
struct Surface
{
Surface()
: mat (0)
, flags (0)
{}
struct Surface {
Surface() :
mat(0), flags(0) {}

unsigned int mat,flags;
unsigned int mat, flags;

typedef std::pair<unsigned int, aiVector2D > SurfaceEntry;
std::vector< SurfaceEntry > entries;
typedef std::pair<unsigned int, aiVector2D> SurfaceEntry;
std::vector<SurfaceEntry> entries;
};

// Represents an AC3D object
struct Object
{
Object()
: type (World)
, name( "" )
, children()
, texture( "" )
, texRepeat( 1.f, 1.f )
, texOffset( 0.0f, 0.0f )
, rotation()
, translation()
, vertices()
, surfaces()
, numRefs (0)
, subDiv (0)
, crease()
{}
struct Object {
Object() :
type(World), name(""), children(), texture(""), texRepeat(1.f, 1.f), texOffset(0.0f, 0.0f), rotation(), translation(), vertices(), surfaces(), numRefs(0), subDiv(0), crease() {}

// Type description
enum Type
{
enum Type {
World = 0x0,
Poly = 0x1,
Poly = 0x1,
Group = 0x2,
Light = 0x4
} type;
Expand Down Expand Up @@ -177,37 +152,33 @@ class AC3DImporter : public BaseImporter
float crease;
};


public:

// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.
* See BaseImporter::CanRead() for details.
*/
bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
bool checkSig) const;
bool CanRead(const std::string &pFile, IOSystem *pIOHandler,
bool checkSig) const;

protected:

// -------------------------------------------------------------------
/** Return importer meta information.
* See #BaseImporter::GetInfo for the details */
const aiImporterDesc* GetInfo () const;
const aiImporterDesc *GetInfo() const;

// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
* See BaseImporter::InternReadFile() for details*/
void InternReadFile( const std::string& pFile, aiScene* pScene,
IOSystem* pIOHandler);
void InternReadFile(const std::string &pFile, aiScene *pScene,
IOSystem *pIOHandler);

// -------------------------------------------------------------------
/** Called prior to ReadFile().
* The function is a request to the importer to update its configuration
* basing on the Importer's configuration property list.*/
void SetupProperties(const Importer* pImp);
void SetupProperties(const Importer *pImp);

private:

// -------------------------------------------------------------------
/** Get the next line from the file.
* @return false if the end of the file was reached*/
Expand All @@ -218,7 +189,7 @@ class AC3DImporter : public BaseImporter
* load subobjects, the method returns after a 'kids 0' was
* encountered.
* @objects List of output objects*/
void LoadObjectSection(std::vector<Object>& objects);
void LoadObjectSection(std::vector<Object> &objects);

// -------------------------------------------------------------------
/** Convert all objects into meshes and nodes.
Expand All @@ -227,24 +198,24 @@ class AC3DImporter : public BaseImporter
* @param outMaterials List of output materials
* @param materials Material list
* @param Scenegraph node for the object */
aiNode* ConvertObjectSection(Object& object,
std::vector<aiMesh*>& meshes,
std::vector<aiMaterial*>& outMaterials,
const std::vector<Material>& materials,
aiNode* parent = NULL);
aiNode *ConvertObjectSection(Object &object,
std::vector<aiMesh *> &meshes,
std::vector<aiMaterial *> &outMaterials,
const std::vector<Material> &materials,
aiNode *parent = nullptr);

// -------------------------------------------------------------------
/** Convert a material
* @param object Current object
* @param matSrc Source material description
* @param matDest Destination material to be filled */
void ConvertMaterial(const Object& object,
const Material& matSrc,
aiMaterial& matDest);
void ConvertMaterial(const Object &object,
const Material &matSrc,
aiMaterial &matDest);

private:
// points to the next data line
const char* buffer;
const char *buffer;

// Configuration option: if enabled, up to two meshes
// are generated per material: those faces who have
Expand All @@ -261,7 +232,7 @@ class AC3DImporter : public BaseImporter
unsigned int mNumMeshes;

// current list of light sources
std::vector<aiLight*>* mLights;
std::vector<aiLight *> *mLights;

// name counters
unsigned int mLightsCounter, mGroupsCounter, mPolysCounter, mWorldsCounter;
Expand Down
Loading

0 comments on commit a874fac

Please sign in to comment.