|
From: Daniele C. <dca...@in...> - 2008-05-12 08:45:17
|
At last I installed Visual studio 8 into my Computer. So I can utilize Mutating Algorithms. With mac I increase very much performance. I use the function doLoadModel modified like below but I have an error when I call MergeTriMeshes function. An example of file is at www.interstudio.net/quesa/Roof.3DMF Have you some idea? //============================================================================= // doLoadModel : Loads a Model from File //----------------------------------------------------------------------------- static TQ3Object doLoadModel(TQ3ViewObject theView) { TQ3StorageObject storageObj; TQ3Object notOptimizedModel,theModel; float xBounds, yBounds, zBounds, scaleFactor; TQ3BoundingBox theBounds; TQ3Vector3D translateToOrigin = { 0.0f, 0.0f, 0.0f }; TQ3Matrix4x4 translateMatrix; TQ3Matrix4x4 scaleMatrix; TextureImporterProcPtr funcPtr = TextureImportCallback; TQ3BoundingBox dummyBounds; // Get the file storageObj = Qut_SelectMetafileToOpen(); if( storageObj == NULL ) return NULL; // Attach texture import callback in case this is VRML. #if !TARGET_API_MAC_OS8 Q3Object_SetProperty( storageObj, kTextureImportCallbackPropertyType, sizeof(TextureImporterProcPtr), &funcPtr ); #endif // Read the file (note, this disposes of storageObj) notOptimizedModel = Qut_ReadModel(storageObj); // Adjust the scale and translation required for the model // // Qut positions the camera 5 units away from the origin, with a hither-yon // distance of ~10 units. By scaling the object to be 3.75f units across, // we obtain something which fits within the visible range of the camera. if(notOptimizedModel) { // theModel=optmizeModel(notOptimizedModel,theView); TQ3Status stato; TQ3ViewStatus viewStatus; TQ3BoundingBox dummyBounds; RemoveExtraReferences(notOptimizedModel); stato=Q3View_StartBoundingBox( theView, kQ3ComputeBoundsApproximate ); Qut_SubmitDefaultState(theView); DecomposeGeometries( notOptimizedModel, theView ); viewStatus=Q3View_EndBoundingBox( theView, &dummyBounds ); if(stato==kQ3Success) do { Q3Object_Submit(notOptimizedModel,theView); DecomposeGeometries( notOptimizedModel, theView ); viewStatus=Q3View_EndBoundingBox( theView, &dummyBounds); }//do while (viewStatus==kQ3ViewStatusRetraverse); LowerAttributesToGeometries( notOptimizedModel); //TQ3GroupObject oldgroup=notOptimizedModel; theModel=(TQ3GroupObject) FlattenHierarchy(notOptimizedModel,0 ); //Q3Object_Dispose(oldgroup); OptimizeTriMeshes(theModel); MergeTriMeshes( theModel); Qut_CalcBounds(theView, theModel, &theBounds); xBounds = (theBounds.max.x - theBounds.min.x); yBounds = (theBounds.max.y - theBounds.min.y); zBounds = (theBounds.max.z - theBounds.min.z); scaleFactor = (xBounds > yBounds) ? xBounds : yBounds; scaleFactor = (zBounds > scaleFactor) ? zBounds : scaleFactor; scaleFactor = 3.75f / scaleFactor; translateToOrigin.x = -(theBounds.min.x + (xBounds * 0.5f)); translateToOrigin.y = -(theBounds.min.y + (yBounds * 0.5f)); translateToOrigin.z = -(theBounds.min.z + (zBounds * 0.5f)); Q3Matrix4x4_SetTranslate(&translateMatrix,translateToOrigin.x,translateToOrigin.y,translateToOrigin.z); Q3Matrix4x4_SetScale(&scaleMatrix,scaleFactor,scaleFactor,scaleFactor); Q3Matrix4x4_SetIdentity(&gMatrixCurrent); Q3Matrix4x4_Multiply(&gMatrixCurrent,&translateMatrix,&gMatrixCurrent); Q3Matrix4x4_Multiply(&gMatrixCurrent,&scaleMatrix,&gMatrixCurrent); } return theModel; } |