// build a polygon that is a CIELab refrence TQ3GeometryObject LogoWin2::NewPolyGCIELabRef(void) { TQ3GeometryObject geometryObject = NULL; //TQ3TriGridData ciepoly; TQ3PolygonData ciepoly; TQ3Vertex3D *vertices; long i; double Lxy[4]; double lab[4]; McoStatus state; TQ3ColorRGB color = { 0.0, 0.0, 0.0 }; double big_ab,big_rgb; TQ3Param2D param2D; ciepoly.numVertices = NumCIExyzRef; ciepoly.vertices = (TQ3Vertex3D *) NewPtr (NumCIExyzRef * sizeof(TQ3Vertex3D)); if (ciepoly.vertices == NULL) return NULL; vertices = ciepoly.vertices; ciepoly.polygonAttributeSet = NULL; for (i=0; i<NumCIExyzRef; i++) { Lxy[0] = 50; Lxy[1] = CIExyzRef2[i*4+1]; Lxy[2] = CIExyzRef2[i*4+2]; vertices[i].point.x = Lxy[1]; vertices[i].point.y = Lxy[2]; vertices[i].point.z = 0.5; sxyztolab(Lxy,lab); big_ab = bigger(fabs(lab[1]),fabs(lab[2])); if (big_ab>127) { lab[1] = lab[1]*127/big_ab; lab[2] = lab[2]*127/big_ab; } labtonxyzinplace(lab,1); state = xyztorgb->compute(lab, monitor_z, 1); if(state != MCO_SUCCESS) return NULL; big_rgb = bigger(lab[1],bigger(lab[2],lab[3])); if (big_rgb>255) { lab[0] = lab[0]*255/big_rgb; lab[1] = lab[1]*255/big_rgb; lab[2] = lab[2]*255/big_rgb; } color.r = lab[0]/256; color.g = lab[1]/256; color.b = lab[2]/256; vertices[i].attributeSet = Q3AttributeSet_New(); Q3AttributeSet_Add(vertices[i].attributeSet, kQ3AttributeTypeDiffuseColor, &color); param2D.u = Lxy[1]*1.37; param2D.v = Lxy[2]*1.1; Q3AttributeSet_Add(vertices[i].attributeSet, kQ3AttributeTypeShadingUV, ¶m2D); } geometryObject = Q3Polygon_New(&ciepoly); for (i = 0; i < NumCIExyzRef; i++) Q3Object_Dispose(vertices[i].attributeSet); DisposePtr ((char *) vertices); return geometryObject; }
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; }