Browse Source

2D Collision Detektion und Handeling hinzugefügt

kolja 6 years ago
parent
commit
094f9d608c
11 changed files with 328 additions and 39 deletions
  1. 6 2
      Array.h
  2. 1 0
      Framework Linux.vcxproj
  3. 3 0
      Framework Linux.vcxproj.filters
  4. 1 0
      Framework.vcxproj
  5. 3 0
      Framework.vcxproj.filters
  6. 81 17
      Model2D.cpp
  7. 14 8
      Model2D.h
  8. 19 0
      Rect2.h
  9. 5 0
      Vec2.h
  10. 121 3
      Welt2D.cpp
  11. 74 9
      Welt2D.h

+ 6 - 2
Array.h

@@ -33,7 +33,9 @@ namespace Framework
         {
             if( !next )
             {
-                ArrayEintrag<TYP> tmp = ArrayEintrag{ 0, 0, 0 };
+                ArrayEintrag<TYP> tmp;
+                tmp.set = 0;
+                tmp.next = 0;
                 *this = tmp;
                 return *this;
             }
@@ -45,7 +47,9 @@ namespace Framework
         {
             if( !next )
             {
-                ArrayEintrag<TYP> tmp = ArrayEintrag{ 0, 0, 0 };
+                ArrayEintrag<TYP> tmp;
+                tmp.set = 0;
+                tmp.next = 0;
                 *this = tmp;
                 return *this;
             }

+ 1 - 0
Framework Linux.vcxproj

@@ -196,6 +196,7 @@
     <ClInclude Include="Rahmen.h" />
     <ClInclude Include="Random.h" />
     <ClInclude Include="Reader.h" />
+    <ClInclude Include="Rect2.h" />
     <ClInclude Include="ReferenceCounting.h" />
     <ClInclude Include="Schrift.h" />
     <ClInclude Include="Scroll.h" />

+ 3 - 0
Framework Linux.vcxproj.filters

@@ -258,6 +258,9 @@
     <ClInclude Include="Kamera2D.h">
       <Filter>Headerdateien\Framework\Objekte2D</Filter>
     </ClInclude>
+    <ClInclude Include="Rect2.h">
+      <Filter>Headerdateien\Framework\Grafik\2D</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Prozess.cpp">

+ 1 - 0
Framework.vcxproj

@@ -238,6 +238,7 @@ copy "x64\Release\Framework.dll" "..\..\Spiele Platform\SMP\Fertig\x64\framework
     <ClInclude Include="ObjectRegister.h" />
     <ClInclude Include="Random.h" />
     <ClInclude Include="Reader.h" />
+    <ClInclude Include="Rect2.h" />
     <ClInclude Include="ReferenceCounting.h" />
     <ClInclude Include="Render3D.h" />
     <ClInclude Include="Shader.h" />

+ 3 - 0
Framework.vcxproj.filters

@@ -282,6 +282,9 @@
     <ClInclude Include="Welt2D.h">
       <Filter>Headerdateien\Framework\Grafik\2D</Filter>
     </ClInclude>
+    <ClInclude Include="Rect2.h">
+      <Filter>Headerdateien\Framework\Grafik\2D</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Maus.cpp">

+ 81 - 17
Model2D.cpp

@@ -425,14 +425,14 @@ bool Model2DData::calcHitPoint( Vertex pos, Vertex dir, const char *polygonName,
                     float f = ( point.x - pos.x ) / dir.x;
                     if( !dir.x )
                         f = ( point.y - pos.y ) / dir.y;
-                    if( !ret || ( hitpoint - pos ).getLengthSq() > ( point - pos ).getLengthSq() && f > 0 )
+                    if( ( !ret || ( hitpoint - pos ).getLengthSq() > ( point - pos ).getLengthSq() ) && f > 0 )
                     {
                         Vertex normal = b.CW90().normalize();
                         Vertex kNorm = Vertex( dir ).normalize();
-                        moveSpeed = normal * ( normal * kNorm ) * dir.getLengthSq();
+                        moveSpeed = normal * ( normal * kNorm ) * dir.getLength();
                         normal = ( point - *polygon->var.schwerpunkt ).CW90().normalize();
                         Vertex rotKraft = normal * ( normal * kNorm ) * dir.getLength();
-                        rotSpeed = ( ( rotKraft.getLength() * ( point - *polygon->var.schwerpunkt ).getLength() ) / 180.f ) * 3.14f * ( normal * kNorm );
+                        rotSpeed = ( (float)sqrt( rotKraft.getLength() * ( point - *polygon->var.schwerpunkt ).getLength() ) / 180.f ) * 3.14f * ( normal * kNorm );
                         hitpoint = point;
                     }
                     ret = 1;
@@ -632,6 +632,30 @@ bool Model2DData::split( Vertex pos, Vertex dir, char *polygonName, Polygon2D &p
     return ret;
 }
 
+float Model2DData::getMasse() const
+{
+    float m = 0;
+    for( auto p = polygons->getArray(); p.set; p++ )
+    {
+        if( p.var.transparent )
+            continue;
+        int anz = p.var.vertex->getEintragAnzahl();
+        if( anz < 3 )
+            continue;
+        Vertex p1 = p.var.vertex->get( anz - 1 );
+        Vertex p2 = p.var.vertex->get( 0 );
+        m += ( p1.y + p2.y ) * ( p1.x - p2.x );
+        for( int i = 1; i < anz; i++ )
+        {
+            p1 = p.var.vertex->get( i - 1 );
+            p2 = p.var.vertex->get( i );
+            m += 0.5f * ( p1.y + p2.y ) * ( p1.x - p2.x );
+        }
+    }
+    m *= 0.5f;
+    return m;
+}
+
 // Reference Counting
 Model2DData *Model2DData::getThis()
 {
@@ -693,14 +717,14 @@ void Model2DObject::impuls( Vertex start, Vertex speed )
     if( rData )
     {
         Vertex resSpeed;
-        float resRotSpeed;
+        float resRotSpeed = 0;
         Vertex hp;
         Vertex mSpeed;
         float rSpeed;
         float dist = INFINITY;
         for( auto p = rData->polygons->getArray(); p.set; p++ )
         {
-            if( rData->calcHitPoint( start, speed, p.var.name->getText(), hp, mSpeed, rSpeed ) )
+            if( !p.var.transparent && rData->calcHitPoint( start, speed, p.var.name->getText(), hp, mSpeed, rSpeed ) )
             {
                 float f = ( hp.x - start.x ) / speed.x;
                 if( !speed.x )
@@ -837,15 +861,11 @@ bool Model2DObject::istLinieInnen( Vertex a, Vertex b ) const
     return 0;
 }
 
-bool Model2DObject::istModelInnen( const Model2DObject *zMdl, bool end ) const
+bool Model2DObject::istModelInnen( const Object2D *zObj, Vertex *sp, bool end ) const
 {
     if( !end )
     {
-        Vertex min = (Vertex)rData->minP * size + position;
-        Vertex max = (Vertex)rData->maxP * size + position;
-        Vertex min2 = (Vertex)zMdl->zModel()->minP * zMdl->getSize() + zMdl->getPosition();
-        Vertex max2 = (Vertex)zMdl->zModel()->maxP * zMdl->getSize() + zMdl->getPosition();
-        if( max.x < min2.x || min.x > max2.x || max.y < min2.y || min.y > max2.y )
+        if( !getBoundingBox().collidesWith( zObj->getBoundingBox() ) )
             return 0;
     }
     Mat3< float > mat = getObjectMatrix();
@@ -856,20 +876,24 @@ bool Model2DObject::istModelInnen( const Model2DObject *zMdl, bool end ) const
         int anz = polygon->var.vertex->getEintragAnzahl();
         for( int i = 0; i < anz; i++ )
         {
-            if( zMdl->istPunktInnen( mat * polygon->var.vertex->get( i ) ) )
+            if( zObj->istPunktInnen( mat * polygon->var.vertex->get( i ) ) )
+            {
+                if( sp )
+                    *sp = mat * polygon->var.vertex->get( i );
                 return 1;
+            }
         }
     }
     if( end )
         return 0;
-    return zMdl->istModelInnen( this, 1 );
+    return zObj->istModelInnen( this, sp, 1 );
 }
 
-Rect< float > Model2DObject::getBoundingBox() const
+Rect2< float > Model2DObject::getBoundingBox() const
 {
     if( rData )
-        return Rect< float >{ (Vertex)rData->minP * size + position, (Vertex)rData->maxP * size + position };
-    return Rect< float >();
+        return Rect2< float >{ (Vertex)rData->minP * size + position, (Vertex)rData->maxP * size + position };
+    return Rect2< float >();
 }
 
 bool Model2DObject::calcHitPoint( Vertex pos, Vertex dir, Vertex &hitpoint ) const
@@ -884,7 +908,7 @@ bool Model2DObject::calcHitPoint( Vertex pos, Vertex dir, Vertex &hitpoint ) con
     {
         for( auto p = rData->polygons->getArray(); p.set; p++ )
         {
-            if( rData->calcHitPoint( pos, dir, p.var.name->getText(), hp, ms, rs ) )
+            if( !p.var.transparent && rData->calcHitPoint( pos, dir, p.var.name->getText(), hp, ms, rs ) )
             {
                 float f = ( hp.x - pos.x ) / dir.x;
                 if( !speed.x )
@@ -902,6 +926,46 @@ bool Model2DObject::calcHitPoint( Vertex pos, Vertex dir, Vertex &hitpoint ) con
     return 0;
 }
 
+float Model2DObject::getLuftWiederstand() const
+{
+    if( !rData )
+        return 0;
+    float angle = speed.angle( Vertex( 1, 0 ) );
+    float faktor = -1;
+    if( getDrehung() > PI )
+        faktor = -faktor;
+    if( getDrehung() < -PI )
+        faktor = -faktor;
+    Mat3< float > m = Mat3< float >::rotation( rotation + faktor * angle ) * Mat3< float >::scaling( size );
+    float yMin = INFINITY;
+    float yMax = -INFINITY;
+    for( auto p = rData->polygons->getArray(); p.set; p++ )
+    {
+        if( p.var.transparent )
+            continue;
+        for( auto point = p.var.vertex->getArray(); point.set; point++ )
+        {
+            Vertex v = m * point.var;
+            if( v.y > yMax )
+                yMax = v.y;
+            if( v.y < yMin )
+                yMin = v.y;
+        }
+    }
+    if( yMin != INFINITY )
+    {
+        return yMax - yMin;
+    }
+    return 0;
+}
+
+float Model2DObject::getMasse() const
+{
+    if( !rData )
+        return 0;
+    return rData->getMasse() * size * size;
+}
+
 Model2DData *Model2DObject::getModel() const
 {
     return rData ? rData->getThis() : 0;

+ 14 - 8
Model2D.h

@@ -74,6 +74,8 @@ namespace Framework
         //  posB: die Position des anderen neuen Polygons (ausgabe)
         //  random: eine funktion die zufällige werte zurückgibt
         __declspec( dllexport ) bool split( Vertex pos, Vertex dir, char *polygonName, Polygon2D &partA, Polygon2D &partB, Punkt &posA, Punkt &posB, std::function< double() > random ) const;
+        // Gibt die Masse des 2D Modells zurück (summe der Flächen der nicht transparenten Polygone)
+        __declspec( dllexport ) float getMasse() const;
         // Erhöht den Reference Counting Zähler.
         //  return: this.
         __declspec( dllexport ) Model2DData *getThis();
@@ -109,22 +111,26 @@ namespace Framework
         __declspec( dllexport ) void render( Mat3< float > &kamMat, Bild &zRObj ) override;
         // Gibt zurück, ob ein Punkt in dem Model enthalten ist
         //  p: Der Punkt
-        __declspec( dllexport ) bool istPunktInnen( Vertex p ) const;
+        __declspec( dllexport ) bool istPunktInnen( Vertex p ) const override;
         // Überprüft, ob eine Linie im Model enthalten ist
         //  a: Der startpunkt der Linie
         //  b: Der endpunkt der Linie
-        __declspec( dllexport ) bool istLinieInnen( Vertex a, Vertex b ) const;
-        // Überprüft, ob sich das Model mit einem anderen Überschneidet
-        //  zMdl: Ein Zeiger auf das andere Model ohne erhöhten Reference Counter
-        //  end: 0, falls alle Ecken beider Modele überprüft werdden sollen. 1, falls nur die Punkte dieses Models im anderen gesucht werden sollen
-        __declspec( dllexport ) bool istModelInnen( const Model2DObject *zMdl, bool end = 0 ) const;
-        __declspec( dllexport ) Rect< float > getBoundingBox() const override;
+        __declspec( dllexport ) bool istLinieInnen( Vertex a, Vertex b ) const override;
+        // Überprüft, ob sich das Objekt mit einem anderen Überschneidet
+        //  zObj: Ein Zeiger auf das andere Objekt ohne erhöhten Reference Counter
+        //  sp: Ein Zeiger auf einen Punkt, in dem der Schnittpunkt gespeichert wird
+        //  end: 0, falls alle Ecken beider Objekte überprüft werdden sollen. 1, falls nur die Punkte dieses Models im anderen gesucht werden sollen
+        __declspec( dllexport ) virtual bool istModelInnen( const Object2D *zObj, Vertex *sp = 0, bool end = 0 ) const;
+        __declspec( dllexport ) Rect2< float > getBoundingBox() const override;
         // Bestimmt den Aufschlagspunkt eines Strahls, der von pos ausgehend in Richtung dir abgegeben wird.
         //  pos: Der Stützvektor der Linie
         //  dir: Der richtungsvektor der Linie
         //  hitPoint: eine referenz auf die variable in dem der schnittpunkt gespeichert werden soll
         //  return: 1, fals ein Schnittpunkt existiert
-        __declspec( dllexport ) virtual bool calcHitPoint( Vertex pos, Vertex dir, Vertex &hitpoint ) const override;
+        __declspec( dllexport ) bool calcHitPoint( Vertex pos, Vertex dir, Vertex &hitpoint ) const override;
+        __declspec( dllexport ) float getLuftWiederstand() const override;
+        // Gibt die Masse des 2D Modells zurück (summe der Flächen der nicht transparenten Polygone)
+        __declspec( dllexport ) float getMasse() const override;
         // Gibt die Model Daten zurück
         __declspec( dllexport ) Model2DData *getModel() const;
         // Gibt die Model Daten ohne erhöhten Reference Counter zurück

+ 19 - 0
Rect2.h

@@ -0,0 +1,19 @@
+#pragma once
+
+#include "Vec2.h"
+
+namespace Framework
+{
+    template<typename T>
+    struct Rect2
+    {
+        Vec2< T > topLeft;
+        Vec2< T > bottomRight;
+
+        // Prüft, ob sich das Rechteck mit einem anderen Überschneidet
+        inline bool collidesWith( const Rect2 &r )
+        {
+            return r.topLeft.x < bottomRight.x && r.bottomRight.x > topLeft.x && r.topLeft.y < bottomRight.y && r.bottomRight.y > r.topLeft.y;
+        }
+    };
+}

+ 5 - 0
Vec2.h

@@ -193,6 +193,11 @@ namespace Framework
             result.y = (T)( x * sine + y * cosine );
             return result;
         }
+        // Ermittelt den Winkel zwischen zwei Vektoren
+        inline T angle( const Vec2 &v2 ) const
+        {
+            return (T)acos( ( *this * v2 ) / sqrt(  getLengthSq() * v2.getLengthSq() ) );
+        }
     };
 }
 

+ 121 - 3
Welt2D.cpp

@@ -23,6 +23,16 @@ void Object2D::explosion( Vertex worldPos, float intensity )
 void Object2D::impuls( Vertex start, Vertex speed )
 {}
 
+void Object2D::setSpeed( Vertex speed )
+{
+    this->speed = speed;
+}
+
+void Object2D::setSpeed( float x, float y )
+{
+    speed.x = x, speed.y = y;
+}
+
 void Object2D::setPosition( Vertex pos )
 {
     position = pos;
@@ -33,6 +43,11 @@ void Object2D::setPosition( float x, float y )
     position = Vertex( x, y );
 }
 
+void Object2D::setDrehungSpeed( float ds )
+{
+    rSpeed = ds;
+}
+
 void Object2D::setDrehung( float drehung )
 {
     rotation = drehung;
@@ -61,13 +76,64 @@ void Object2D::addSize( float size )
     this->size += size;
 }
 
-bool Object2D::tick( double zeit )
+bool Object2D::handleCollision( Object2D *obj )
+{
+    Vertex hp;
+    if( istModelInnen( obj, &hp ) )
+    {
+        Vertex v1 = getSpeed() + getWorldDir( getObjectPos( hp ).rotation( rSpeed ) - getObjectPos( hp ) );
+        Vertex v2 = obj->getSpeed() + getWorldDir( obj->getObjectPos( hp ).rotation( obj->getDrehungSpeed() ) - obj->getObjectPos( hp ) );
+        float m1 = getMasse();
+        float m2 = obj->getMasse();
+        if( m1 == 0 || m2 == 0 )
+            return 0;
+        rSpeed = 0;
+        speed = Vertex( 0, 0 );
+        obj->setDrehungSpeed( 0 );
+        obj->setSpeed( 0, 0 );
+        if( v2.x || v2.y )
+            impuls( hp - v2, v2 * ( m2 / ( m1 + m2 ) ) );
+        if( v1.x || v1.y )
+            obj->impuls( hp - v1, v1 * ( m1 / ( m1 + m2 ) ) );
+        return 1;
+    }
+    return 0;
+}
+
+bool Object2D::tick( const WeltInfo &info, double zeit )
 {
     rotation += rSpeed * (float)zeit;
+    while( rotation > PI * 2 )
+        rotation -= (float)PI * 2;
+    while( rotation < 0 )
+        rotation += (float)PI * 2;
     position += speed * (float)zeit;
+    while( zeit > 1 )
+    {
+        rSpeed -= rSpeed - ( rSpeed / ( 1 + info.airResistance * getLuftWiederstand() ) );
+        speed -= speed - ( speed / ( 1 + info.airResistance * getLuftWiederstand() ) );
+        zeit -= 1;
+    }
+    rSpeed -= ( rSpeed - ( rSpeed / ( 1 + info.airResistance * getLuftWiederstand() ) ) ) * (float)zeit;
+    speed -= ( speed - ( speed / ( 1 + info.airResistance * getLuftWiederstand() ) ) ) * (float)zeit;
     return rSpeed != 0 || speed != Vertex( 0, 0 );
 }
 
+bool Object2D::istPunktInnen( Vertex p ) const
+{
+    return 0;
+}
+
+bool Object2D::istLinieInnen( Vertex a, Vertex b ) const
+{
+    return 0;
+}
+
+bool Object2D::istModelInnen( const Object2D *zObj, Vertex *sp, bool end ) const
+{
+    return 0;
+}
+
 Mat3< float > Object2D::getObjectMatrix() const
 {
     return Mat3<float>::translation( position ) * Mat3<float>::rotation( rotation ) * Mat3<float>::scaling( size );
@@ -88,11 +154,31 @@ Vertex Object2D::getObjectDir( Vertex worldDir ) const
     return Vertex( worldDir.x, worldDir.y ).rotation( -rotation ) * ( 1 / size );
 }
 
+Vertex Object2D::getWorldPos( Vertex objectPos ) const
+{
+    return ( Vertex( objectPos ) * size ).rotation( rotation ) + position;
+}
+
+Vertex Object2D::getWorldDir( Vertex objectDir ) const
+{
+    return ( Vertex( objectDir ) * size ).rotation( rotation );
+}
+
+Vertex Object2D::getSpeed() const
+{
+    return speed;
+}
+
 Vertex Object2D::getPosition() const
 {
     return position;
 }
 
+float Object2D::getDrehungSpeed() const
+{
+    return rSpeed;
+}
+
 float Object2D::getDrehung() const
 {
     return rotation;
@@ -108,6 +194,16 @@ bool Object2D::calcHitPoint( Vertex pos, Vertex dir, Vertex &hitpoint ) const
     return 0;
 }
 
+float Object2D::getLuftWiederstand() const
+{
+    return 0;
+}
+
+float Object2D::getMasse() const
+{
+    return 0;
+}
+
 Object2D *Object2D::getThis()
 {
     ref++;
@@ -125,6 +221,7 @@ Object2D *Object2D::release()
 Welt2D::Welt2D()
 {
     objects = new RCArray< Object2D >();
+    memset( &info, 0, sizeof( WeltInfo ) );
     ref = 1;
 }
 
@@ -133,6 +230,11 @@ Welt2D::~Welt2D()
     objects->release();
 }
 
+void Welt2D::setAirResistance( float resistance )
+{
+    info.airResistance = resistance;
+}
+
 void Welt2D::addObject( Object2D *obj )
 {
     objects->add( obj );
@@ -172,7 +274,23 @@ bool Welt2D::tick( double zeit )
 {
     bool ret = 0;
     for( auto obj = objects->getArray(); obj.set; obj++ )
-        ret |= obj.var->tick( zeit );
+    {
+        if( obj.next )
+        {
+            for( auto obj2 = *obj.next; obj2.set; obj2++ )
+            {
+                if( obj.var->handleCollision( obj2 ) )
+                {
+                    while( obj.var->istModelInnen( obj2 ) )
+                    {
+                        ret |= obj.var->tick( info, 0.03 );
+                        ret |= obj2.var->tick( info, 0.03 );
+                    }
+                }
+            }
+        }
+        ret |= obj.var->tick( info, zeit );
+    }
     return ret;
 }
 
@@ -180,7 +298,7 @@ void Welt2D::render( Mat3< float > &kamMat, Punkt size, Bild &zRObj )
 {
     for( auto obj = objects->getArray(); obj.set; obj++ )
     {
-        Rect< float > bnd = obj.var->getBoundingBox();
+        Rect2< float > bnd = obj.var->getBoundingBox();
         Vertex topRight = Vertex( bnd.topLeft.y, bnd.bottomRight.x );
         Vertex bottomLeft = Vertex( bnd.topLeft.x, bnd.bottomRight.y );
         bnd.bottomRight = kamMat * bnd.bottomRight;

+ 74 - 9
Welt2D.h

@@ -3,17 +3,16 @@
 #include "Array.h"
 #include "Mat3.h"
 #include "Punkt.h"
+#include "Rect2.h"
 
 namespace Framework
 {
     typedef Vec2< float > Vertex;
     class Bild;
 
-    template<typename T>
-    struct Rect
+    struct WeltInfo
     {
-        Vec2< T > topLeft;
-        Vec2< T > bottomRight;
+        float airResistance;
     };
 
     class Object2D
@@ -29,10 +28,31 @@ namespace Framework
     public:
         __declspec( dllexport ) Object2D();
         virtual __declspec( dllexport ) ~Object2D();
+        // Fügt einen Schub in die ausbreitungsrichtung der Explusion zur Bewegung des Objektes hinzu
+        //  worldPos: Die Position des Explusionsuhrsprungs
+        //  intensity: Die Intensität der Explusion
         __declspec( dllexport ) void explosion( Vertex worldPos, float intensity );
+        // Übt auf das Objekt einen Impuls aus, der sowohl die geschwindigkeit, als auch die Drehungsgeschwindigkeit des Objektes beeinflusst
+        //  start: Die Startposition des Impulses in der Welt
+        //  speed: Die Geschwindigkeit des Impulses in der Welt
         __declspec( dllexport ) virtual void impuls( Vertex start, Vertex speed );
+        // Setzt die Geschwindigkeit des Objektes in der Welt
+        //  speed: Anzahl der zurückgelegten Koordinaten pro Sekunde
+        __declspec( dllexport ) void setSpeed( Vertex speed );
+        // Setzt die Geschwindigkeit des Objektes in der Welt
+        //  x: Anzahl der zurückgelegten x Koordinaten pro Sekunde
+        //  y: Anzahl der zurückgelegten y Koordinaten pro Sekunde
+        __declspec( dllexport ) void setSpeed( float x, float y );
+        // Setzt die Position des Objektes in der Welt
+        //  pos: Die Position in Weltkoordinaten
         __declspec( dllexport ) void setPosition( Vertex pos );
+        // Setzt die Position des Objektes in der Welt
+        //  x: Die X Position in Weltkoordinaten
+        //  y: Die Y Position in Weltkoordinaten
         __declspec( dllexport ) void setPosition( float x, float y );
+        // Setzt die Rotationsgeschwindigkeit in Radiant pro Sekunde
+        //  ds: Die neue Rptationsgeschwindigkeit
+        __declspec( dllexport ) void setDrehungSpeed( float ds );
         // Setzt die Drehung des Models gegen den Uhrzeigersinn
         //  drehung: Der winkel in Bogenmas
         __declspec( dllexport ) void setDrehung( float drehung );
@@ -45,26 +65,69 @@ namespace Framework
         // Addiert zur Skallierung einen bestimmten Wert hinzu
         //  size: Der Wert, der zur skallierung hinzugefügt werden soll
         __declspec( dllexport ) void addSize( float size );
-        __declspec( dllexport ) virtual bool tick( double zeit );
+        // Prüft ob eine Collision mit einem anderen Objekt vorliegt und passt die Geschwindigkeiten beider Objekte entsprechend an
+        __declspec( dllexport ) virtual bool handleCollision( Object2D *obj );
+        // Verarbeitet vargangene Zeit und aktualisiert die Position und die Drehung des Objektes in der Welt
+        //  zeit: Die vergangene Zeit in Sekunden
+        __declspec( dllexport ) virtual bool tick( const WeltInfo &info, double zeit );
+        // Zeichnet das Objekt in ein Bild
+        //  kamMat: Due Kamera Matrix, welche einen Punkt aus Weltkoordinaten in Bildschirmkoordinaten umwandelt
+        //  zRObj: Das Bild, in welches gezeichnet werden soll
         virtual void render( Mat3< float > &kamMat, Bild &zRObj ) = 0;
+        // Gibt zurück, ob ein Punkt in dem Objekt enthalten ist
+        //  p: Der Punkt
+        __declspec( dllexport ) virtual bool istPunktInnen( Vertex p ) const;
+        // Überprüft, ob eine Linie im Objekt enthalten ist
+        //  a: Der startpunkt der Linie
+        //  b: Der endpunkt der Linie
+        __declspec( dllexport ) virtual bool istLinieInnen( Vertex a, Vertex b ) const;
+        // Überprüft, ob sich das Objekt mit einem anderen Überschneidet
+        //  zObj: Ein Zeiger auf das andere Objekt ohne erhöhten Reference Counter
+        //  sp: Ein Zeiger auf einen Punkt, in dem der Schnittpunkt gespeichert wird
+        //  end: 0, falls alle Ecken beider Objekte überprüft werdden sollen. 1, falls nur die Punkte dieses Models im anderen gesucht werden sollen
+        __declspec( dllexport ) virtual bool istModelInnen( const Object2D *zObj, Vertex *sp = 0, bool end = 0 ) const;
+        // Gibt eine Matrix zurück, welche einen Punkt aus Objektkoordinaten in Bildschirmkoordinaten umrechnet
         __declspec( dllexport ) Mat3< float > getObjectMatrix() const;
+        // Gibt eine Matrix zurück, welche einen Punkt aus Bildschirmkoordinaten in Objektkoordinaten umrechnet
         __declspec( dllexport ) Mat3< float > getInverseObjectMatrix() const;
+        // Rechnet einen Punkt aus Welt Koordinaten in Objektkoordinaten um
+        //  worldPos: Die Position des Punktes in der Welt
         __declspec( dllexport ) Vertex getObjectPos( Vertex worldPos ) const;
+        // Rechnet eine Richtung aus Weltkoordinaten in Objektkoordinaten um
+        //  worldDir: Die Richtung in Weltkoordinaten
         __declspec( dllexport ) Vertex getObjectDir( Vertex worldDir ) const;
-        // gibt die Position des Models zurück
+        // Rechnet einen Punkt aus Objektkoordinaten in Weltkoordinaten um
+        //  worldPos: Die Position des Punktes in Objektkoordinaten
+        __declspec( dllexport ) Vertex getWorldPos( Vertex objectPos ) const;
+        // Rechnet eine Richtung aus Objektkoordinaten in Weltkoordinaten um
+        //  worldDir: Die Richtung in Objektkoordinaten
+        __declspec( dllexport ) Vertex getWorldDir( Vertex objectDir ) const;
+        // Gibt die Geschwindigkeit des Objektes zurück
+        __declspec( dllexport ) Vertex getSpeed() const;
+        // gibt die Position des Objektes zurück
         __declspec( dllexport ) Vertex getPosition() const;
-        // gibt die Drehung des Models zurück
+        // gibt die Drehgeschwindigkeit des Objektes zurück
+        __declspec( dllexport ) float getDrehungSpeed() const;
+        // gibt die Drehung des Objektes zurück
         __declspec( dllexport ) float getDrehung() const;
-        // gibt den Skallierungs Faktor zurück
+        // gibt den Skallierungs Objektes zurück
         __declspec( dllexport ) float getSize() const;
-        __declspec( dllexport ) virtual Rect< float > getBoundingBox() const = 0;
+        // Gibt eine Boundingbox zurück, in der sich alle Punkte des Objektes befinden ( in Weltkoordinaten)
+        __declspec( dllexport ) virtual Rect2< float > getBoundingBox() const = 0;
         // Bestimmt den Aufschlagspunkt eines Strahls, der von pos ausgehend in Richtung dir abgegeben wird.
         //  pos: Der Stützvektor der Linie
         //  dir: Der richtungsvektor der Linie
         //  hitPoint: eine referenz auf die variable in dem der schnittpunkt gespeichert werden soll
         //  return: 1, fals ein Schnittpunkt existiert
         __declspec( dllexport ) virtual bool calcHitPoint( Vertex pos, Vertex dir, Vertex &hitpoint ) const;
+        // Ermittelt die Fläche des Objektes, welche rechtwinklich zum Bewegungsvektor steht
+        __declspec( dllexport ) virtual float getLuftWiederstand() const;
+        // Gibt die Masse des Objektes zurück
+        __declspec( dllexport ) virtual float getMasse() const;
+        // Erhöht den Reference Counter um 1 und gibt this zurück
         __declspec( dllexport ) Object2D *getThis();
+        // Verringert den Reference Counter um 1 (bei 0 löscht sich das Objekt selbst)
+        //  Gibt 0 zurück
         __declspec( dllexport ) Object2D *release();
     };
 
@@ -74,11 +137,13 @@ namespace Framework
         RCArray< Object2D > *objects;
         Punkt topLeft;
         Punkt rightBottom;
+        WeltInfo info;
         int ref;
 
     public:
         __declspec( dllexport ) Welt2D();
         __declspec( dllexport ) ~Welt2D();
+        __declspec( dllexport ) void setAirResistance( float resistance );
         __declspec( dllexport ) void addObject( Object2D *obj );
         __declspec( dllexport ) void explosion( Vertex worldPos, float intensity, float maxRad );
         __declspec( dllexport ) void impuls( Vertex worldPos, Vertex worldDir );