2008-05-09 17:24:28 +00:00
|
|
|
/*
|
|
|
|
---------------------------------------------------------------------------
|
2012-02-03 03:38:30 +00:00
|
|
|
Open Asset Import Library (assimp)
|
2008-05-09 17:24:28 +00:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
2015-06-28 19:48:25 +00:00
|
|
|
Copyright (c) 2006-2015, assimp team
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use of this software in source and binary forms,
|
|
|
|
with or without modification, are permitted provided that the 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.
|
|
|
|
|
2012-02-03 03:38:30 +00:00
|
|
|
* Neither the name of the assimp team, nor the names of its
|
2008-05-09 17:24:28 +00:00
|
|
|
contributors may be used to endorse or promote products
|
|
|
|
derived from this software without specific prior
|
2012-02-03 03:38:30 +00:00
|
|
|
written permission of the assimp team.
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
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
|
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
/** @file Implementation of the 3ds importer class */
|
2008-06-22 10:09:26 +00:00
|
|
|
|
2015-04-15 23:00:17 +00:00
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
|
2008-10-13 16:45:48 +00:00
|
|
|
|
2008-06-22 10:09:26 +00:00
|
|
|
// internal headers
|
2008-05-05 12:36:31 +00:00
|
|
|
#include "3DSLoader.h"
|
2015-06-28 19:48:25 +00:00
|
|
|
#include "TargetAnimation.h"
|
2015-04-15 23:00:17 +00:00
|
|
|
#include "../include/assimp/scene.h"
|
2015-06-28 19:48:25 +00:00
|
|
|
#include "../include/assimp/DefaultLogger.hpp"
|
2015-04-15 23:00:17 +00:00
|
|
|
#include "StringComparison.h"
|
2015-06-28 19:48:25 +00:00
|
|
|
#include <boost/scoped_array.hpp>
|
|
|
|
#include <cctype>
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
using namespace Assimp;
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
// Setup final material indices, generae a default material if necessary
|
|
|
|
void Discreet3DSImporter::ReplaceDefaultMaterial()
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
|
2009-01-20 21:41:17 +00:00
|
|
|
// Try to find an existing material that matches the
|
2008-05-05 12:36:31 +00:00
|
|
|
// typical default material setting:
|
|
|
|
// - no textures
|
|
|
|
// - diffuse color (in grey!)
|
|
|
|
// NOTE: This is here to workaround the fact that some
|
|
|
|
// exporters are writing a default material, too.
|
2008-10-31 19:32:00 +00:00
|
|
|
unsigned int idx = 0xcdcdcdcd;
|
|
|
|
for (unsigned int i = 0; i < mScene->mMaterials.size();++i)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
std::string s = mScene->mMaterials[i].mName;
|
|
|
|
for (std::string::iterator it = s.begin(); it != s.end(); ++it)
|
|
|
|
*it = ::tolower(*it);
|
|
|
|
|
|
|
|
if (std::string::npos == s.find("default"))continue;
|
|
|
|
|
|
|
|
if (mScene->mMaterials[i].mDiffuse.r !=
|
|
|
|
mScene->mMaterials[i].mDiffuse.g ||
|
|
|
|
mScene->mMaterials[i].mDiffuse.r !=
|
|
|
|
mScene->mMaterials[i].mDiffuse.b)continue;
|
|
|
|
|
|
|
|
if (mScene->mMaterials[i].sTexDiffuse.mMapName.length() != 0 ||
|
|
|
|
mScene->mMaterials[i].sTexBump.mMapName.length() != 0 ||
|
|
|
|
mScene->mMaterials[i].sTexOpacity.mMapName.length() != 0 ||
|
|
|
|
mScene->mMaterials[i].sTexEmissive.mMapName.length() != 0 ||
|
|
|
|
mScene->mMaterials[i].sTexSpecular.mMapName.length() != 0 ||
|
|
|
|
mScene->mMaterials[i].sTexShininess.mMapName.length() != 0 )
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
idx = i;
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
if (0xcdcdcdcd == idx)idx = (unsigned int)mScene->mMaterials.size();
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// now iterate through all meshes and through all faces and
|
|
|
|
// find all faces that are using the default material
|
2008-10-31 19:32:00 +00:00
|
|
|
unsigned int cnt = 0;
|
|
|
|
for (std::vector<D3DS::Mesh>::iterator
|
|
|
|
i = mScene->mMeshes.begin();
|
|
|
|
i != mScene->mMeshes.end();++i)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
|
|
|
for (std::vector<unsigned int>::iterator
|
|
|
|
a = (*i).mFaceMaterials.begin();
|
|
|
|
a != (*i).mFaceMaterials.end();++a)
|
|
|
|
{
|
|
|
|
// NOTE: The additional check seems to be necessary,
|
|
|
|
// some exporters seem to generate invalid data here
|
2008-05-25 22:29:05 +00:00
|
|
|
if (0xcdcdcdcd == (*a))
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
(*a) = idx;
|
|
|
|
++cnt;
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
else if ( (*a) >= mScene->mMaterials.size())
|
2008-05-25 22:29:05 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
(*a) = idx;
|
2008-08-09 22:39:57 +00:00
|
|
|
DefaultLogger::get()->warn("Material index overflow in 3DS file. Using default material");
|
2008-10-31 19:32:00 +00:00
|
|
|
++cnt;
|
2008-05-25 22:29:05 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
if (cnt && idx == mScene->mMaterials.size())
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
// We need to create our own default material
|
|
|
|
D3DS::Material sMat;
|
2008-05-05 12:36:31 +00:00
|
|
|
sMat.mDiffuse = aiColor3D(0.3f,0.3f,0.3f);
|
|
|
|
sMat.mName = "%%%DEFAULT";
|
2008-10-31 19:32:00 +00:00
|
|
|
mScene->mMaterials.push_back(sMat);
|
|
|
|
|
|
|
|
DefaultLogger::get()->info("3DS: Generating default material");
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
|
|
|
}
|
2008-08-28 17:35:36 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2009-01-18 23:48:25 +00:00
|
|
|
// Check whether all indices are valid. Otherwise we'd crash before the validation step is reached
|
2008-10-31 19:32:00 +00:00
|
|
|
void Discreet3DSImporter::CheckIndices(D3DS::Mesh& sMesh)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2009-01-18 23:48:25 +00:00
|
|
|
for (std::vector< D3DS::Face >::iterator i = sMesh.mFaces.begin(); i != sMesh.mFaces.end();++i)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
|
|
|
// check whether all indices are in range
|
2008-08-28 17:35:36 +00:00
|
|
|
for (unsigned int a = 0; a < 3;++a)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-08-28 17:35:36 +00:00
|
|
|
if ((*i).mIndices[a] >= sMesh.mPositions.size())
|
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
DefaultLogger::get()->warn("3DS: Vertex index overflow)");
|
2008-08-28 17:35:36 +00:00
|
|
|
(*i).mIndices[a] = (uint32_t)sMesh.mPositions.size()-1;
|
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
if ( !sMesh.mTexCoords.empty() && (*i).mIndices[a] >= sMesh.mTexCoords.size())
|
|
|
|
{
|
|
|
|
DefaultLogger::get()->warn("3DS: Texture coordinate index overflow)");
|
|
|
|
(*i).mIndices[a] = (uint32_t)sMesh.mTexCoords.size()-1;
|
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-08-28 17:35:36 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
// Generate out unique verbose format representation
|
|
|
|
void Discreet3DSImporter::MakeUnique(D3DS::Mesh& sMesh)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2009-01-18 23:48:25 +00:00
|
|
|
// TODO: really necessary? I don't think. Just a waste of memory and time
|
|
|
|
// to do it now in a separate buffer.
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// Allocate output storage
|
|
|
|
std::vector<aiVector3D> vNew (sMesh.mFaces.size() * 3);
|
2008-11-16 21:56:45 +00:00
|
|
|
std::vector<aiVector3D> vNew2;
|
|
|
|
if (sMesh.mTexCoords.size())
|
|
|
|
vNew2.resize(sMesh.mFaces.size() * 3);
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
for (unsigned int i = 0, base = 0; i < sMesh.mFaces.size();++i)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-11-16 21:56:45 +00:00
|
|
|
D3DS::Face& face = sMesh.mFaces[i];
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
// Positions
|
|
|
|
for (unsigned int a = 0; a < 3;++a,++base)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-11-16 21:56:45 +00:00
|
|
|
vNew[base] = sMesh.mPositions[face.mIndices[a]];
|
|
|
|
if (sMesh.mTexCoords.size())
|
|
|
|
vNew2[base] = sMesh.mTexCoords[face.mIndices[a]];
|
2008-08-09 22:39:57 +00:00
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
face.mIndices[a] = base;
|
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-08-28 17:35:36 +00:00
|
|
|
sMesh.mPositions = vNew;
|
|
|
|
sMesh.mTexCoords = vNew2;
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-08-28 17:35:36 +00:00
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2009-01-18 23:48:25 +00:00
|
|
|
// Convert a 3DS texture to texture keys in an aiMaterial
|
2011-08-22 20:22:51 +00:00
|
|
|
void CopyTexture(aiMaterial& mat, D3DS::Texture& texture, aiTextureType type)
|
2008-11-16 21:56:45 +00:00
|
|
|
{
|
|
|
|
// Setup the texture name
|
|
|
|
aiString tex;
|
|
|
|
tex.Set( texture.mMapName);
|
|
|
|
mat.AddProperty( &tex, AI_MATKEY_TEXTURE(type,0));
|
|
|
|
|
|
|
|
// Setup the texture blend factor
|
|
|
|
if (is_not_qnan(texture.mTextureBlend))
|
|
|
|
mat.AddProperty<float>( &texture.mTextureBlend, 1, AI_MATKEY_TEXBLEND(type,0));
|
|
|
|
|
|
|
|
// Setup the texture mapping mode
|
|
|
|
mat.AddProperty<int>((int*)&texture.mMapMode,1,AI_MATKEY_MAPPINGMODE_U(type,0));
|
|
|
|
mat.AddProperty<int>((int*)&texture.mMapMode,1,AI_MATKEY_MAPPINGMODE_V(type,0));
|
|
|
|
|
|
|
|
// Mirroring - double the scaling values
|
2009-01-18 23:48:25 +00:00
|
|
|
// FIXME: this is not really correct ...
|
2008-11-16 21:56:45 +00:00
|
|
|
if (texture.mMapMode == aiTextureMapMode_Mirror)
|
|
|
|
{
|
|
|
|
texture.mScaleU *= 2.f;
|
|
|
|
texture.mScaleV *= 2.f;
|
|
|
|
texture.mOffsetU /= 2.f;
|
|
|
|
texture.mOffsetV /= 2.f;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setup texture UV transformations
|
|
|
|
mat.AddProperty<float>(&texture.mOffsetU,5,AI_MATKEY_UVTRANSFORM(type,0));
|
|
|
|
}
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
// Convert a 3DS material to an aiMaterial
|
|
|
|
void Discreet3DSImporter::ConvertMaterial(D3DS::Material& oldMat,
|
2011-08-22 20:22:51 +00:00
|
|
|
aiMaterial& mat)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
|
|
|
// NOTE: Pass the background image to the viewer by bypassing the
|
2008-10-31 19:32:00 +00:00
|
|
|
// material system. This is an evil hack, never do it again!
|
|
|
|
if (0 != mBackgroundImage.length() && bHasBG)
|
2008-08-28 17:35:36 +00:00
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
aiString tex;
|
2008-10-31 19:32:00 +00:00
|
|
|
tex.Set( mBackgroundImage);
|
2008-05-05 12:36:31 +00:00
|
|
|
mat.AddProperty( &tex, AI_MATKEY_GLOBAL_BACKGROUND_IMAGE);
|
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
// Be sure this is only done for the first material
|
2008-10-31 19:32:00 +00:00
|
|
|
mBackgroundImage = std::string("");
|
2008-08-28 17:35:36 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
// At first add the base ambient color of the scene to the material
|
2008-10-31 19:32:00 +00:00
|
|
|
oldMat.mAmbient.r += mClrAmbient.r;
|
|
|
|
oldMat.mAmbient.g += mClrAmbient.g;
|
|
|
|
oldMat.mAmbient.b += mClrAmbient.b;
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
aiString name;
|
|
|
|
name.Set( oldMat.mName);
|
|
|
|
mat.AddProperty( &name, AI_MATKEY_NAME);
|
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
// Material colors
|
2008-05-05 12:36:31 +00:00
|
|
|
mat.AddProperty( &oldMat.mAmbient, 1, AI_MATKEY_COLOR_AMBIENT);
|
|
|
|
mat.AddProperty( &oldMat.mDiffuse, 1, AI_MATKEY_COLOR_DIFFUSE);
|
|
|
|
mat.AddProperty( &oldMat.mSpecular, 1, AI_MATKEY_COLOR_SPECULAR);
|
|
|
|
mat.AddProperty( &oldMat.mEmissive, 1, AI_MATKEY_COLOR_EMISSIVE);
|
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
// Phong shininess and shininess strength
|
2008-10-31 19:32:00 +00:00
|
|
|
if (D3DS::Discreet3DS::Phong == oldMat.mShading ||
|
|
|
|
D3DS::Discreet3DS::Metal == oldMat.mShading)
|
2008-05-25 22:29:05 +00:00
|
|
|
{
|
2008-06-03 21:50:53 +00:00
|
|
|
if (!oldMat.mSpecularExponent || !oldMat.mShininessStrength)
|
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
oldMat.mShading = D3DS::Discreet3DS::Gouraud;
|
2008-06-03 21:50:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mat.AddProperty( &oldMat.mSpecularExponent, 1, AI_MATKEY_SHININESS);
|
|
|
|
mat.AddProperty( &oldMat.mShininessStrength, 1, AI_MATKEY_SHININESS_STRENGTH);
|
|
|
|
}
|
2008-05-25 22:29:05 +00:00
|
|
|
}
|
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
// Opacity
|
2008-05-05 12:36:31 +00:00
|
|
|
mat.AddProperty<float>( &oldMat.mTransparency,1,AI_MATKEY_OPACITY);
|
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
// Bump height scaling
|
2008-05-05 12:36:31 +00:00
|
|
|
mat.AddProperty<float>( &oldMat.mBumpHeight,1,AI_MATKEY_BUMPSCALING);
|
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
// Two sided rendering?
|
2008-06-03 21:50:53 +00:00
|
|
|
if (oldMat.mTwoSided)
|
|
|
|
{
|
2008-08-28 17:35:36 +00:00
|
|
|
int i = 1;
|
2008-06-03 21:50:53 +00:00
|
|
|
mat.AddProperty<int>(&i,1,AI_MATKEY_TWOSIDED);
|
|
|
|
}
|
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
// Shading mode
|
2008-05-05 12:36:31 +00:00
|
|
|
aiShadingMode eShading = aiShadingMode_NoShading;
|
|
|
|
switch (oldMat.mShading)
|
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
case D3DS::Discreet3DS::Flat:
|
2008-05-05 12:36:31 +00:00
|
|
|
eShading = aiShadingMode_Flat; break;
|
|
|
|
|
|
|
|
// I don't know what "Wire" shading should be,
|
2008-11-16 21:56:45 +00:00
|
|
|
// assume it is simple lambertian diffuse shading
|
2008-10-31 19:32:00 +00:00
|
|
|
case D3DS::Discreet3DS::Wire:
|
2008-11-16 21:56:45 +00:00
|
|
|
{
|
|
|
|
// Set the wireframe flag
|
|
|
|
unsigned int iWire = 1;
|
|
|
|
mat.AddProperty<int>( (int*)&iWire,1,AI_MATKEY_ENABLE_WIREFRAME);
|
|
|
|
}
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case D3DS::Discreet3DS::Gouraud:
|
2008-05-05 12:36:31 +00:00
|
|
|
eShading = aiShadingMode_Gouraud; break;
|
|
|
|
|
|
|
|
// assume cook-torrance shading for metals.
|
2008-10-31 19:32:00 +00:00
|
|
|
case D3DS::Discreet3DS::Phong :
|
2008-05-25 22:29:05 +00:00
|
|
|
eShading = aiShadingMode_Phong; break;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case D3DS::Discreet3DS::Metal :
|
2008-05-05 12:36:31 +00:00
|
|
|
eShading = aiShadingMode_CookTorrance; break;
|
2008-09-11 20:50:15 +00:00
|
|
|
|
|
|
|
// FIX to workaround a warning with GCC 4 who complained
|
|
|
|
// about a missing case Blinn: here - Blinn isn't a valid
|
|
|
|
// value in the 3DS Loader, it is just needed for ASE
|
2008-10-31 19:32:00 +00:00
|
|
|
case D3DS::Discreet3DS::Blinn :
|
2008-09-11 20:50:15 +00:00
|
|
|
eShading = aiShadingMode_Blinn; break;
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
|
|
|
mat.AddProperty<int>( (int*)&eShading,1,AI_MATKEY_SHADING_MODEL);
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// DIFFUSE texture
|
2008-05-05 12:36:31 +00:00
|
|
|
if( oldMat.sTexDiffuse.mMapName.length() > 0)
|
2008-11-16 21:56:45 +00:00
|
|
|
CopyTexture(mat,oldMat.sTexDiffuse, aiTextureType_DIFFUSE);
|
2008-06-03 21:50:53 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// SPECULAR texture
|
2008-05-05 12:36:31 +00:00
|
|
|
if( oldMat.sTexSpecular.mMapName.length() > 0)
|
2008-11-16 21:56:45 +00:00
|
|
|
CopyTexture(mat,oldMat.sTexSpecular, aiTextureType_SPECULAR);
|
2008-06-03 21:50:53 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// OPACITY texture
|
2008-05-05 12:36:31 +00:00
|
|
|
if( oldMat.sTexOpacity.mMapName.length() > 0)
|
2008-11-16 21:56:45 +00:00
|
|
|
CopyTexture(mat,oldMat.sTexOpacity, aiTextureType_OPACITY);
|
2008-05-09 17:24:28 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// EMISSIVE texture
|
2008-05-05 12:36:31 +00:00
|
|
|
if( oldMat.sTexEmissive.mMapName.length() > 0)
|
2008-11-16 21:56:45 +00:00
|
|
|
CopyTexture(mat,oldMat.sTexEmissive, aiTextureType_EMISSIVE);
|
2008-05-09 17:24:28 +00:00
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
// BUMP texture
|
2008-05-05 12:36:31 +00:00
|
|
|
if( oldMat.sTexBump.mMapName.length() > 0)
|
2008-11-16 21:56:45 +00:00
|
|
|
CopyTexture(mat,oldMat.sTexBump, aiTextureType_HEIGHT);
|
2008-05-09 17:24:28 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// SHININESS texture
|
2008-05-05 12:36:31 +00:00
|
|
|
if( oldMat.sTexShininess.mMapName.length() > 0)
|
2008-11-16 21:56:45 +00:00
|
|
|
CopyTexture(mat,oldMat.sTexShininess, aiTextureType_SHININESS);
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2009-02-11 20:56:05 +00:00
|
|
|
// REFLECTION texture
|
|
|
|
if( oldMat.sTexReflective.mMapName.length() > 0)
|
|
|
|
CopyTexture(mat,oldMat.sTexReflective, aiTextureType_REFLECTION);
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// Store the name of the material itself, too
|
2009-02-11 20:56:05 +00:00
|
|
|
if( oldMat.mName.length()) {
|
2008-05-05 12:36:31 +00:00
|
|
|
aiString tex;
|
|
|
|
tex.Set( oldMat.mName);
|
|
|
|
mat.AddProperty( &tex, AI_MATKEY_NAME);
|
|
|
|
}
|
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
// Split meshes by their materials and generate output aiMesh'es
|
|
|
|
void Discreet3DSImporter::ConvertMeshes(aiScene* pcOut)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
|
|
|
std::vector<aiMesh*> avOutMeshes;
|
2008-10-31 19:32:00 +00:00
|
|
|
avOutMeshes.reserve(mScene->mMeshes.size() * 2);
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2010-05-20 12:07:04 +00:00
|
|
|
unsigned int iFaceCnt = 0,num = 0;
|
|
|
|
aiString name;
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// we need to split all meshes by their materials
|
2010-05-20 12:07:04 +00:00
|
|
|
for (std::vector<D3DS::Mesh>::iterator i = mScene->mMeshes.begin(); i != mScene->mMeshes.end();++i) {
|
|
|
|
boost::scoped_array< std::vector<unsigned int> > aiSplit(new std::vector<unsigned int>[mScene->mMaterials.size()]);
|
|
|
|
|
|
|
|
name.length = ASSIMP_itoa10(name.data,num++);
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
unsigned int iNum = 0;
|
2008-10-31 19:32:00 +00:00
|
|
|
for (std::vector<unsigned int>::const_iterator a = (*i).mFaceMaterials.begin();
|
2008-05-05 12:36:31 +00:00
|
|
|
a != (*i).mFaceMaterials.end();++a,++iNum)
|
|
|
|
{
|
2008-08-28 17:35:36 +00:00
|
|
|
aiSplit[*a].push_back(iNum);
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
|
|
|
// now generate submeshes
|
2008-10-31 19:32:00 +00:00
|
|
|
for (unsigned int p = 0; p < mScene->mMaterials.size();++p)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2010-05-20 12:07:04 +00:00
|
|
|
if (aiSplit[p].empty()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
aiMesh* meshOut = new aiMesh();
|
|
|
|
meshOut->mName = name;
|
|
|
|
meshOut->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
|
|
|
|
|
|
|
|
// be sure to setup the correct material index
|
|
|
|
meshOut->mMaterialIndex = p;
|
|
|
|
|
|
|
|
// use the color data as temporary storage
|
|
|
|
meshOut->mColors[0] = (aiColor4D*)(&*i);
|
|
|
|
avOutMeshes.push_back(meshOut);
|
|
|
|
|
|
|
|
// convert vertices
|
|
|
|
meshOut->mNumFaces = (unsigned int)aiSplit[p].size();
|
|
|
|
meshOut->mNumVertices = meshOut->mNumFaces*3;
|
|
|
|
|
|
|
|
// allocate enough storage for faces
|
|
|
|
meshOut->mFaces = new aiFace[meshOut->mNumFaces];
|
|
|
|
iFaceCnt += meshOut->mNumFaces;
|
|
|
|
|
|
|
|
meshOut->mVertices = new aiVector3D[meshOut->mNumVertices];
|
|
|
|
meshOut->mNormals = new aiVector3D[meshOut->mNumVertices];
|
|
|
|
if ((*i).mTexCoords.size())
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2010-05-20 12:07:04 +00:00
|
|
|
meshOut->mTextureCoords[0] = new aiVector3D[meshOut->mNumVertices];
|
|
|
|
}
|
|
|
|
for (unsigned int q = 0, base = 0; q < aiSplit[p].size();++q)
|
|
|
|
{
|
2015-03-02 22:44:02 +00:00
|
|
|
unsigned int index = aiSplit[p][q];
|
2010-05-20 12:07:04 +00:00
|
|
|
aiFace& face = meshOut->mFaces[q];
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2010-05-20 12:07:04 +00:00
|
|
|
face.mIndices = new unsigned int[3];
|
|
|
|
face.mNumIndices = 3;
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2010-05-20 12:07:04 +00:00
|
|
|
for (unsigned int a = 0; a < 3;++a,++base)
|
|
|
|
{
|
|
|
|
unsigned int idx = (*i).mFaces[index].mIndices[a];
|
|
|
|
meshOut->mVertices[base] = (*i).mPositions[idx];
|
|
|
|
meshOut->mNormals [base] = (*i).mNormals[idx];
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2010-05-20 12:07:04 +00:00
|
|
|
if ((*i).mTexCoords.size())
|
|
|
|
meshOut->mTextureCoords[0][base] = (*i).mTexCoords[idx];
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2010-05-20 12:07:04 +00:00
|
|
|
face.mIndices[a] = base;
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
// Copy them to the output array
|
2008-06-01 12:46:17 +00:00
|
|
|
pcOut->mNumMeshes = (unsigned int)avOutMeshes.size();
|
2008-05-05 12:36:31 +00:00
|
|
|
pcOut->mMeshes = new aiMesh*[pcOut->mNumMeshes]();
|
2010-05-20 12:07:04 +00:00
|
|
|
for (unsigned int a = 0; a < pcOut->mNumMeshes;++a) {
|
2008-05-05 12:36:31 +00:00
|
|
|
pcOut->mMeshes[a] = avOutMeshes[a];
|
2010-05-20 12:07:04 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// We should have at least one face here
|
2010-05-20 12:07:04 +00:00
|
|
|
if (!iFaceCnt) {
|
2010-03-18 17:00:12 +00:00
|
|
|
throw DeadlyImportError("No faces loaded. The mesh is empty");
|
2010-05-20 12:07:04 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-08-28 17:35:36 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
// Add a node to the scenegraph and setup its final transformation
|
2008-11-16 21:56:45 +00:00
|
|
|
void Discreet3DSImporter::AddNodeToGraph(aiScene* pcSOut,aiNode* pcOut,
|
2011-06-09 14:29:32 +00:00
|
|
|
D3DS::Node* pcIn, aiMatrix4x4& /*absTrafo*/)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
|
|
|
std::vector<unsigned int> iArray;
|
2008-07-10 16:49:01 +00:00
|
|
|
iArray.reserve(3);
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-11-04 20:41:11 +00:00
|
|
|
aiMatrix4x4 abs;
|
2008-07-10 16:49:01 +00:00
|
|
|
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
// Find all meshes with the same name as the node
|
|
|
|
for (unsigned int a = 0; a < pcSOut->mNumMeshes;++a)
|
|
|
|
{
|
|
|
|
const D3DS::Mesh* pcMesh = (const D3DS::Mesh*)pcSOut->mMeshes[a]->mColors[0];
|
|
|
|
ai_assert(NULL != pcMesh);
|
2008-05-25 22:29:05 +00:00
|
|
|
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
if (pcIn->mName == pcMesh->mName)
|
|
|
|
iArray.push_back(a);
|
|
|
|
}
|
|
|
|
if (!iArray.empty())
|
|
|
|
{
|
|
|
|
// The matrix should be identical for all meshes with the
|
|
|
|
// same name. It HAS to be identical for all meshes .....
|
|
|
|
D3DS::Mesh* imesh = ((D3DS::Mesh*)pcSOut->mMeshes[iArray[0]]->mColors[0]);
|
|
|
|
|
|
|
|
// Compute the inverse of the transformation matrix to move the
|
|
|
|
// vertices back to their relative and local space
|
|
|
|
aiMatrix4x4 mInv = imesh->mMat, mInvTransposed = imesh->mMat;
|
|
|
|
mInv.Inverse();mInvTransposed.Transpose();
|
|
|
|
aiVector3D pivot = pcIn->vPivot;
|
|
|
|
|
|
|
|
pcOut->mNumMeshes = (unsigned int)iArray.size();
|
|
|
|
pcOut->mMeshes = new unsigned int[iArray.size()];
|
|
|
|
for (unsigned int i = 0;i < iArray.size();++i) {
|
|
|
|
const unsigned int iIndex = iArray[i];
|
|
|
|
aiMesh* const mesh = pcSOut->mMeshes[iIndex];
|
|
|
|
|
2014-01-30 01:39:04 +00:00
|
|
|
if (mesh->mColors[1] == NULL)
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
{
|
2014-01-30 01:39:04 +00:00
|
|
|
// Transform the vertices back into their local space
|
|
|
|
// fixme: consider computing normals after this, so we don't need to transform them
|
|
|
|
const aiVector3D* const pvEnd = mesh->mVertices + mesh->mNumVertices;
|
|
|
|
aiVector3D* pvCurrent = mesh->mVertices, *t2 = mesh->mNormals;
|
|
|
|
|
|
|
|
for (; pvCurrent != pvEnd; ++pvCurrent, ++t2) {
|
|
|
|
*pvCurrent = mInv * (*pvCurrent);
|
|
|
|
*t2 = mInvTransposed * (*t2);
|
2008-07-10 16:49:01 +00:00
|
|
|
}
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
|
2014-01-30 01:39:04 +00:00
|
|
|
// Handle negative transformation matrix determinant -> invert vertex x
|
|
|
|
if (imesh->mMat.Determinant() < 0.0f)
|
|
|
|
{
|
|
|
|
/* we *must* have normals */
|
|
|
|
for (pvCurrent = mesh->mVertices, t2 = mesh->mNormals; pvCurrent != pvEnd; ++pvCurrent, ++t2) {
|
|
|
|
pvCurrent->x *= -1.f;
|
|
|
|
t2->x *= -1.f;
|
|
|
|
}
|
|
|
|
DefaultLogger::get()->info("3DS: Flipping mesh X-Axis");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle pivot point
|
|
|
|
if (pivot.x || pivot.y || pivot.z)
|
|
|
|
{
|
|
|
|
for (pvCurrent = mesh->mVertices; pvCurrent != pvEnd; ++pvCurrent) {
|
|
|
|
*pvCurrent -= pivot;
|
|
|
|
}
|
2008-07-10 16:49:01 +00:00
|
|
|
}
|
2014-01-30 01:39:04 +00:00
|
|
|
|
|
|
|
mesh->mColors[1] = (aiColor4D*)1;
|
2008-07-10 16:49:01 +00:00
|
|
|
}
|
2014-01-30 01:39:04 +00:00
|
|
|
else
|
|
|
|
mesh->mColors[1] = (aiColor4D*)1;
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
|
|
|
|
// Setup the mesh index
|
|
|
|
pcOut->mMeshes[i] = iIndex;
|
2008-07-10 16:49:01 +00:00
|
|
|
}
|
2008-05-25 22:29:05 +00:00
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2009-01-20 21:41:17 +00:00
|
|
|
// Setup the name of the node
|
2014-01-30 01:39:04 +00:00
|
|
|
// First instance keeps its name otherwise something might break, all others will be postfixed with their instance number
|
|
|
|
if (pcIn->mInstanceNumber > 1)
|
|
|
|
{
|
|
|
|
char tmp[12];
|
|
|
|
ASSIMP_itoa10(tmp, pcIn->mInstanceNumber);
|
|
|
|
std::string tempStr = pcIn->mName + "_inst_";
|
|
|
|
tempStr += tmp;
|
|
|
|
pcOut->mName.Set(tempStr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pcOut->mName.Set(pcIn->mName);
|
2009-01-20 21:41:17 +00:00
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// Now build the transformation matrix of the node
|
|
|
|
// ROTATION
|
2009-02-11 20:56:05 +00:00
|
|
|
if (pcIn->aRotationKeys.size()){
|
2009-11-19 23:22:53 +00:00
|
|
|
|
|
|
|
// FIX to get to Assimp's quaternion conventions
|
|
|
|
for (std::vector<aiQuatKey>::iterator it = pcIn->aRotationKeys.begin(); it != pcIn->aRotationKeys.end(); ++it) {
|
|
|
|
(*it).mValue.w *= -1.f;
|
|
|
|
}
|
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
pcOut->mTransformation = aiMatrix4x4( pcIn->aRotationKeys[0].mValue.GetMatrix() );
|
|
|
|
}
|
2009-02-11 20:56:05 +00:00
|
|
|
else if (pcIn->aCameraRollKeys.size())
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
{
|
|
|
|
aiMatrix4x4::RotationZ(AI_DEG_TO_RAD(- pcIn->aCameraRollKeys[0].mValue),
|
|
|
|
pcOut->mTransformation);
|
|
|
|
}
|
|
|
|
|
|
|
|
// SCALING
|
|
|
|
aiMatrix4x4& m = pcOut->mTransformation;
|
|
|
|
if (pcIn->aScalingKeys.size())
|
|
|
|
{
|
|
|
|
const aiVector3D& v = pcIn->aScalingKeys[0].mValue;
|
|
|
|
m.a1 *= v.x; m.b1 *= v.x; m.c1 *= v.x;
|
|
|
|
m.a2 *= v.y; m.b2 *= v.y; m.c2 *= v.y;
|
|
|
|
m.a3 *= v.z; m.b3 *= v.z; m.c3 *= v.z;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TRANSLATION
|
|
|
|
if (pcIn->aPositionKeys.size())
|
|
|
|
{
|
|
|
|
const aiVector3D& v = pcIn->aPositionKeys[0].mValue;
|
|
|
|
m.a4 += v.x;
|
|
|
|
m.b4 += v.y;
|
|
|
|
m.c4 += v.z;
|
|
|
|
}
|
|
|
|
|
2008-11-04 20:41:11 +00:00
|
|
|
// Generate animation channels for the node
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
if (pcIn->aPositionKeys.size() > 1 || pcIn->aRotationKeys.size() > 1 ||
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
pcIn->aScalingKeys.size() > 1 || pcIn->aCameraRollKeys.size() > 1 ||
|
|
|
|
pcIn->aTargetPositionKeys.size() > 1)
|
2008-11-04 20:41:11 +00:00
|
|
|
{
|
|
|
|
aiAnimation* anim = pcSOut->mAnimations[0];
|
|
|
|
ai_assert(NULL != anim);
|
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
if (pcIn->aCameraRollKeys.size() > 1)
|
2008-11-04 20:41:11 +00:00
|
|
|
{
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
DefaultLogger::get()->debug("3DS: Converting camera roll track ...");
|
2008-11-04 20:41:11 +00:00
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// Camera roll keys - in fact they're just rotations
|
|
|
|
// around the camera's z axis. The angles are given
|
|
|
|
// in degrees (and they're clockwise).
|
|
|
|
pcIn->aRotationKeys.resize(pcIn->aCameraRollKeys.size());
|
|
|
|
for (unsigned int i = 0; i < pcIn->aCameraRollKeys.size();++i)
|
|
|
|
{
|
|
|
|
aiQuatKey& q = pcIn->aRotationKeys[i];
|
|
|
|
aiFloatKey& f = pcIn->aCameraRollKeys[i];
|
2008-11-04 20:41:11 +00:00
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
q.mTime = f.mTime;
|
2009-11-19 23:22:53 +00:00
|
|
|
|
|
|
|
// FIX to get to Assimp quaternion conventions
|
|
|
|
q.mValue = aiQuaternion(0.f,0.f,AI_DEG_TO_RAD( /*-*/ f.mValue));
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
}
|
2008-11-04 20:41:11 +00:00
|
|
|
}
|
2009-01-20 21:41:17 +00:00
|
|
|
#if 0
|
2008-11-26 22:03:14 +00:00
|
|
|
if (pcIn->aTargetPositionKeys.size() > 1)
|
|
|
|
{
|
|
|
|
DefaultLogger::get()->debug("3DS: Converting target track ...");
|
|
|
|
|
|
|
|
// Camera or spot light - need to convert the separate
|
|
|
|
// target position channel to our representation
|
|
|
|
TargetAnimationHelper helper;
|
|
|
|
|
|
|
|
if (pcIn->aPositionKeys.empty())
|
|
|
|
{
|
|
|
|
// We can just pass zero here ...
|
|
|
|
helper.SetFixedMainAnimationChannel(aiVector3D());
|
|
|
|
}
|
|
|
|
else helper.SetMainAnimationChannel(&pcIn->aPositionKeys);
|
|
|
|
helper.SetTargetAnimationChannel(&pcIn->aTargetPositionKeys);
|
|
|
|
|
|
|
|
// Do the conversion
|
|
|
|
std::vector<aiVectorKey> distanceTrack;
|
|
|
|
helper.Process(&distanceTrack);
|
|
|
|
|
|
|
|
// Now add a new node as child, name it <ourName>.Target
|
|
|
|
// and assign the distance track to it. This is that the
|
|
|
|
// information where the target is and how it moves is
|
|
|
|
// not lost
|
|
|
|
D3DS::Node* nd = new D3DS::Node();
|
|
|
|
pcIn->push_back(nd);
|
|
|
|
|
|
|
|
nd->mName = pcIn->mName + ".Target";
|
|
|
|
|
|
|
|
aiNodeAnim* nda = anim->mChannels[anim->mNumChannels++] = new aiNodeAnim();
|
|
|
|
nda->mNodeName.Set(nd->mName);
|
|
|
|
|
|
|
|
nda->mNumPositionKeys = (unsigned int)distanceTrack.size();
|
|
|
|
nda->mPositionKeys = new aiVectorKey[nda->mNumPositionKeys];
|
|
|
|
::memcpy(nda->mPositionKeys,&distanceTrack[0],
|
|
|
|
sizeof(aiVectorKey)*nda->mNumPositionKeys);
|
2009-04-09 21:37:49 +00:00
|
|
|
}
|
|
|
|
#endif
|
2009-01-20 21:41:17 +00:00
|
|
|
|
2009-04-09 21:37:49 +00:00
|
|
|
// Cameras or lights define their transformation in their parent node and in the
|
|
|
|
// corresponding light or camera chunks. However, we read and process the latter
|
|
|
|
// to to be able to return valid cameras/lights even if no scenegraph is given.
|
|
|
|
for (unsigned int n = 0; n < pcSOut->mNumCameras;++n) {
|
|
|
|
if (pcSOut->mCameras[n]->mName == pcOut->mName) {
|
|
|
|
pcSOut->mCameras[n]->mLookAt = aiVector3D(0.f,0.f,1.f);
|
2009-01-20 21:41:17 +00:00
|
|
|
}
|
2009-04-09 21:37:49 +00:00
|
|
|
}
|
|
|
|
for (unsigned int n = 0; n < pcSOut->mNumLights;++n) {
|
|
|
|
if (pcSOut->mLights[n]->mName == pcOut->mName) {
|
|
|
|
pcSOut->mLights[n]->mDirection = aiVector3D(0.f,0.f,1.f);
|
2009-01-20 21:41:17 +00:00
|
|
|
}
|
2008-11-26 22:03:14 +00:00
|
|
|
}
|
2008-11-16 21:56:45 +00:00
|
|
|
|
2009-01-20 21:41:17 +00:00
|
|
|
// Allocate a new node anim and setup its name
|
2008-11-16 21:56:45 +00:00
|
|
|
aiNodeAnim* nda = anim->mChannels[anim->mNumChannels++] = new aiNodeAnim();
|
|
|
|
nda->mNodeName.Set(pcIn->mName);
|
|
|
|
|
|
|
|
// POSITION keys
|
|
|
|
if (pcIn->aPositionKeys.size() > 0)
|
2008-11-04 20:41:11 +00:00
|
|
|
{
|
2008-11-16 21:56:45 +00:00
|
|
|
nda->mNumPositionKeys = (unsigned int)pcIn->aPositionKeys.size();
|
|
|
|
nda->mPositionKeys = new aiVectorKey[nda->mNumPositionKeys];
|
|
|
|
::memcpy(nda->mPositionKeys,&pcIn->aPositionKeys[0],
|
|
|
|
sizeof(aiVectorKey)*nda->mNumPositionKeys);
|
2008-11-04 20:41:11 +00:00
|
|
|
}
|
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
// ROTATION keys
|
|
|
|
if (pcIn->aRotationKeys.size() > 0)
|
2008-11-04 20:41:11 +00:00
|
|
|
{
|
2008-11-16 21:56:45 +00:00
|
|
|
nda->mNumRotationKeys = (unsigned int)pcIn->aRotationKeys.size();
|
|
|
|
nda->mRotationKeys = new aiQuatKey[nda->mNumRotationKeys];
|
2008-11-04 20:41:11 +00:00
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
// Rotations are quaternion offsets
|
|
|
|
aiQuaternion abs;
|
|
|
|
for (unsigned int n = 0; n < nda->mNumRotationKeys;++n)
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
{
|
2008-11-16 21:56:45 +00:00
|
|
|
const aiQuatKey& q = pcIn->aRotationKeys[n];
|
2008-11-04 20:41:11 +00:00
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
abs = (n ? abs * q.mValue : q.mValue);
|
|
|
|
nda->mRotationKeys[n].mTime = q.mTime;
|
|
|
|
nda->mRotationKeys[n].mValue = abs.Normalize();
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
}
|
2008-11-16 21:56:45 +00:00
|
|
|
}
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
// SCALING keys
|
|
|
|
if (pcIn->aScalingKeys.size() > 0)
|
|
|
|
{
|
|
|
|
nda->mNumScalingKeys = (unsigned int)pcIn->aScalingKeys.size();
|
|
|
|
nda->mScalingKeys = new aiVectorKey[nda->mNumScalingKeys];
|
|
|
|
::memcpy(nda->mScalingKeys,&pcIn->aScalingKeys[0],
|
|
|
|
sizeof(aiVectorKey)*nda->mNumScalingKeys);
|
2008-11-04 20:41:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// Allocate storage for children
|
2008-06-01 12:46:17 +00:00
|
|
|
pcOut->mNumChildren = (unsigned int)pcIn->mChildren.size();
|
2008-05-05 12:36:31 +00:00
|
|
|
pcOut->mChildren = new aiNode*[pcIn->mChildren.size()];
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
// Recursively process all children
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
const unsigned int size = pcIn->mChildren.size();
|
|
|
|
for (unsigned int i = 0; i < size;++i)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
|
|
|
pcOut->mChildren[i] = new aiNode();
|
|
|
|
pcOut->mChildren[i]->mParent = pcOut;
|
2008-11-04 20:41:11 +00:00
|
|
|
AddNodeToGraph(pcSOut,pcOut->mChildren[i],pcIn->mChildren[i],abs);
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-11-04 20:41:11 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// Find out how many node animation channels we'll have finally
|
|
|
|
void CountTracks(D3DS::Node* node, unsigned int& cnt)
|
|
|
|
{
|
2009-01-20 21:41:17 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2008-11-04 20:41:11 +00:00
|
|
|
// We will never generate more than one channel for a node, so
|
|
|
|
// this is rather easy here.
|
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
if (node->aPositionKeys.size() > 1 || node->aRotationKeys.size() > 1 ||
|
|
|
|
node->aScalingKeys.size() > 1 || node->aCameraRollKeys.size() > 1 ||
|
|
|
|
node->aTargetPositionKeys.size() > 1)
|
2008-11-04 20:41:11 +00:00
|
|
|
{
|
|
|
|
++cnt;
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
|
2009-01-20 21:41:17 +00:00
|
|
|
// account for the additional channel for the camera/spotlight target position
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
if (node->aTargetPositionKeys.size() > 1)++cnt;
|
2008-11-04 20:41:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Recursively process all children
|
|
|
|
for (unsigned int i = 0; i < node->mChildren.size();++i)
|
|
|
|
CountTracks(node->mChildren[i],cnt);
|
|
|
|
}
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
// Generate the output node graph
|
|
|
|
void Discreet3DSImporter::GenerateNodeGraph(aiScene* pcOut)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
|
|
|
pcOut->mRootNode = new aiNode();
|
2008-10-31 19:32:00 +00:00
|
|
|
if (0 == mRootNode->mChildren.size())
|
|
|
|
{
|
2009-01-20 21:41:17 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2013-03-21 18:54:55 +00:00
|
|
|
// It seems the file is so messed up that it has not even a hierarchy.
|
2008-05-05 12:36:31 +00:00
|
|
|
// generate a flat hiearachy which looks like this:
|
|
|
|
//
|
|
|
|
// ROOT_NODE
|
|
|
|
// |
|
|
|
|
// ----------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
// | | | | |
|
|
|
|
// MESH_0 MESH_1 MESH_2 ... MESH_N CAMERA_0 ....
|
2008-05-05 12:36:31 +00:00
|
|
|
//
|
2008-08-09 22:39:57 +00:00
|
|
|
DefaultLogger::get()->warn("No hierarchy information has been found in the file. ");
|
2008-05-25 22:29:05 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
pcOut->mRootNode->mNumChildren = pcOut->mNumMeshes +
|
|
|
|
mScene->mCameras.size() + mScene->mLights.size();
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
pcOut->mRootNode->mChildren = new aiNode* [ pcOut->mRootNode->mNumChildren ];
|
|
|
|
pcOut->mRootNode->mName.Set("<3DSDummyRoot>");
|
|
|
|
|
|
|
|
// Build dummy nodes for all meshes
|
|
|
|
unsigned int a = 0;
|
|
|
|
for (unsigned int i = 0; i < pcOut->mNumMeshes;++i,++a)
|
|
|
|
{
|
|
|
|
aiNode* pcNode = pcOut->mRootNode->mChildren[a] = new aiNode();
|
2008-05-05 12:36:31 +00:00
|
|
|
pcNode->mParent = pcOut->mRootNode;
|
|
|
|
pcNode->mMeshes = new unsigned int[1];
|
|
|
|
pcNode->mMeshes[0] = i;
|
|
|
|
pcNode->mNumMeshes = 1;
|
2008-05-25 22:29:05 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// Build a name for the node
|
2015-06-05 07:52:06 +00:00
|
|
|
pcNode->mName.length = sprintf(pcNode->mName.data,"3DSMesh_%u",i);
|
2008-10-31 19:32:00 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// Build dummy nodes for all cameras
|
|
|
|
for (unsigned int i = 0; i < (unsigned int )mScene->mCameras.size();++i,++a)
|
|
|
|
{
|
|
|
|
aiNode* pcNode = pcOut->mRootNode->mChildren[a] = new aiNode();
|
|
|
|
pcNode->mParent = pcOut->mRootNode;
|
|
|
|
|
|
|
|
// Build a name for the node
|
|
|
|
pcNode->mName = mScene->mCameras[i]->mName;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Build dummy nodes for all lights
|
|
|
|
for (unsigned int i = 0; i < (unsigned int )mScene->mLights.size();++i,++a)
|
|
|
|
{
|
|
|
|
aiNode* pcNode = pcOut->mRootNode->mChildren[a] = new aiNode();
|
|
|
|
pcNode->mParent = pcOut->mRootNode;
|
|
|
|
|
|
|
|
// Build a name for the node
|
|
|
|
pcNode->mName = mScene->mLights[i]->mName;
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
}
|
2008-11-01 15:14:00 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// First of all: find out how many scaling, rotation and translation
|
|
|
|
// animation tracks we'll have afterwards
|
2008-11-04 20:41:11 +00:00
|
|
|
unsigned int numChannel = 0;
|
|
|
|
CountTracks(mRootNode,numChannel);
|
|
|
|
|
|
|
|
if (numChannel)
|
|
|
|
{
|
|
|
|
// Allocate a primary animation channel
|
|
|
|
pcOut->mNumAnimations = 1;
|
|
|
|
pcOut->mAnimations = new aiAnimation*[1];
|
|
|
|
aiAnimation* anim = pcOut->mAnimations[0] = new aiAnimation();
|
|
|
|
|
|
|
|
anim->mName.Set("3DSMasterAnim");
|
|
|
|
|
|
|
|
// Allocate enough storage for all node animation channels,
|
|
|
|
// but don't set the mNumChannels member - we'll use it to
|
|
|
|
// index into the array
|
|
|
|
anim->mChannels = new aiNodeAnim*[numChannel];
|
|
|
|
}
|
|
|
|
|
|
|
|
aiMatrix4x4 m;
|
|
|
|
AddNodeToGraph(pcOut, pcOut->mRootNode, mRootNode,m);
|
2008-11-01 15:14:00 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2014-01-30 01:39:04 +00:00
|
|
|
// We used the first and second vertex color set to store some temporary values so we need to cleanup here
|
|
|
|
for (unsigned int a = 0; a < pcOut->mNumMeshes; ++a)
|
|
|
|
{
|
2008-05-05 12:36:31 +00:00
|
|
|
pcOut->mMeshes[a]->mColors[0] = NULL;
|
2014-01-30 01:39:04 +00:00
|
|
|
pcOut->mMeshes[a]->mColors[1] = NULL;
|
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2011-03-08 17:46:39 +00:00
|
|
|
pcOut->mRootNode->mTransformation = aiMatrix4x4(
|
2011-02-27 19:47:00 +00:00
|
|
|
1.f,0.f,0.f,0.f,
|
|
|
|
0.f,0.f,1.f,0.f,
|
|
|
|
0.f,-1.f,0.f,0.f,
|
2011-03-08 17:46:39 +00:00
|
|
|
0.f,0.f,0.f,1.f) * pcOut->mRootNode->mTransformation;
|
2009-01-20 21:41:17 +00:00
|
|
|
|
|
|
|
// If the root node is unnamed name it "<3DSRoot>"
|
|
|
|
if (::strstr( pcOut->mRootNode->mName.data, "UNNAMED" ) ||
|
2009-12-24 11:34:57 +00:00
|
|
|
(pcOut->mRootNode->mName.data[0] == '$' && pcOut->mRootNode->mName.data[1] == '$') )
|
2009-01-20 21:41:17 +00:00
|
|
|
{
|
|
|
|
pcOut->mRootNode->mName.Set("<3DSRoot>");
|
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
// Convert all meshes in the scene and generate the final output scene.
|
|
|
|
void Discreet3DSImporter::ConvertScene(aiScene* pcOut)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
// Allocate enough storage for all output materials
|
|
|
|
pcOut->mNumMaterials = (unsigned int)mScene->mMaterials.size();
|
|
|
|
pcOut->mMaterials = new aiMaterial*[pcOut->mNumMaterials];
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// ... and convert the 3DS materials to aiMaterial's
|
2008-05-05 12:36:31 +00:00
|
|
|
for (unsigned int i = 0; i < pcOut->mNumMaterials;++i)
|
|
|
|
{
|
2011-08-22 20:22:51 +00:00
|
|
|
aiMaterial* pcNew = new aiMaterial();
|
2008-10-31 19:32:00 +00:00
|
|
|
ConvertMaterial(mScene->mMaterials[i],*pcNew);
|
2008-05-05 12:36:31 +00:00
|
|
|
pcOut->mMaterials[i] = pcNew;
|
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
// Generate the output mesh list
|
|
|
|
ConvertMeshes(pcOut);
|
|
|
|
|
|
|
|
// Now copy all light sources to the output scene
|
|
|
|
pcOut->mNumLights = (unsigned int)mScene->mLights.size();
|
|
|
|
if (pcOut->mNumLights)
|
|
|
|
{
|
|
|
|
pcOut->mLights = new aiLight*[pcOut->mNumLights];
|
|
|
|
::memcpy(pcOut->mLights,&mScene->mLights[0],sizeof(void*)*pcOut->mNumLights);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now copy all cameras to the output scene
|
|
|
|
pcOut->mNumCameras = (unsigned int)mScene->mCameras.size();
|
|
|
|
if (pcOut->mNumCameras)
|
|
|
|
{
|
|
|
|
pcOut->mCameras = new aiCamera*[pcOut->mNumCameras];
|
|
|
|
::memcpy(pcOut->mCameras,&mScene->mCameras[0],sizeof(void*)*pcOut->mNumCameras);
|
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2009-01-18 23:48:25 +00:00
|
|
|
|
|
|
|
#endif // !! ASSIMP_BUILD_NO_3DS_IMPORTER
|