CQ3ObjectRef Duplicator::DuplicateDisplayGroup( TQ3Object inGroup ) { CQ3ObjectRef theDupe; if (Q3Object_IsType( inGroup, kQ3DisplayGroupTypeOrdered )) { theDupe = CQ3ObjectRef( Q3OrderedDisplayGroup_New() ); } else { theDupe = CQ3ObjectRef( Q3DisplayGroup_New() ); } // Copy the display group state TQ3DisplayGroupState theState; Q3DisplayGroup_GetState( inGroup, &theState ); Q3DisplayGroup_SetState( theDupe.get(), theState ); // Duplicate the objects belonging to the group Q3GroupIterator iter( inGroup ); CQ3ObjectRef theItem; while ( (theItem = iter.NextObject()).isvalid() ) { CQ3ObjectRef itemDupe( Duplicate( theItem.get() ) ); Q3Group_AddObject( theDupe.get(), itemDupe.get() ); } return theDupe; }
static TQ3GroupObject QD3DSupport_NewTrackGroup(TQ3ShaderObject theShader) { TQ3GroupObject myGroup = NULL; if ((myGroup = Q3OrderedDisplayGroup_New()) != NULL ) { TQ3GroupPosition myGroupPosition; /* ADD TEXTURE SHADER OBJECT TO GROUP */ myGroupPosition = Q3Group_AddObject(myGroup, theShader); if ( myGroupPosition == nil ) { Utils_DisplayErrorMsg("Group_AddObject failed!"); } } /* Done! */ return ( myGroup ); }
static TQ3GroupObject QD3DSupport_GroundInit(TQ3ShaderObject groundShaderObject) { long i; TQ3GeometryObject polygonObj = NULL; TQ3GroupPosition myGroupPosition; TQ3GroupObject groundGroup; TQ3PolygonData polygonData; TQ3Vertex3D vertices[kNumGrndTextureVertices] = {0,-3,GROUND_SIZE,nil, GROUND_SIZE,-3,GROUND_SIZE,nil, GROUND_SIZE,-3,-GROUND_SIZE,nil, 0,-3,-GROUND_SIZE,nil}; TQ3AttributeSet attribs[kNumGrndTextureVertices] = {NULL, NULL, NULL, NULL}; float ambient = 1.0F; TQ3Param2D uv[kNumGrndTextureVertices] = {0,0,1,0,1,1,0,1}; if (groundShaderObject == NULL) { return NULL; } groundGroup = Q3OrderedDisplayGroup_New(); if (groundGroup == NULL) { return NULL; } /* ADD TEXTURE SHADER OBJECT TO GROUP */ myGroupPosition = Q3Group_AddObject(groundGroup, groundShaderObject); if ( myGroupPosition == nil ) { Utils_DisplayErrorMsg("Q3Group_AddObject failed!"); goto outOfMem; } Q3Object_Dispose(groundShaderObject); /* CREATE VERTICES */ for (i=0; i < kNumGrndTextureVertices; i++) { attribs[i] = Q3AttributeSet_New(); if( attribs[i] == NULL ) { Utils_DisplayErrorMsg("Attribute set creation failed!"); goto outOfMem; } Q3AttributeSet_Add(attribs[i], kQ3AttributeTypeShadingUV, &uv[i]); vertices[i].attributeSet = attribs[i]; } /* CREATE NEW POLYGON OBJECT */ polygonData.numVertices = kNumGrndTextureVertices; polygonData.vertices = vertices; polygonData.polygonAttributeSet = nil; polygonObj = Q3Polygon_New(&polygonData); if( polygonObj == NULL ) { Utils_DisplayErrorMsg("Polygon_New failed!"); goto outOfMem; } for (i=0; i < kNumGrndTextureVertices; i++) { Q3Object_Dispose(attribs[i]); attribs[i] = NULL; } myGroupPosition = Q3Group_AddObject(groundGroup, polygonObj); Q3Object_Dispose(polygonObj); if ( myGroupPosition == nil ) { Utils_DisplayErrorMsg("Q3Group_AddObject failed!"); goto outOfMem; } /* Success! */ return groundGroup; /* Error handling */ outOfMem: if (groundGroup) { Q3Object_Dispose(groundGroup); } for (i=0; i < kNumGrndTextureVertices; i++) { if( attribs[i] ) { Q3Object_Dispose(attribs[i]); } } return NULL; }