home *** CD-ROM | disk | FTP | other *** search
- #if !defined(_OBJECT_H)
- #define _OBJECT_H
-
- /**********************************************************************
- *
- * File : object.h
- *
- * Abstract : The interface to a "sub-class" of RenderWare clumps
- * which provides enhanced functionality such as binding a
- * light to a clump which acts as the visual representation
- * of a light and also stores the filename of the file from
- * which the clump was loaded.
- *
- * This application had been written to be compatible with
- * both the fixed and floating-point versions of the
- * RenderWare library, i.e., it uses the macros CREAL,
- * INT2REAL, RAdd, RDiv, RSub etc. If your application is
- * intended for the floating-point version of the library
- * only these macros are not necessary.
- *
- * Please note that this application is intended for
- * demonstration purposes only. No support will be
- * provided for this code and it comes with no warranty.
- *
- **********************************************************************
- *
- * This file is a product of Criterion Software Ltd.
- *
- * This file is provided as is with no warranties of any kind and is
- * provided without any obligation on Criterion Software Ltd. or
- * Canon Inc. to assist in its use or modification.
- *
- * Criterion Software Ltd. will not, under any
- * circumstances, be liable for any lost revenue or other damages arising
- * from the use of this file.
- *
- * Copyright (c) 1994, 1995 Criterion Software Ltd.
- * All Rights Reserved.
- *
- * RenderWare is a trademark of Canon Inc.
- *
- **********************************************************************/
-
- /**********************************************************************
- *
- * Comment:
- *
- * This code demonstrates the use of the user data pointer which is
- * supported by most RenderWare objects. The user data pointer allows
- * additional information to be stored with an object by setting the
- * user data pointer to an application defined structure.
- *
- * The viewer manipulates two main kinds of RenderWare objects, clumps
- * and lights. RenderWare lights are normally invisible but to make
- * manipulation uniform between the two object types we create a clump
- * to represent each light. We therefore need some mechanism to tie
- * a light and the clump which represents it together (and vice-versa).
- * This is one of the uses to which we put the user data to.
- *
- * Also, in order to give object's identifiable names and to allow us
- * to save them under their original filenames we need to be able to
- * store the filename of the file storing the clump. We also use the
- * user-data field for this purpose.
- *
- * We define a structure which holds a filename string and a light
- * object handle (which may be NULL if the clump does not represent
- * a light). An instance of this structure is stored in the user
- * data field of each clump. For lights, however, we simply store
- * the handle of the clump representing the light directly in the
- * user data field.
- *
- **********************************************************************/
-
- /**********************************************************************
- *
- * Type definitions.
- *
- **********************************************************************/
-
- /*
- * different types of objects present
- */
- typedef enum
- {
- rfIsClump,
- rfIsSprite,
- rfIsSpline,
- rfIsPaletteSprite,
- rfIsLight,
- rfNoMoveClump
- } rfDataType;
-
- /*
- * This is the user data structure stored with each clump. It consists
- * of a filename string which will be empty for clumps not loaded from
- * a file (such as those which represent lights) and a light pointer
- * which will be NULL for those clumps which do not represent lights.
- */
- typedef struct
- {
- char fileName[_MAX_PATH]; /* The file storing this clump */
- RwLight *light; /* The light this clump represents */
- rfDataType datatype; /* type of object */
- } ClumpUserData;
-
- /**********************************************************************
- *
- * Macro functions.
- *
- **********************************************************************/
-
- /*
- * Return the clump's user data pointer. If this clump is a child
- * in a clump hiearchy it has no user data so the user data of the
- * clump at the root of the hierarcy is returned.
- */
- #define GETCLUMPUSERDATA(clump) ((ClumpUserData *)RwGetClumpData(RwGetClumpRoot(clump)))
-
- /*
- * Get the clump's file name (may be empty).
- */
- #define GETCLUMPFILENAME(clump) (GETCLUMPUSERDATA(clump)->fileName)
-
- /*
- * Return the light associated with a clump (if it has one).
- */
- #define GETCLUMPLIGHT(clump) (GETCLUMPUSERDATA(clump)->light)
-
- /*
- * Return the datatype associated with a clump (if it has one).
- */
- #define GETOBJECTTYPE(clump) (GETCLUMPUSERDATA(clump)->datatype)
-
- /*
- * Test whether the clump is the visual representation of a light
- * or an object in its own right.
- */
- #define ISCLUMPLIGHT(clump) (GETCLUMPLIGHT(clump) != NULL)
-
- /*
- * Return the clump which is the visual representation of a light.
- */
- #define GETLIGHTCLUMP(light) ((RwClump *)RwGetLightData(light))
-
- /**********************************************************************
- *
- * Functions.
- *
- **********************************************************************/
-
- /*
- * Read a clump from the given file. This function creates and
- * initializes the user data structure of the clump.
- *
- * RenderWare API Equivalent: RwReadShape()
- */
- extern RwClump *ReadClumpObj(char *fileName);
-
- /*
- * Create a sprite from the bitmap contained in the given file.
- *
- * RenderWare API Equivalent: RwCreateSprite()
- */
- extern RwClump *CreateSpriteObj(char *fileName);
-
- /*
- * Create a light of the given type. A clump is built which represents
- * this light and is attached to the user data field of the light.
- *
- * NOTE: We return a pointer to the clump build rather than the light
- * as clump's are the main object type of the viewer.
- *
- * RenderWare API Equivalent: RwCreateLight()
- */
- extern RwLight *CreateLightObj(RwLightType kind);
-
- /*
- * Duplicate the given clump object and its associated light (if it has
- * one).
- *
- * RenderWare API Equivalent: RwDuplicateClump(), RwDuplicateLight().
- */
- extern RwClump *DuplicateClumpObj(RwClump *);
-
- /*
- * Add a clump object to the given scene. This function will also add the
- * light object to the scene if the the clump represents a light.
- *
- * RenderWare API Equivalent: RwAddClumpToScene(), RwAddLightToScene().
- */
- extern RwScene *AddClumpObjToScene(RwScene *scene, RwClump *clump);
-
- /*
- * Add a light object to the given scene. This function will also add the
- * clump object representing a light to the scene.
- *
- * RenderWare API Equivalent: RwAddLightToScene(), RwAddClumpToScene().
- */
- extern RwScene *AddLightObjToScene(RwScene *scene, RwLight *light);
-
- /*
- * Set the brightness of the given light object. This function also
- * updates the visual appearance of the clump object representing the
- * light to reflect the new brightness.
- *
- * RenderWare API Equivalent: RwSetLightBrightness().
- */
- extern RwLight *SetLightObjBrightness(RwLight *light, RwReal bright);
-
- /*
- * Set the color of the given light object. This function also
- * updates the visual appearance of the clump object representing the
- * light to reflect the new color.
- *
- * RenderWare API Equivalent: RwSetLightColor().
- */
- extern RwLight *SetLightObjColor(RwLight *light, RwReal r, RwReal g, RwReal b);
-
- /*
- * Turn the clump which is the visible representation of a light on or off.
- * This function does not turn the light itself on or off, it only
- * shows or hides the visible representation of that light.
- *
- * RenderWare API Equivalent: RwSetClumpState().
- */
- extern RwLight *SetLightObjVisibleState(RwLight *light, RwState state);
-
- /*
- * Destory the given clump object (and its associated light if it has
- * one). This function will also free the user data structure allocated
- * for the clump.
- *
- * RenderWare API Equivalent: RwDestoryClump()
- */
- extern void DestroyClumpObj(RwClump *clump);
-
- /**********************************************************************/
-
- #endif /* !defined(_OBJECT_H) */