123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- #include "Welt3D.h"
- #include "Zeichnung3D.h"
- #include "MausEreignis.h"
- #include "Model3D.h"
- #include "GraphicsApi.h"
- #include "DXBuffer.h"
- using namespace Framework;
- Welt3D::Welt3D()
- : ReferenceCounter()
- {
- members = new RCArray< Model3D >();
- pointLightCount = 0;
- diffuseLightCount = 0;
- pointLights = 0;
- diffuseLights = 0;
- rend = 0;
- }
- Welt3D::~Welt3D()
- {
- members->release();
- delete[] pointLights;
- delete[] diffuseLights;
- }
- void Welt3D::lock()
- {
- cs.lock();
- }
- void Welt3D::unlock()
- {
- cs.unlock();
- }
- void Welt3D::addZeichnung( Model3D *obj )
- {
- cs.lock();
- for( auto i = members->getIterator(); i; i++ )
- {
- if( i == obj )
- throw std::exception();
- }
- members->add( obj );
- rend = 1;
- cs.unlock();
- }
- void Welt3D::removeZeichnung( Model3D *obj )
- {
- cs.lock();
- for( int i = 0; i < members->getEintragAnzahl(); i++ )
- {
- if( members->z( i ) == obj )
- {
- members->remove( i );
- break;
- }
- }
- cs.unlock();
- }
- void Welt3D::doMausEreignis( MausEreignis3D &me )
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- bool Welt3D::tick( double tickval )
- {
- cs.lock();
- for( auto m = members->getIterator(); m; m++ )
- rend |= m->tick( tickval );
- cs.unlock();
- bool tmp = rend;
- rend = 0;
- return tmp;
- }
- int Welt3D::traceRay( Vec3< float > &point, Vec3< float > &dir )
- {
- float min = INFINITY;
- int minId = -1;
- int index = 0;
- int pId = 0;
- for( auto m = members->getIterator(); m; m++, index++ )
- {
- float tmp = m->traceRay( point, dir, min, pId );
- if( min > tmp && tmp >= 0 )
- {
- min = tmp;
- minId = index;
- }
- }
- if( minId >= 0 )
- return members->z( minId )->traceRay( point, dir, pId, this );
- return 0xFF000000;
- }
- Iterator< Model3D * > Welt3D::getMembers()
- {
- return members->getIterator();
- }
- int Framework::Welt3D::getPointLightCount() const
- {
- return pointLightCount;
- }
- int Framework::Welt3D::getDiffuseLightCount() const
- {
- return diffuseLightCount;
- }
- void Framework::Welt3D::copyLight( DXBuffer *zDiffuse, DXBuffer *zPoints ) const
- {
- zDiffuse->setData( diffuseLights );
- zDiffuse->setLength( diffuseLightCount * (int)sizeof( DiffuseLight ) );
- zDiffuse->copieren();
- zPoints->setData( pointLights );
- zPoints->setLength( pointLightCount * (int)sizeof( PointLight ) );
- zPoints->copieren();
- }
|