public:
Render3D()
{};
virtual
~Render3D() {};
// Setup and Cleanup need
to have additions here, but still call the parent versions
virtual
void Setup( ImageBuffer *imageBuffer );
virtual
void Cleanup( void ) { Render2D::Cleanup();
};
// Overload this function
to get extra work done at start frame
virtual
void StartFrame( void );
// Set the camera parameters
we're to use for rendering
void SetObjectDetail( float
scaler );
void SetFOV( float horizontal_fov
);
void
SetFar( float distance ) { far_clip = distance; };
void SetCamera( const Tpoint*
pos, const Trotation* rot );
float
GetObjectDetail( void ) { return detailScaler; };
float
GetFOV( void )
{ return horizontal_half_angle * 2.0f; };
float
GetVFOV( void )
{ return vertical_half_angle * 2.0f; };
float
GetDFOV( void )
{ return diagonal_half_angle * 2.0f; };
virtual void SetViewport( float leftSide, float topSide, float rightSide, float bottomSide );
// Setup the 3D object lighting
void SetLightDirection(
const Tpoint* dir );
void GetLightDirection(
Tpoint* dir );
// Trun 3D object texturing
on/off
void SetObjectTextureState(
BOOL state );
BOOL
GetObjectTextureState( void )
{ return objTextureState; };
//
Get the location and orientation of the camera for this renderer
float
X( void ) { return cameraPos.x; };
float
Y( void ) { return cameraPos.y; };
float
Z( void ) { return cameraPos.z; };
float
Yaw( void )
{ return yaw; };
float
Pitch( void ) { return pitch; };
float
Roll( void ) { return roll; };
void
GetAt( Tpoint *v )
{ v->x = cameraRot.M11, v->y = cameraRot.M12, v->z = cameraRot.M13; };
void
GetLeft( Tpoint *v ) { v->x = cameraRot.M21, v->y = cameraRot.M22,
v->z = cameraRot.M23; };
void
GetUp( Tpoint *v )
{ v->x = cameraRot.M31, v->y = cameraRot.M32, v->z = cameraRot.M33; };
// Transform the given worldspace
point into pixel coordinates using the current camera
void TransformPoint(
Tpoint* world, ThreeDVertex* pixel );
void TransformPointToView(
Tpoint* world, Tpoint *result );
void TransformBillboardPoint(
Tpoint* world, Tpoint *viewOffset, ThreeDVertex* pixel );
void TransformTreePoint(
Tpoint* world, Tpoint *viewOffset, ThreeDVertex* pixel );
void UnTransformPoint(
Tpoint* pixel, Tpoint* vector );
void TransformCameraCentricPoint(
Tpoint* world, ThreeDVertex* pixel );
float ZDistanceFromCamera(
Tpoint* p );
// Draw flat shaded geometric
primitives in world space using the current camera parameters
void Render3DPoint( Tpoint*
p1 );
void Render3DLine( Tpoint*
p1, Tpoint* p2 );
void Render3DFlatTri( Tpoint*
p1, Tpoint* p2, Tpoint* p3 );
void Render3DObject( GLint
id, Tpoint* pos, const Trotation* orientation );
// Draw a full featured square
or tri given the already transformed (but not clipped) verts
void DrawSquare( ThreeDVertex*
v0, ThreeDVertex* v1, ThreeDVertex* v2, ThreeDVertex* v3, int CullFlag
);
void DrawTriangle( ThreeDVertex*
v0, ThreeDVertex* v1, ThreeDVertex* v2, int CullFlag );
protected:
// Draw a fan which is known
to require clipping
void ClipAndDraw3DFan( ThreeDVertex**
vertPointers, unsigned count, int CullFlag );
private:
void IntersectNear(
ThreeDVertex *v1, ThreeDVertex *v2, ThreeDVertex *v );
void IntersectTop(
ThreeDVertex *v1, ThreeDVertex *v2, ThreeDVertex *v );
void IntersectBottom( ThreeDVertex
*v1, ThreeDVertex *v2, ThreeDVertex *v );
void IntersectLeft(
ThreeDVertex *v1, ThreeDVertex *v2, ThreeDVertex *v );
void IntersectRight(
ThreeDVertex *v1, ThreeDVertex *v2, ThreeDVertex *v );
protected:
float
far_clip;
float
detailScaler;
float
resRelativeScaler;
BOOL
objTextureState;
float
horizontal_half_angle;
float
vertical_half_angle;
float
diagonal_half_angle;
float
oneOVERtanHFOV;
float
oneOVERtanVFOV;
float
yaw;
float
pitch;
float
roll;
Tpoint
cameraPos;
// Camera position in world space
Trotation
cameraRot;
// Camera orientation matrix
float
lightAmbient;
float
lightDiffuse;
Tpoint
lightVector;
Tpoint
move;
// Camera space translation required to position visible objects
Trotation
T;
// Transformation matrix including aspect ratio and FOV effects
Trotation
Tbb;
// Transformation matrix for billboards
Trotation
Tt;
// Transformation matrix for trees