Newbie Perspective Problem

Started by
2 comments, last by blood angel 23 years, 7 months ago
Ive tried the search 10 times now and I keep getting a ''timeout'' error, and I realise this must be one of the most asked posts. Sorry. But I ask what are the formulas to show a 3d object with perspective? This is the only part of my demo that isn''t working. I''d be grateful for any help or pointers that anyone can give. Thanks.
Advertisement
Well, the regulars here don't seem too interested in answering this question anymore, as I asked it a few topics down ("Total Newbie to 3d programming") as part of my question. Anyway, I've been doing some research, and I found this:

http://www.geom.umn.edu/docs/reference/CRC-formulas/node37.html

The projection formula it gives does require that you be working in homogeneous coordinates, but since I'm doing that anyway, it isn't a big deal for me. It might be too much trouble for you to change your demo if you aren't using them though. Hopefully, someone might see fit to at least post some more resources if they don't feel like answering themselves.


Edited by - c_wraith on September 16, 2000 6:39:22 PM
Thanks c_wraith. I know this must be an unwanted recurring question.
If you're interested here's my Projection code:

        void Project( POINT3D *pVertex, POINT3D *pResult, unsigned long ulNumVertices, FLOAT fproj, FLOAT fOffX, FLOAT fOffY ){	ASSERT( pVertex );	ASSERT( pResult );	ASSERT( ulNumVertices > 0 );	ASSERT( !_isnan( fproj ));	ASSERT( !_isnan( fOffX ));	ASSERT( !_isnan( fOffY ));	unsigned long	i;	FLOAT			k, k0, k1;	POINT3D			*pVertexIn = &pVertex[0];	POINT3D			*pVertexOut = &pResult[0];	//	// Utilize the fact that a/b AND c/d is equivalent to	// ad/bd AND ac/bd :-) Thus cutting the number of divs	// by half!! We have:	//	//	1 div and 3 muls/two pixels	//			VS	//	2 divs/two pixels	//	// so as long as a div is more expensive than 1.5 muls we're OK!!!	// Also we're unrolled our loop 2x and with the no-pointer-aliasing	// optimization, we should be in good shape...	//	unsigned long ulHalfVerts = ulNumVertices&~0x1;	for( i=0; i<ulHalfVerts; i+=2 )	{		ASSERT( pVertexIn<i>.IsValid());		ASSERT( pVertexIn[i+1].IsValid());                k = fproj/(pVertexIn<i>.z * pVertexIn[i+1].z);		k0 = pVertexIn[i+1].z*k;		k1 = pVertexIn[i].z*k;                pVertexOut[i].x = fOffX + k0*pVertexIn[i].x;                pVertexOut[i].y = fOffY + k0*pVertexIn[i].y;		pVertexOut[i].z = pVertexIn[i].z;                pVertexOut[i+1].x = fOffX + k1*pVertexIn[i+1].x;                pVertexOut[i+1].y = fOffY + k1*pVertexIn[i+1].y;		pVertexOut[i+1].z = pVertexIn[i+1].z;	}	if ( ulNumVertices&0x1 )	{		i = ulNumVertices-1;		ASSERT( pVertexIn[i].IsValid());		// Do the last transition		k = fproj/pVertexIn[i].z;                pVertexOut[i].x = fOffX + k*pVertexIn[i].x;                pVertexOut[i].y = fOffY + k*pVertexIn[i].y;		pVertexOut[i].z = pVertexIn[i].z;	}}        



Edited by - neocron on September 19, 2000 4:25:38 PM

This topic is closed to new replies.

Advertisement