home *** CD-ROM | disk | FTP | other *** search
- /****************************/
- /* BOX.C */
- /****************************/
-
-
- /****************************/
- /* EXTERNALS */
- /****************************/
-
- #include <qd3d.h>
- #include <QD3DGeometry.h>
- #include <QD3DSet.h>
- #include <QD3DView.h>
- #include <QD3DShader.h>
- #include <QD3DGroup.h>
- #include <QD3DRenderer.h>
- #include <QD3DAcceleration.h>
- #include <QD3DDrawContext.h>
-
- extern TQ3ViewObject gMyViewObject;
- extern TQ3StyleObject gMyStyleObject_Interpolation;
- extern TQ3StyleObject gMyStyleObject_Backfacing;
- extern TQ3StyleObject gMyStyleObject_Fillstyle;
- extern TQ3ShaderObject gMyShaderObject_IlluminationShader;
-
-
-
- /****************************/
- /* PROTOTYPES */
- /****************************/
-
- extern void DoFatalAlert(Str255 s);
-
- void CreateMyBoxObject(void);
- void DrawMyObjects(void);
-
-
- /****************************/
- /* CONSTANTS */
- /****************************/
-
-
- /*********************/
- /* VARIABLES */
- /*********************/
-
- TQ3GeometryObject gMyBoxObject;
-
-
- /****************** CREATE MY BOX OBJECT ******************/
- //
- // Creates and returns a box geometry object.
- //
- // INPUT : none
- // OUTPUT : box object
- //
-
- void CreateMyBoxObject(void)
- {
- TQ3ColorRGB color = {1.0,1.0,1.0}; // make it white
- TQ3AttributeSet attribs;
- float ambient = 1.0;
- TQ3Point3D origin = {0,0,0};
- TQ3Vector3D orientation = {0,2,0};
- TQ3Vector3D majorAxis = {0,0,2};
- TQ3Vector3D minorAxis = {2,0,0};
- TQ3BoxData boxData;
- TQ3Status myStatus;
-
-
- /* CREATE ATTRIBUTES FOR BOX */
-
- attribs = Q3AttributeSet_New(); // make new attrib object
- if (attribs == nil)
- DoFatalAlert("\pUnable to create new attribute Set!");
-
- // add color attribute
- myStatus = Q3AttributeSet_Add(attribs, kQ3AttributeTypeDiffuseColor, &color);
- if ( myStatus == kQ3Failure )
- DoFatalAlert("\p Q3AttributeSet_Add Failed!");
-
- // add ambient attribute
- myStatus = Q3AttributeSet_Add(attribs, kQ3AttributeTypeAmbientCoefficient, &ambient);
- if ( myStatus == kQ3Failure )
- DoFatalAlert("\p Q3AttributeSet_Add Failed!");
-
-
- /* SET BOX INITIALIZE DATA */
-
- boxData.origin = origin; // set box origin coords
- boxData.orientation = orientation; // set orientation vector
- boxData.majorAxis = majorAxis; // set major axis vector
- boxData.minorAxis = minorAxis; // set minor axis vector
- boxData.faceAttributeSet = nil; // faces will inherit attribs...
- boxData.boxAttributeSet = attribs; // ... from entire box's attribs
-
- gMyBoxObject = Q3Box_New(&boxData); // make new box object from data
- if (gMyBoxObject == nil)
- DoFatalAlert("\pError creating new Box geometry");
-
-
- /* DISPOSE OF OUR REFERENCE TO THE ATTRIBUTES */
-
- Q3Object_Dispose(attribs);
- }
-
-
- /******************* DRAW MY OBJECTS *********************/
- //
- // Draws a frame of animation for the FlyThru window.
- //
-
- void DrawMyObjects(void)
- {
- TQ3Status myStatus;
- TQ3ViewStatus myViewStatus;
-
- /* START RENDERING */
-
- myStatus = Q3View_StartRendering(gMyViewObject); // start rendering
- if ( myStatus == kQ3Failure )
- DoFatalAlert("\p Q3View_StartRendering Failed!");
-
- do
- {
- /* SET INTERPOLATION STYLE */
-
- myStatus = Q3Style_Submit(gMyStyleObject_Interpolation,gMyViewObject);
- if ( myStatus == kQ3Failure )
- DoFatalAlert("\p Q3Style_Submit Failed!");
-
- /* SET BACKFACING STYLE */
-
- myStatus = Q3Style_Submit(gMyStyleObject_Backfacing,gMyViewObject);
- if ( myStatus == kQ3Failure )
- DoFatalAlert("\p Q3Style_Submit Failed!");
-
-
- /* SET FILL STYLE */
-
- myStatus = Q3Style_Submit(gMyStyleObject_Fillstyle, gMyViewObject);
- if ( myStatus == kQ3Failure )
- DoFatalAlert("\p Q3Style_Submit Failed!");
-
-
- /* SET SHADER TO USE */
-
- myStatus = Q3Shader_Submit(gMyShaderObject_IlluminationShader, gMyViewObject);
- if ( myStatus == kQ3Failure )
- DoFatalAlert("\p Q3Shader_Submit Failed!");
-
-
- /* DRAW THE BOX OBJECT */
-
- myStatus = Q3Geometry_Submit(gMyBoxObject,gMyViewObject);
- if ( myStatus == kQ3Failure )
- DoFatalAlert("\p Drawing box Failed!");
-
- /* SEE IF DONE */
-
- myViewStatus = Q3View_EndRendering(gMyViewObject);
-
- } while ( myViewStatus == kQ3ViewStatusRetraverse );
-
- }
-
-
-
-