#pragma once
#include "ofxAssimpMeshHelper.h"
#include "ofxAssimpAnimation.h"
#include "ofxAssimpTexture.h"
#include "ofMesh.h"
#include "ofPoint.h"
struct aiScene;
struct aiNode;
class ofxAssimpModelLoader{
public:
~ofxAssimpModelLoader();
ofxAssimpModelLoader();
bool loadModel(std::string modelName, bool optimize=false);
bool loadModel(ofBuffer & buffer, bool optimize=false, const char * extension="");
void createEmptyModel();
void createLightsFromAiModel();
void optimizeScene();
void update();
bool hasAnimations();
unsigned int getAnimationCount();
ofxAssimpAnimation & getAnimation(int animationIndex);
void playAllAnimations();
void stopAllAnimations();
void resetAllAnimations();
void setPausedForAllAnimations(bool pause);
void setLoopStateForAllAnimations(ofLoopType state);
void setPositionForAllAnimations(float position);
OF_DEPRECATED_MSG("Use ofxAssimpAnimation instead", void setAnimation(int animationIndex));
OF_DEPRECATED_MSG("Use ofxAssimpAnimation instead", void setNormalizedTime(float time));
OF_DEPRECATED_MSG("Use ofxAssimpAnimation instead", void setTime(float time));
OF_DEPRECATED_MSG("Use ofxAssimpAnimation instead", float getDuration(int animationIndex));
bool hasMeshes();
unsigned int getMeshCount();
ofxAssimpMeshHelper & getMeshHelper(int meshIndex);
void clear();
void setScale(float x, float y, float z);
void setPosition(float x, float y, float z);
void setRotation(int which, float angle, float rot_x, float rot_y, float r_z);
void setScaleNormalization(bool normalize);
void setNormalizationFactor(float factor);
std::vector<std::string> getMeshNames();
unsigned int getNumMeshes();
ofMesh getMesh(std::string name);
ofMesh getMesh(unsigned int num);
ofMesh getCurrentAnimatedMesh(std::string name);
ofMesh getCurrentAnimatedMesh(unsigned int num);
ofMaterial getMaterialForMesh(std::string name);
ofMaterial getMaterialForMesh(unsigned int num);
ofTexture getTextureForMesh(std::string name);
ofTexture getTextureForMesh(unsigned int num);
void drawWireframe();
void drawFaces();
void drawVertices();
void enableTextures();
void disableTextures();
void enableNormals();
void enableMaterials();
void disableNormals();
void enableColors();
void disableColors();
void disableMaterials();
void draw(ofPolyRenderMode renderType);
ofPoint getPosition();
ofPoint getSceneCenter();
float getNormalizedScale();
ofPoint getScale();
ofMatrix4x4 getModelMatrix();
ofPoint getSceneMin(bool bScaled = false);
ofPoint getSceneMax(bool bScaled = false);
int getNumRotations();
ofPoint getRotationAxis(int which);
float getRotationAngle(int which);
void calculateDimensions();
const aiScene * getAssimpScene();
protected:
void updateAnimations();
void updateMeshes(aiNode * node, ofMatrix4x4 parentMatrix);
void updateBones();
void updateModelMatrix();
unsigned int initImportProperties(bool optimize);
bool processScene();
void loadGLResources();
void updateGLResources();
void getBoundingBoxWithMinVector( aiVector3D* min, aiVector3D* max);
void getBoundingBoxForNode(const ofxAssimpMeshHelper & mesh, aiVector3D* min, aiVector3D* max);
ofFile file;
aiVector3D scene_min, scene_max, scene_center;
bool normalizeScale;
double normalizedScale;
std::vector<float> rotAngle;
std::vector<ofPoint> rotAxis;
ofPoint scale;
ofPoint pos;
ofMatrix4x4 modelMatrix;
std::vector<ofLight> lights;
std::vector<ofxAssimpTexture> textures;
std::vector<ofxAssimpMeshHelper> modelMeshes;
std::vector<ofxAssimpAnimation> animations;
int currentAnimation;
bool bUsingTextures;
bool bUsingNormals;
bool bUsingColors;
bool bUsingMaterials;
float normalizeFactor;
std::shared_ptr<const aiScene> scene;
std::shared_ptr<aiPropertyStore> store;
};
Comments