home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Learn 3D Graphics Programming on the PC
/
Learn_3D_Graphics_Programming_on_the_PC_Ferraro.iso
/
rwwin
/
rfview.h_
/
rfview.bin
Wrap
Text File
|
1995-11-14
|
12KB
|
394 lines
#if !defined(_RFVIEW_H)
#define _RFVIEW_H
/*
* The application instance handle (from rfview.c).
*/
extern HINSTANCE AppInstance;
/**********************************************************************
*
* Macro functions.
*
**********************************************************************/
/*
* Macros to convert real numbers in the range CREAL(0.0) to CREAL(1.0)
* (which RenderWare uses to represent the value of a color channel) to
* integers in the range 0 to 255 (which Windows uses to represent the
* value of the a color channel). We use the Windows style in the user
* interface because users are more used to 0 to 255.
*/
#define BYTETOREAL(v) (RDiv(INT2REAL((RwInt32)(v)), CREAL(255.0)))
#define REALTOBYTE(r) ((int)(REAL2INT(RMul((r), CREAL(255.0)))))
/*
* A macro to convert a RenderWare RwRGBColor to a Windows COLORREF.
*/
#define RWTOCOLORREF(rgb) \
(PALETTERGB(REALTOBYTE((rgb)->r), REALTOBYTE((rgb)->g), REALTOBYTE((rgb)->b)))
/**********************************************************************
*
* Functions.
*
**********************************************************************/
/*
* Convert a RenderWare RwRGBColor to a Windows COLORREF.
*/
extern COLORREF RGBToColorRef(RwRGBColor *rgb);
/*
* Convert a Windows COLORREF to a RenderWare RwRGBColor.
*/
extern RwRGBColor *ColorRefToRGB(COLORREF color, RwRGBColor *rgb);
/**********************************************************************/
#include "object.h"
#include "rtramp.h"
#ifndef M_PI
#define M_PI 3.141592654
#endif /* M_PI */
#define M_2PI 6.283185308
/**********************************************************************
*
* Type definitions.
*
**********************************************************************/
/*
* This enumerated type tells us what kind of action should be taken
* on mouse events.
*/
typedef enum
{
mmNoAction,
mmScrollBackdrop,
mmMoveAndTurnCamera,
mmTiltCamera,
mmSpinClump,
mmDragClump,
mmDragClumpInZ
} MMMode;
/**********************************************************************
*
* Application global variables.
*
**********************************************************************/
/* defines */
#define TwoPI 6.2831852
#define rfSideA 1111 // tags for side used when changing materials
#define rfSideB 1112 // tags for side used when changing materials
#define rfSideC 1113 // tags for side used when changing materials
#define rfSideD 1114 // tags for side used when changing materials
#define rfSideAll 1115 // tags for all sides used when changing materials
#define MAX_RSCROLL 100 // rotation maximum value (-0.5 to +0.5)
#define MAX_SCROLL 500 // translate maximum value (-2.5 to +2.5)
#define MAX_SCROLLS 1000 // scale maximum value (-5 to +5)
#define MAX_CP_SCROLL 2400 // camera maximum position and point at (-12 to +12)
#define MAX_CSCROLL 18000 // camera angle maximum (-90 to +90)
#define MAX_REPEAT 500 // maximum repeat count (0 to 500)
#define WINDOWTAG 1234 // special window in a wall tag to animate material directly
#define MODTEXTURE 1235 // tag for a polygon that is used for modifying texture
#define MODCOLOR 0031 // modify the raster with this color
// ************************************* start of Ferraro ******************************
/* structure to hold info on animating materials */
typedef struct {
RwBool Ambient;
RwBool Diffuse;
RwBool Specular;
RwBool MatAnimate;
float vAmbient,AmbientInc;
float vDiffuse,DiffuseInc;
float vSpecular,SpecularInc;
} rfSurfMom;
/* structure used for manipulating the cameras */
typedef struct {
RwV3d pos;
RwReal vw_width,vw_height;
double angle;
float aspect;
RwV3d point;
RwReal val; // angle of rotation, amount o
int repeat; // repeat count
} rfCamera;
// transform structure
typedef struct {
RwReal x,y,z; // axis of rotation or translation or origin of scale
int val; // angle of rotation
int repeat; // repeat count
RwCombineOperation combine; // combine operator
} rfTransform;
// debugging structure
typedef struct {
RwDebugSeverity Severity;
RwDebugState Message,Assertion,Script;
RwDebugState Output,Trace;
} rfDebugging;
// relative coordinate transformation working structure
typedef struct {
RwV3d pos,up,at,right,vc;
} rfRelative;
/*
* Class name for the MS Window's window class.
*/
#define RWVIEWCLASSNAME "RwViewClass"
/*
* Window title.
*/
#define WINDOWTITLE "RenderWare 3D Object Viewer"
/*
* Default size of the viewer's window.
*/
#define DEFAULTWINDOWWIDTH 1280 // 440
#define DEFAULTWINDOWHEIGHT 1024 // 450
#define DEFAULTNUMSPLINESAMPLES 100
#if defined(CONSTRAIN_SIZE)
/*
* Maximum size of the viewer's window.
*/
#define MAXIMUMWINDOWWIDTH 1280 // 512
#define MAXIMUMWINDOWHEIGHT 1024 // 522
#endif
/*
* The default size of the viewwindow.
*/
#define DEFAULTVIEWWINDOWSIZE CREAL(0.4)
/*
* Default distance of the camera from the origin.
*/
#define DEFAULTCAMERADISTANCE CREAL(7.0)
/* Default minimum height of a spline control point. */
#define DEFAULTMINCONTROLPOINTHEIGHT CREAL(0.1)
/* Default maximum height of a spline control point.*/
#define DEFAULTMAXCONTROLPOINTHEIGHT CREAL(2.0)
/* Spline tracking parameters. */
#define MINSPLINEDELTA CREAL(0.002)
#define DEFAULTSPLINEDELTA CREAL(0.004)
#define MAXSPLINEDELTA CREAL(0.010)
#define DEFAULTNUMCONTROLPOINTS 20
/* structure used for spline definition mostly taken from rwRoller */
typedef struct
{
RwSpline *spline;
RwClump *controlPointClumps[DEFAULTNUMCONTROLPOINTS];
RwClump *coasterClump;
RwReal t;
RwReal tDelta;
RwV3d tAt;
RwV3d tUp;
RwV3d tRight;
RwV3d tPosition;
char description[20];
char filename[80];
} RollerCoasterType;
// main definition occurs only in rfView.c
#ifdef MAIN
RollerCoasterType *coaster; // spline
rfRelative rfRel; // relative (local) coordinate working structure
HWND CurrentWindow; // current window
rfDebugging rfDebug; // debugging window
rfSurfMom rfSurf; // surface momentum
RwBool rfReadSprite; // should we read sprites
RwBool rfBirdsEye,rfPaletteView; // is birds eye view and/or palette sprite displayed
/*
* The bird's eye sprite and the texture the sprite uses. We could
* just keep a handle on the sprite and find the texture from it
* each time it is needed but for simplicitly we will keep a handle on
* both.
*/
RwCamera *BirdsEyeCamera = NULL;
RwTexture *BirdsEyeTexture = NULL,*PaletteTexture = NULL;
RwClump *BirdsEyeSprite = NULL,*PaletteSprite = NULL;
RwCamera *CurrentCamera = NULL;
rfCamera rfCam; // camera working structure
rfTransform rfTran,rfRot,rfScale,rfLoc; // transform structure for translatino, rotation, scaling and location
RwBool rfRepeatMode = FALSE; // if we are in repeat mode then do not show bounding box
float textureRate=(float)1.0,accumulatedRate=(float)0.0; // texture animation variables
/*
* Global RenderWare object pointers. In this simple application we
* make use of only a single scene, camera and light.
*/
RwScene *Scene = NULL;
RwCamera *Camera = NULL;
int DisplayDepth;
/*
* This variable is used to remember which clump was last picked
* when spinning or dragging a clump on mouse move events.
*/
RwClump *SelectedClump = NULL;
/*
* This is the clump used to highlight the currently picked clump.
*/
RwClump *HighlightClump = NULL;
/*
* This matrix is used when spinning a clump, it is stored globally
* so that it is not necessary to re-build the matrix for each frame of
* animation.
*/
RwMatrix4d *SpinMatrix = NULL;
/*
* This variable tells us whether the clump should be spun with
* momentum. Why do we need this as well as the Momentum setting?
* Well Momentum is TRUE if an object can have momentum (even if it
* does not currently have moment where SpinClump is TRUE only if we
* are actually spinning a clump with momentum currently.
*/
BOOL SpinClump = FALSE;
/*
* This variable tells us what kind of action to take on a mouse move.
* The action depends on the object that was picked when the mouse button
* went down, and on the selection of virtual keys that were depressed at
* that time. By default no action is taken on mouse move.
*/
MMMode MouseMoveMode = mmNoAction;
/*
* Global variables used to remember the last mouse X and Y coordinates
* when involved in a pan, zoom, drag or spin.
*/
int LastX;
int LastY;
/*
* This stores the offset from the initial pick position to the origin
* of the picked clump. It used so that we drag objects by their picked
* position rather than by their origin.
*/
RwV3d PickOffset;
/*
* Current animation frame number. This is incremented each time a
* frame is drawn on timer expiry. The purpose of this variable is
* to enable us to periodically (based on the number of frames) call
* RwOrthoNormalizeMatrix() to correct any errors which have crept
* into the clump's joint matrix because of the inevitable
* restrictions on the accuracy of fixed-point numbers. See
* HandleTimer for more details.
*/
int FrameNumber = 0;
/*
* This flag indicates whether the 3D components of the application
* have been successfully initialized as yet. It is used to guard
* the message loop handler functions from being invoked before the
* 3D components of the application are successfully initialized.
*/
BOOL RwIsOpen = FALSE;
/*
* This is the last filename opened by the viewer. This is stored
* so that we can initialize the file open dialog with the last file
* loaded each time.
*/
char LastFileName[_MAX_PATH];
/*
* are we showing spline track
*/
BOOL HideSpline;
/*
* are we showing control points on the spline
*/
BOOL HideControlPoints;
/*
* are we using acceleration and deceleration on the spline
*/
BOOL UseSmoothEnd;
/*
* should object travel along spline
*/
BOOL TravelSpline;
#else // external definitions: See above for description.
extern RollerCoasterType *coaster;
extern rfRelative rfRel;
extern HWND CurrentWindow;
extern rfDebugging rfDebug;
extern rfSurfMom rfSurf;
extern RwBool rfReadSprite;
extern RwBool rfBirdsEye,rfPaletteView;
extern RwCamera *BirdsEyeCamera;
extern RwTexture *BirdsEyeTexture,*PaletteTexture;
extern RwClump *BirdsEyeSprite,*PaletteSprite;
extern RwCamera *CurrentCamera;
extern rfCamera rfCam;
extern rfTransform rfTran,rfRot,rfScale,rfLoc;
extern RwBool rfRepeatMode;
extern float textureRate,accumulatedRate;
extern RwScene *Scene ;
extern RwCamera *Camera;
extern int DisplayDepth;
extern RwClump *SelectedClump;
extern RwClump *HighlightClump;
extern RwMatrix4d *SpinMatrix;
extern BOOL SpinClump;
extern MMMode MouseMoveMode;
extern int LastX;
extern int LastY;
extern RwV3d PickOffset;
extern int FrameNumber;
extern BOOL RwIsOpen;
extern char LastFileName[_MAX_PATH];
extern BOOL HideSpline;
extern BOOL HideControlPoints;
extern BOOL UseSmoothEnd;
extern BOOL TravelSpline;
#endif
/*
* Spline tracking parameters.
*/
#define MINSPLINEDELTA CREAL(0.002)
#define DEFAULTSPLINEDELTA CREAL(0.004)
#define MAXSPLINEDELTA CREAL(0.010)
#define SPLINEDELTAACCELERATION CREAL(0.0005)
#define SPLINEDELTADECCELERATION CREAL(0.0006)
#endif /* !defined(_RFVIEW_H) */