123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- //===========================================================================//
- // Copyright (C) Microsoft Corporation. All rights reserved. //
- //===========================================================================//
- #include "MLRHeaders.hpp"
- //#############################################################################
- //############################ MLREffect #################################
- //#############################################################################
- void EffectClipPolygon::Init()
- {
- Verify(gos_GetCurrentHeap() == StaticHeap);
- coords.SetLength(Limits::Max_Number_Vertices_Per_Polygon);
- colors.SetLength(Limits::Max_Number_Vertices_Per_Polygon);
- texCoords.SetLength(Limits::Max_Number_Vertices_Per_Polygon);
- clipPerVertex.SetLength(Limits::Max_Number_Vertices_Per_Polygon);
- }
- void EffectClipPolygon::Destroy()
- {
- coords.SetLength(0);
- colors.SetLength(0);
- texCoords.SetLength(0);
- clipPerVertex.SetLength(0);
- }
- //#############################################################################
- //############################ MLREffect #################################
- //#############################################################################
- MLREffect::ClassData*
- MLREffect::DefaultData = NULL;
- EffectClipPolygon
- *MLREffect::clipBuffer;
- DynamicArrayOf<Vector4D>
- *MLREffect::transformedCoords;
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //
- void
- MLREffect::InitializeClass()
- {
- Verify(!DefaultData);
- Verify(gos_GetCurrentHeap() == StaticHeap);
- DefaultData =
- new ClassData(
- MLREffectClassID,
- "MidLevelRenderer::MLREffect",
- RegisteredClass::DefaultData
- );
- Register_Object(DefaultData);
-
- transformedCoords = new DynamicArrayOf<Vector4D> (Limits::Max_Number_Vertices_Per_Mesh);
- Register_Object(transformedCoords);
- clipBuffer = new EffectClipPolygon [2];
- Register_Pointer(clipBuffer);
- clipBuffer[0].Init();
- clipBuffer[1].Init();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //
- void
- MLREffect::TerminateClass()
- {
- clipBuffer[1].Destroy();
- clipBuffer[0].Destroy();
- Unregister_Pointer(clipBuffer);
- delete [] clipBuffer;
- Unregister_Object(transformedCoords);
- delete transformedCoords;
- Unregister_Object(DefaultData);
- delete DefaultData;
- DefaultData = NULL;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //
- MLREffect::MLREffect(int nr, ClassData *class_data):
- RegisteredClass(class_data)
- {
- Verify(gos_GetCurrentHeap() == Heap);
- visible = 0;
- maxNrOf = nr;
- testList.SetLength(maxNrOf);
- for(int i=0; i < maxNrOf; i++)
- {
- testList[i] = 0;
- }
-
- TurnAllOff();
- TurnAllVisible();
- worldToEffect = LinearMatrix4D::Identity;
- gos_vertices = NULL;
- numGOSVertices = 0;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //
- MLREffect::~MLREffect()
- {
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //
- void
- MLREffect::Transform(int nrOfUsedEffects, int nrOfVertices)
- {
- Check_Object(this);
- Start_Timer(Transform_Time);
- int i, j, k;
- for(i=0,j=0;i<nrOfUsedEffects;i++,j+=nrOfVertices)
- {
- if(IsOn(i) == false)
- {
- continue;
- }
- for(k=j;k<j+nrOfVertices;k++)
- {
- (*transformedCoords)[k].Multiply(points[k], effectToClipMatrix);
- }
- }
- Stop_Timer(Transform_Time);
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //
- void
- MLREffect::TurnAllOn()
- {
- Check_Object(this);
- int i;
- for(i=0;i<maxNrOf;i++)
- {
- testList[i] |= 2;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //
- void
- MLREffect::TurnAllOff()
- {
- Check_Object(this);
- int i;
- for(i=0;i<maxNrOf;i++)
- {
- testList[i] &= ~2;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //
- void
- MLREffect::TurnAllVisible()
- {
- Check_Object(this);
- int i;
- for(i=0;i<maxNrOf;i++)
- {
- testList[i] |= 1;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //
- void
- MLREffect::TurnAllInVisible()
- {
- Check_Object(this);
- int i;
- for(i=0;i<maxNrOf;i++)
- {
- testList[i] &= ~1;
- }
- }
|