#include <ros/ros.h>
#include <urdf2inventor/AssimpImport.h>
#include <assimp/Importer.hpp>
#include <assimp/importerdesc.h>
#include <assimp/postprocess.h>
#include <boost/filesystem.hpp>
#include <Inventor/nodes/SoTransform.h>
#include <Inventor/nodes/SoIndexedPointSet.h>
#include <Inventor/nodes/SoIndexedLineSet.h>
#include <Inventor/nodes/SoIndexedTriangleStripSet.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/nodes/SoTexture2.h>
#include <iostream>
#include <sstream>
Go to the source code of this file.
Functions | |
void | addNode (SoSeparator *const parent, const aiNode *const node, const aiMaterial *const *const materials, const aiMesh *const *const meshes, const aiTexture *const *const textures, const std::string &sceneDir, const SoMaterial *materialOverride) |
SoSeparator * | Assimp2Inventor (const aiScene *const scene, const std::string &sceneDir, const SoMaterial *materialOverride) |
std::vector< std::string > | assimpImportedExtensions () |
std::vector< std::pair < std::string, std::vector < std::string > > > | assimpImportedFormats () |
SoMaterial * | cloneMaterial (const SoMaterial &m) |
SoMaterial * | getMaterial (const aiMaterial *const material) |
SoSeparator * | getMesh (const aiMesh *const mesh, const aiMaterial *const material, const std::string &sceneDir, SoSeparator *meshSep=NULL, const SoMaterial *materialOverride=NULL) |
SbName | getName (const std::string &name) |
SoIndexedShape * | getShape (const aiMesh *const mesh) |
SoTexture2 * | getTexture (const aiTexture *const texture) |
SoTexture * | getTexture (const aiMaterial *const material, const std::string &sceneDir) |
SoTransform * | getTransform (const aiMatrix4x4 &matrix) |
bool | hasMesh (const aiNode *node) |
void | printTransform (const aiMatrix4x4 &matrix) |
std::vector< std::string > | tokenize (const std::string &str, const std::string &token) |
void addNode | ( | SoSeparator *const | parent, |
const aiNode *const | node, | ||
const aiMaterial *const *const | materials, | ||
const aiMesh *const *const | meshes, | ||
const aiTexture *const *const | textures, | ||
const std::string & | sceneDir, | ||
const SoMaterial * | materialOverride | ||
) |
materialOverride | can be used to override material properties. |
Definition at line 537 of file AssimpImport.cpp.
SoSeparator* Assimp2Inventor | ( | const aiScene *const | scene, |
const std::string & | sceneDir, | ||
const SoMaterial * | materialOverride | ||
) |
materialOverride | can be used to override ALL NODES material properties to given values. |
I don't know how they will be referenced inside the scene
Definition at line 595 of file AssimpImport.cpp.
std::vector<std::string> assimpImportedExtensions | ( | ) |
Definition at line 627 of file AssimpImport.cpp.
std::vector<std::pair<std::string, std::vector<std::string> > > assimpImportedFormats | ( | ) |
Definition at line 638 of file AssimpImport.cpp.
SoMaterial* cloneMaterial | ( | const SoMaterial & | m | ) |
Definition at line 285 of file AssimpImport.cpp.
SoMaterial* getMaterial | ( | const aiMaterial *const | material | ) |
Definition at line 297 of file AssimpImport.cpp.
SoSeparator* getMesh | ( | const aiMesh *const | mesh, |
const aiMaterial *const | material, | ||
const std::string & | sceneDir, | ||
SoSeparator * | meshSep = NULL , |
||
const SoMaterial * | materialOverride = NULL |
||
) |
Definition at line 496 of file AssimpImport.cpp.
SbName getName | ( | const std::string & | name | ) |
Definition at line 45 of file AssimpImport.cpp.
SoIndexedShape* getShape | ( | const aiMesh *const | mesh | ) |
How to map UV channels to textures (MATKEY_UVWSRC)? The MATKEY_UVWSRC property is only present if the source format doesn't specify an explicit mapping from textures to UV channels. Many formats don't do this and assimp is not aware of a perfect rule either.
Your handling of UV channels needs to be flexible therefore. Our recommendation is to use logic like this to handle most cases properly:
have only one uv channel? assign channel 0 to all textures and break
for all textures have uvwsrc for this texture? assign channel specified in uvwsrc else assign channels in ascending order for all texture stacks, i.e. diffuse1 gets channel 1, opacity0 gets channel 0.
Definition at line 359 of file AssimpImport.cpp.
SoTexture2* getTexture | ( | const aiTexture *const | texture | ) |
texture->pcData is a pointer to a memory buffer of size mWidth containing the compressed texture data I do not know how to extract this information
Definition at line 131 of file AssimpImport.cpp.
SoTexture* getTexture | ( | const aiMaterial *const | material, |
const std::string & | sceneDir | ||
) |
I only know how to deal with aiTextureType_DIFFUSE textures and with only one texture. Other types and the other DIFFUSE texture but the first will be ignored. A texture has a transformation, an UV index, a blend factor, an operation and some flags but all these properties will also be ignored. Transform should be removed by the post process step, ut aiUVTransform => SoTexture2Transform ? UV index only has a valid value if mapping == aiTextureMapping_UV Operation should have something related with SoTextureCombiner How I know when I need to use SoTexture3 or Sotexture2? I don't know how to check if the image has been loaded correctly texture->model is always set to DECAL, is that good? It should be related with the loaded info
If it is not defined, suppose it is aiTextureMapping_UV
How to check if image was loaded?
Definition at line 163 of file AssimpImport.cpp.
SoTransform* getTransform | ( | const aiMatrix4x4 & | matrix | ) |
Definition at line 108 of file AssimpImport.cpp.
bool hasMesh | ( | const aiNode * | node | ) |
Definition at line 524 of file AssimpImport.cpp.
void printTransform | ( | const aiMatrix4x4 & | matrix | ) |
Definition at line 78 of file AssimpImport.cpp.
std::vector<std::string> tokenize | ( | const std::string & | str, |
const std::string & | token | ||
) |
Definition at line 613 of file AssimpImport.cpp.