123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- //===========================================================================//
- // Copyright (C) Microsoft Corporation. All rights reserved. //
- //===========================================================================//
- #include "MLRHeaders.hpp"
- //#############################################################################
- //######################### MLRPointCloud ###############################
- //#############################################################################
- MLRPointCloud::ClassData*
- MLRPointCloud::DefaultData = NULL;
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //
- void
- MLRPointCloud::InitializeClass()
- {
- Verify(!DefaultData);
- Verify(gos_GetCurrentHeap() == StaticHeap);
- DefaultData =
- new ClassData(
- MLRPointCloudClassID,
- "MidLevelRenderer::MLRPointCloud",
- MLREffect::DefaultData
- );
- Register_Object(DefaultData);
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //
- void
- MLRPointCloud::TerminateClass()
- {
- Unregister_Object(DefaultData);
- delete DefaultData;
- DefaultData = NULL;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //
- MLRPointCloud::MLRPointCloud(int nr, int _type) :
- MLREffect(nr, DefaultData), type(_type)
- {
- Verify(gos_GetCurrentHeap() == Heap);
- usedNrOfVertices = 0;
- Check_Pointer(this);
-
- drawMode = SortData::PointCloud;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //
- MLRPointCloud::~MLRPointCloud()
- {
- Check_Object(this);
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //
- void
- MLRPointCloud::SetData(
- const int *count,
- const Stuff::Point3D *point_data,
- const Stuff::RGBAColor *color_data
- )
- {
- Check_Pointer(this);
- usedNrOfVertices = count;
- Verify(*usedNrOfVertices <= maxNrOf);
- points = point_data;
- colors = color_data;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //
- void
- MLRPointCloud::Draw (DrawEffectInformation *dInfo, GOSVertexPool *allVerticesToDraw, MLRSorter *sorter)
- {
- Check_Object(this);
- worldToEffect.Invert(*dInfo->effectToWorld);
- Transform(*usedNrOfVertices, 1);
- #if 0
- Lighting(*shape->worldToShape, dInfo->activeLights, dInfo->nrOfActiveLights);
- #endif
- if( Clip(dInfo->clippingFlags, allVerticesToDraw) )
- {
- sorter->AddEffect(this, dInfo->state);
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //
- void
- MLRPointCloud::Transform(int, int)
- {
- Check_Object(this);
- Start_Timer(Transform_Time);
- int i;
- for(i=0;i<*usedNrOfVertices;i++)
- {
- if(IsOn(i) == false)
- {
- continue;
- }
- (*transformedCoords)[i].Multiply(points[i], effectToClipMatrix);
- }
- Stop_Timer(Transform_Time);
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //
- int
- MLRPointCloud::Clip(MLRClippingState clippingFlags, GOSVertexPool *vt)
- {
- //--------------------------------------
- // See if we don't have to draw anything
- //--------------------------------------
- //
- int i;
- numGOSVertices = 0;
- if(clippingFlags.GetClippingState() == 0 || usedNrOfVertices <= 0)
- {
- if(usedNrOfVertices <= 0)
- {
- visible = 0;
- }
- else
- {
- Check_Object(vt);
- gos_vertices = vt->GetActualVertexPool();
- for(i=0;i<*usedNrOfVertices;i++)
- {
- // if(IsOn(i) == false)
- // {
- // continue;
- // }
- GOSCopyData(
- &gos_vertices[numGOSVertices],
- transformedCoords->GetData(),
- colors,
- i
- );
- numGOSVertices++;
- }
- Check_Object(vt);
- vt->Increase(numGOSVertices);
-
- visible = numGOSVertices ? 1 : 0;
- }
- return visible;
- }
- Check_Object(vt);
- gos_vertices = vt->GetActualVertexPool();
- Stuff::Vector4D *v4d = transformedCoords->GetData();
- for(i=0;i<*usedNrOfVertices;i++,v4d++)
- {
- // if(IsOn(i) == false)
- // {
- // continue;
- // }
- // if( clippingFlags.IsFarClipped() && v4d->w < v4d->z)
- // {
- // continue;
- // }
- // if( clippingFlags.IsNearClipped() && v4d->z < 0.0f)
- // {
- // continue;
- // }
- // if( clippingFlags.IsRightClipped() && v4d->x < 0.0f)
- // {
- // continue;
- // }
- // if( clippingFlags.IsLeftClipped() && v4d->w < v4d->x)
- // {
- // continue;
- // }
- // if( clippingFlags.IsBottomClipped() && v4d->y < 0.0f)
- // {
- // continue;
- // }
- // if(clippingFlags.IsTopClipped() && v4d->w < v4d->y)
- // {
- // continue;
- // }
- GOSCopyData(
- &gos_vertices[numGOSVertices],
- transformedCoords->GetData(),
- colors,
- i
- );
- // if(
- // //clippingFlags.IsLeftClipped() &&
- // (gos_vertices[numGOSVertices].x + ((type)?type*4.f : 4.f)) > Environment.screenWidth
- // )
- // {
- // continue;
- // }
- //
- // if(
- // //clippingFlags.IsTopClipped() &&
- // (gos_vertices[numGOSVertices].y + ((type)?type*4.f : 4.f)) > Environment.screenHeight
- // )
- // {
- // continue;
- // }
- //
- numGOSVertices++;
- }
- vt->Increase(numGOSVertices);
- visible = numGOSVertices ? 1 : 0;
- if(visible)
- {
- }
- else
- {
- }
- return visible;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //
- void
- MLRPointCloud::TestInstance() const
- {
- if (usedNrOfVertices)
- {
- Verify(*usedNrOfVertices >= 0);
- Verify(*usedNrOfVertices <= maxNrOf);
- }
- }
|