@eulphean wrote:
Hello all,
I’m trying to draw some 3D models that I’m loading with ofxAssimpModelLoader. I’m able to draw the first 3D model successfully as I followed the assimpLoader example in oF. However, I need to draw a collection of the second 3D model at each of the vertex of the first 3D model. Here’s my code.
#include "ofApp.h" CoinObject::CoinObject() { model.loadModel("HighCoin.obj", true); model.setRotation(0, 0, 0, 0, 0); model.setScale(0.9, 0.9, 0.9); } //-------------------------------------------------------------- void ofApp::setup(){ ofBackground(ofColor::black); ofSetVerticalSync(true); // Load the 1st 3D model. humanModel.loadModel("Breathing.dae", false); humanModel.setPosition(0, 0, 0); humanModel.setRotation(0, 180, 0, 0, 1); humanModel.setScale(1.5, 1.5, 1.5); humanModel.setLoopStateForAllAnimations(OF_LOOP_NORMAL); humanModel.setPausedForAllAnimations(false); humanModel.playAllAnimations(); humanMesh = humanModel.getCurrentAnimatedMesh(0); topLight.setPosition(0, 500, 500); bottomLight.setPosition(0, -500, 500); ofEnableBlendMode(OF_BLENDMODE_ALPHA); // Create a collection of 2nd 3D model for each vertex of the mesh. auto vertexCount = humanMesh.getVertices().size(); for (int i = 0; i < vertexCount; i++) { CoinObject *coin = new CoinObject(); coins.push_back(coin); } } //-------------------------------------------------------------- void ofApp::update(){ humanModel.update(); humanMesh = humanModel.getCurrentAnimatedMesh(0); } //-------------------------------------------------------------- void ofApp::draw(){ ofEnableDepthTest(); ofEnableLighting(); topLight.enable(); bottomLight.enable(); ofPushMatrix(); cam.begin(); drawMeshVertices(); cam.end(); ofPopMatrix(); bottomLight.disable(); topLight.disable(); ofDisableLighting; ofDisableDepthTest(); } void ofApp::drawMeshVertices() { ofPushMatrix(); ofFill(); ofSetColor(ofColor::red); ofxAssimpMeshHelper & meshHelper = humanModel.getMeshHelper(0); ofMultMatrix(humanModel.getModelMatrix()); ofMultMatrix(meshHelper.matrix); for (int i = 0; i < humanMesh.getVertices().size(); i++) { // None of the coins can be seen on the screen. coins[i] -> model.drawFaces(); } ofPopMatrix(); }
I need to call ofMultMatrix twice to draw the mesh for the 1st 3D model. I tried calling that for the 2nd model as well before the drawFaces call on the coin model, but nothing shows up on the screen. Any suggestion/advice? Thanks in advance
Posts: 3
Participants: 1