collada and artoolkit

Hi guys,

I’ve been working with the ARToolKit example from parmendil here: http://forum.openframeworks.cc/t/augmented-reality/743/0 and trying to get it to work with collada loaded markers, using the collada loader from theo here: http://forum.openframeworks.cc/t/animated-collada-working-in-of/3137/0. I’m trying to combine the two but with limited OpenGL knowledge, and limited CrtRender examples on the internet, I’m not making much progress. Can anyone offer some insight into how this might work? I’m not sure how to draw the model to the screen so that it looks positioned at the marker location.

This is what my draw() method looks like:

  
void testApp::draw(){  
	// === COLLADA stuff starts here  
	_CrtRender.SetScreenWidth(ofGetWidth());  
	_CrtRender.SetScreenHeight(ofGetHeight());		  
	  
	ofTranslate(0, ofGetHeight(), 0);  
	ofScale(1, -1, 1);  
	  
	// draw the feed from the camera to the screen  
	glDisable(GL_CULL_FACE);  
	glDisable(GL_DEPTH_TEST);  
	glDisable(GL_LIGHT0);  
	glDisable(GL_LIGHTING);  
	tempImage.draw(0,0);  
	glEnable(GL_LIGHTING);  
	glEnable(GL_LIGHT0);  
	glEnable(GL_DEPTH_TEST);  
	glEnable(GL_CULL_FACE);  
	  
	// === ARToolKitPlus stuff starts here  
  
	  
         //this is where we use the calculated matrix from ARToolkitPlus to put  
	//in our graphics at the location and orientation of the marker.  
	//- the matrix has the 0,0 point as the center of the marker.   
	  
	int numDetected = tracker->getNumDetectedMarkers();  
	//cout<<"numberofmarkers:"<<numDetected<<endl;  
	  
	glViewport(0, 0, 1280, 720 );  
	glMatrixMode( GL_PROJECTION );  
  
	if (numDetected > 0)  
	{  
		glLoadMatrixf(tracker->getProjectionMatrix());  
		  
		ARToolKitPlus::ARMarkerInfo marker = tracker->getDetectedMarker(0);  
		float m34[ 3 ][ 4 ];  
		float c[ 2 ] = { 0.0f, 0.0f };  
		float w = 40.0f;  
		  
		tracker->rppGetTransMat( &marker, c, w, m34 );  
		  
		float m[ 16 ];  //this is some crazy matrix transformative stuff.   
						//I think initially it came out of one of the arToolkit functions....   
						//but i got it from here: [http://chihara.naist.jp/people/STAFF/imura/computer/OpenGL/artp/disp-content](http://chihara.naist.jp/people/STAFF/imura/computer/OpenGL/artp/disp-content)  
			  
		for ( int i = 0; i < 3; i++ ) {  
			for ( int j = 0; j < 4; j++ ) {  
				m[ j * 4 + i ] = m34[ i ][ j ];  
			}  
		}  
			  
		for ( int j = 0; j < 3; j++ ) {  
			m[ j * 4 + 3 ] = 0.0f;  
		}  
			  
		m[ 3 * 4 + 3 ] = 1.0f;  
		  
		glMatrixMode( GL_MODELVIEW );  
		glLoadMatrixf( m );  
		  
		glPushMatrix();  
		glRotatef(-90, 0, 0, 1);  
		  
	        if(_CrtRender.GetScene()) _CrtRender.Render();   
		  
		glPopMatrix();  
		  
	}  

I’m sure something has to happen around the _CrtRender.Render(); call to affect the geometry of the 3D scene, but I’m not sure what that is. Any help would be great.

Thanks,
J

Oh, I should mention that this code simply displays the loaded model in the middle of the screen, unaffected by the marker, but the marker does get detected.

Hi Jaypozo

You’re right, there’re some modifications to do in the Collada Redender. I already asked to some guys who have posted that they have already did it but I didn’t get any answer from them about how to do it. :slight_smile:

regards!

I’m also searching for a working solution of collada + artoolkit.

I’ve looked at the collada renderer code and I guess the integration is possible with a little bit of hacking the camera class.

There is another question, is it possible to load and render more than 1 collada object (animation). I need to load a different object for the different markers.

Any help will be appreciated! :slight_smile:

If I’ve got any success I’ll bring it back.