class methods
- ofxAssimpModelLoader()
- ~ofxAssimpModelLoader()
- calculateDimensions()
- clear()
- createEmptyModel()
- createLightsFromAiModel()
- disableColors()
- disableMaterials()
- disableNormals()
- disableTextures()
- draw()
- drawFaces()
- drawVertices()
- drawWireframe()
- enableColors()
- enableMaterials()
- enableNormals()
- enableTextures()
- getAnimation()
- getAnimationCount()
- getAssimpScene()
- getCurrentAnimatedMesh()
- getMaterialForMesh()
- getMesh()
- getMeshCount()
- getMeshHelper()
- getMeshNames()
- getModelMatrix()
- getNormalizedScale()
- getNumMeshes()
- getNumRotations()
- getPosition()
- getRotationAngle()
- getRotationAxis()
- getScale()
- getSceneCenter()
- getSceneMax()
- getSceneMin()
- getTextureForMesh()
- hasAnimations()
- hasMeshes()
- loadModel()
- optimizeScene()
- playAllAnimations()
- resetAllAnimations()
- setLoopStateForAllAnimations()
- setNormalizationFactor()
- setPausedForAllAnimations()
- setPosition()
- setPositionForAllAnimations()
- setRotation()
- setScale()
- setScaleNormalization()
- stopAllAnimations()
- update()
ofAssimpModelLoader addon permits loading to memory and processing 3D models in a convenient and unified format. This addon is mostly a wrapper of the "Open Asset Import Library" (assimp), in its version 5.2 https://github.com/assimp/assimp.
For an example see openFrameworks/examples/3d/assimp3DModelLoaderExample
.
At least, these model formats are supported:
- 3DS
- ASE
- DXF
- GLTF
- FBX
- HMP
- MD2
- MD3
- MD5
- MDC
- MDL
- NFF
- PLY
- STL
- X
- LWO
- OBJ
- SMD
- Collada
- Ogre XML
- partly LWS
In order to load a file to memory, you just need to declare a new variable of type ofAssimpModelLoader and use the function loadModel():
ofxAssimpModelLoader model;
model.loadModel("file_name.3DS");
You could draw it using:
void ofApp::draw(){
ofBackground(50, 50, 50, 0);
ofSetColor(255, 255, 255, 255);
model.drawFaces();
}
But probably you would not see the entire model. In the next snippet it appears centered:
void ofApp::draw(){
ofBackground(50, 50, 50, 0);
ofSetColor(255, 255, 255, 255);
model.setPosition(ofGetWidth()/2, (float)ofGetHeight() * 0.75 , 0);
model.drawFaces();
}
There are other two ways to represent the model, by its points or by the wiring between the points. In the next snippet the three ways are represented:
void ofApp::draw(){
ofBackground(50, 50, 50, 0);
ofSetColor(255, 255, 255, 255);
model.setPosition(ofGetWidth()*2/6, (float)ofGetHeight() * 0.75 , 0);
model.draw(OF_MESH_FILL); //same as model.drawFaces();
model.setPosition(ofGetWidth()*3/6, (float)ofGetHeight() * 0.75 , 0);
model.draw(OF_MESH_POINTS); // same as model.drawVertices();
model.setPosition(ofGetWidth()*4/6, (float)ofGetHeight() * 0.75 , 0);
model.draw(OF_MESH_WIREFRAME); // same as model.drawWireframe();
}
We can use model.setScale() to change the size and setRotation() to rotate the model. The next snippet, for instance, draws the model half it's size and if it was looking at you, now is showing it's back:
model.setRotation(0,90,0,1,0);
model.setScale(0.5, 0.5, 0.5);
model.setPosition(ofGetWidth()*2/6, (float)ofGetHeight() * 0.75 , 0);
model.drawFaces();
You can accumulate setRotation() functions for rotating different degrees in different axis if you increment the value of the first variable:
model.setRotation(0, actualXRotation, 1, 0, 0);
model.setRotation(1, actualYRotation, 0, 1, 0);
model.setRotation(2, actualZRotation, 0, 0, 1);
loadModel(...)
bool ofxAssimpModelLoader::loadModel(ofBuffer &buffer, bool optimize=false, const char *extension)
setLoopStateForAllAnimations(...)
void ofxAssimpModelLoader::setLoopStateForAllAnimations(ofLoopType state)
setPositionForAllAnimations(...)
void ofxAssimpModelLoader::setPositionForAllAnimations(float position)
setRotation(...)
void ofxAssimpModelLoader::setRotation(int which, float angle, float rot_x, float rot_y, float r_z)
Last updated 星期二, 19 十一月 2024 17:23:26 UTC - 2537ee49f6d46d5fe98e408849448314fd1f180e
If you have any doubt about the usage of this module you can ask in the forum.
If you want to contribute better documentation or start documenting this section you can do so here
If you find anything wrong with this docs you can report any error by opening an issue