Faking simple 3D

Hello,

I’m currently trying to make some tunnelling effect. Really simple, nothing fancy. I thought it would be rather simple, but I find myself unable to perform this… I would appreciate any help, because there is apparently something I’m missing…
Here is my code :

@
kmVec3 vEyes, vLookAt, vUp;
vUp.x = 0, vUp.y = 1.f, vUp.z = 0;
vEyes.x = 0, vEyes.y = 0, vEyes.z = mfCurrentProgress;
vLookAt.x = 0, vLookAt.y = 0, vLookAt.z = mfCurrentProgress + 50;

kmMat4 mPerspective, mView, mGlobal;
kmMat4LookAt( &mView, &vEyes, &vLookAt, &vUp );
kmMat4PerspectiveProjection( &mPerspective, 50.f, FRAME_SIZE.width / FRAME_SIZE.height, 5.f, 5000.f );
kmMat4Multiply( &mGlobal, &mPerspective, &mView );

for( std::list< Section >::const_iterator it = mitCurrentFirstSection;
it != mlevelDef.end(); ++it )
{
kmVec3 vRefPosition;
vRefPosition.x = 0;
vRefPosition.y = 0;
vRefPosition.z = it~~>depth;
kmVec3 vScreenPosition;
kmVec3Transform;
kmVec3 vRefPosition2;
vRefPosition2.x = 0;
vRefPosition2.y = 25;
vRefPosition2.z = it~~>depth();
kmVec3 vScreenPosition2;
kmVec3Transform( &vScreenPosition2, &vRefPosition2, &mGlobal );

// Draw the section
glLineWidth( 2 );
ccDrawColor4B( 180, 12, 12, 255 );
CCPoint pt2DRef( vScreenPosition2.x - vScreenPosition.x, vScreenPosition2.y - vScreenPosition.y );
ccDrawCircle( CCPoint( FRAME_SIZE.width / 2, FRAME_SIZE.height / 2 ), ccpLength( pt2DRef ), 0, 8,
false, 1, 1 );
}
@

mfCurrentProgress increases with time so we should move along the “tube”.

Thanks for any help, guys. And thanks for your time, no matter what :slight_smile:

ccdrawcircle has its drawing shader set up by:
CCGLProgram::setUniformsForBuiltins()

it uses:
kmGLGetMatrix(KM_GL_PROJECTION, &matrixP);
kmGLGetMatrix(KM_GL_MODELVIEW, &matrixMV);

to transform the drawing…
so i guess you would have to multiply one of these matrixes.
the kmGL classes are pretty self explanatory… since it looks like you got your head around how to use the kmMat4 ones.

ccdrawcircle has its drawing shader set up by:
CCGLProgram::setUniformsForBuiltins()

it uses:
kmGLGetMatrix(KM_GL_PROJECTION, &matrixP);
kmGLGetMatrix(KM_GL_MODELVIEW, &matrixMV);

to transform the drawing…
so i guess you would have to multiply one of these matrixes.
the kmGL classes are pretty self explanatory… since it looks like you got your head around how to use the kmMat4 ones.

Thank you for your answer. I’ll try to see what I can make out of these.

Nevertheless, I’m sorry but maybe it was too candid to paste my entire functions code… In fact my problem is not directly related to the drawcircle part. What I’m trying to do is convert myself my 3D world coordinates to 2D screen coordinates. Then I’m using some shortcuts to get simple concentric tube-like shape stuff with the drawCircle calls.

But apparently my method isn’t the right, I just can’t figure out myself what I missed in my matrix stuff…