Ejemplo n.º 1
0
TQ3Status QD3DSupport_DocDraw3DData( DocumentPtr theDocument )
{

	Q3View_StartRendering(theDocument->fView );
	do
	{		
		Q3Style_Submit( theDocument->fInterpolation, theDocument->fView );
		Q3Style_Submit( theDocument->fBackFacing, theDocument->fView );
		Q3Style_Submit( theDocument->fFillStyle, theDocument->fView );
		Q3DisplayGroup_Submit( theDocument->fTrackGroup, theDocument->fView );
		Q3DisplayGroup_Submit( theDocument->fGroundGroup, theDocument->fView );

	} while (Q3View_EndRendering(theDocument->fView) == kQ3ViewStatusRetraverse );

	Track_MoveCamera(theDocument->fCamera,
					theDocument->fSplinePointsPtr,
					theDocument->fNumSplinePoints,
					&theDocument->fTrackIndex);

	return kQ3Success ;
}
bool LoadModel_QD3D(FileSpecifier& Spec, Model3D& Model)
{
	// Clear out the final model object
	Model.Clear();
	
	// Test for QD3D/Quesa's presence and initialize it if not present
	if (QD3D_Presence_Checked)
	{
		if (!QD3D_Present) return false;
	}
	else
	{
		QD3D_Presence_Checked = true;
		
		// MacOS QD3D; modify this for Quesa as appropriate
		if ((void*)Q3Initialize != (void*)kUnresolvedCFragSymbolAddress)
		{
			TQ3Status Success = Q3Initialize();
			QD3D_Present = (Success == kQ3Success);
		}
		
		// Do additional setup;
		// if the triangulator could not be created, then act as if
		// QD3D/Quesa had not been loaded
		if (QD3D_Present)
		{
			Q3Error_Register(QD3D_Error_Handler,0);
			QD3D_Present = CreateTriangulator();
		}
		if (!QD3D_Present)
			Q3Exit();
	}
	
	if (DBOut)
	{
		// Read buffer
		const int BufferSize = 256;
		char Buffer[BufferSize];
		Spec.GetName(Buffer);
		fprintf(DBOut,"Loading QuickDraw-3D model file %s\n",Buffer);
	}
	
	TQ3Object ModelObject = LoadModel(Spec);
	if (!ModelObject) return false;
	
	StartAccumulatingVertices();
	
	if (Q3View_StartRendering(TriangulatorView) == kQ3Failure)
	{
		if (DBOut) fprintf(DBOut,"ERROR: couldn't start triangulation 'rendering'\n");
		Q3Object_Dispose(ModelObject);
		return false;
	}
	do
	{
		Q3SubdivisionStyle_Submit(&TesselationData, TriangulatorView);
		if (Q3Object_Submit(ModelObject, TriangulatorView) == kQ3Failure)
		{
			if (DBOut) fprintf(DBOut,"ERROR: model could not be 'rendered'\n");
		}
	}
	while (Q3View_EndRendering(TriangulatorView) == kQ3ViewStatusRetraverse);

	// Done with the model
	Q3Object_Dispose(ModelObject);
	
	GetVerticesIntoModel(Model);
	
	return !Model.Positions.empty();
}