Browse Source

3D Kamerafunktionen erweitert

Kolja Strohm 5 years ago
parent
commit
a010c52d7a
6 changed files with 184 additions and 51 deletions
  1. 1 1
      Bildschirm.cpp
  2. 102 32
      Kam3D.cpp
  3. 33 0
      Kam3D.h
  4. 36 16
      Mat4.h
  5. 6 2
      Render3D.cpp
  6. 6 0
      Vec3.h

+ 1 - 1
Bildschirm.cpp

@@ -684,7 +684,7 @@ void Bildschirm3D::update() // aktualisiert directX
     // create a device, device context and swap chain using the information in the scd struct
     UINT flag = 0;
 #ifdef _DEBUG
-    //flag |= D3D11_CREATE_DEVICE_DEBUG;
+    flag |= D3D11_CREATE_DEVICE_DEBUG;
 #endif
     result = D3D11CreateDeviceAndSwapChain( NULL,
                                             D3D_DRIVER_TYPE_HARDWARE,

+ 102 - 32
Kam3D.cpp

@@ -31,6 +31,7 @@ Kam3D::Kam3D()
     viewport->Height = 200;
 
     welt = 0;
+    style = 0;
 
     ref = 1;
 
@@ -85,7 +86,22 @@ void Kam3D::scrollOut( float val )
 //  ziel: Der Punkt, auf den die Kamera zeigen soll
 void Kam3D::setAusrichtung( Vec3< float > ziel )
 {
-
+    rotX = 0;
+    rotY = 0;
+    rotZ = 0;
+    // TODO calculate this
+    Vec3< float > target = ( ziel - pos ).normalize();
+    if( target == Vec3<float>( 0, 0, -1 ) )
+        rotY = (float)PI;
+    if( target == Vec3<float>( 0, 1, 0 ) )
+        rotX = -(float)PI / 2.f;
+    if( target == Vec3<float>( 0, -1, 0 ) )
+        rotX = (float)PI / 2.f;
+    if( target == Vec3<float>( 1, 0, 0 ) )
+        rotY = (float)PI / 2.f;
+    if( target == Vec3<float>( -1, 0, 0 ) )
+        rotY = -(float)PI / 2.f;
+    updateMatrix();
 }
 
 // Setzt die Position des Bildes auf dem Bildschirm
@@ -133,43 +149,81 @@ void Kam3D::setWelt( Welt3D *w )
     welt = w;
 }
 
+// Setzt den Style der Kamera
+//  style: Der neue Style bestehend aus den Flags aus der zugehörigen Style Klasse
+void Kam3D::setStyle( __int64 style )
+{
+    this->style = style;
+}
+
+// Setzt den Style der Kamera
+//  style: Alle Style Flags, die verändert werden sollen
+//  add_remove: 1, falls der Style hinzugefügt werden soll. 0, falls der Style entfernt weden soll
+void Kam3D::setStyle( __int64 style, bool add_remove )
+{
+    if( add_remove )
+        this->style |= style;
+    else if( !add_remove )
+        this->style &= ~style;
+}
+
+// Fügt Style Flags hinzu
+//  style: Der Style, der hinzugefügt werden soll
+void Kam3D::addStyle( __int64 style )
+{
+    this->style |= style;
+}
+
+// Entfernt Style Flags
+//  style: Der Style, der entfernt werden soll
+void Kam3D::removeStyle( __int64 style )
+{
+    this->style &= ~style;
+}
+
 // Verarbeitet die vergangene Zeit
 //  tickval: Die zeit in sekunden, die seit dem letzten Aufruf der Funktion vergangen ist
 //  return: true, wenn sich das Bild neu gezeichnet werden muss, false sonnst.
 bool Kam3D::tick( double tv )
 {
-    if( getTastenStand( T_Oben ) )
-        rotX -= (float)tv;
-    if( getTastenStand( T_Unten ) )
-        rotX += (float)tv;
-    if( getTastenStand( T_Links ) )
-        rotY -= (float)tv;
-    if( getTastenStand( T_Rechts ) )
-        rotY += (float)tv;
-    Vec3< float > n( 0, 0, 1 );
-    Vec3< float > n2( 1, 0, 0 );
-    Vec3< float > n3( 0, 1, 0 );
-    Mat4< float > tmp = tmp.rotationY( rotY ) * tmp.rotationX( rotX );
-    n = tmp * n;
-    n = n * (float)tv * 60;
-    n2 = tmp * n2;
-    n2 = n2 * (float)tv * 60;
-    n3 = tmp * n3;
-    n3 = n3 * (float)tv * 60;
-    if( getTastenStand( 'w' ) )
-        pos += n;
-    if( getTastenStand( 's' ) )
-        pos -= n;
-    if( getTastenStand( 'd' ) )
-        pos += n2;
-    if( getTastenStand( 'a' ) )
-        pos -= n2;
-    if( getTastenStand( ' ' ) )
-        pos += n3;
-    if( getTastenStand( T_Shift ) )
-        pos -= n3;
+    if( hatStyle( Style::Rotatable ) )
+    {
+        if( getTastenStand( T_Oben ) )
+            rotX -= (float)tv;
+        if( getTastenStand( T_Unten ) )
+            rotX += (float)tv;
+        if( getTastenStand( T_Links ) )
+            rotY -= (float)tv;
+        if( getTastenStand( T_Rechts ) )
+            rotY += (float)tv;
+    }
+    if( hatStyle( Style::Movable ) )
+    {
+        Vec3< float > n( 0, 0, 1 );
+        Vec3< float > n2( 1, 0, 0 );
+        Vec3< float > n3( 0, 1, 0 );
+        Mat4< float > tmp = tmp.rotationY( rotY ) * tmp.rotationX( rotX );
+        n = tmp * n;
+        n = n * (float)tv * 60;
+        n2 = tmp * n2;
+        n2 = n2 * (float)tv * 60;
+        n3 = tmp * n3;
+        n3 = n3 * (float)tv * 60;
+        if( getTastenStand( 'w' ) )
+            pos += n;
+        if( getTastenStand( 's' ) )
+            pos -= n;
+        if( getTastenStand( 'd' ) )
+            pos += n2;
+        if( getTastenStand( 'a' ) )
+            pos -= n2;
+        if( getTastenStand( ' ' ) )
+            pos += n3;
+        if( getTastenStand( T_Shift ) )
+            pos -= n3;
+    }
     updateMatrix();
-    if( welt )
+    if( welt && hatStyle( Style::Tick ) )
         return welt->tick( tv );
     return 0;
 }
@@ -214,6 +268,22 @@ void Kam3D::render( Render3D *zRObj )
         welt->render( zRObj );
 }
 
+// Gibt zurück, ob bestimmte Styles gesetzt wurden
+//  style: Die Styles, die überprüft werden sollen
+//  return: 1, falls alle Styles in style gesetzt wurden
+bool Kam3D::hatStyle( __int64 style ) const
+{
+    return ( this->style | style ) == this->style;
+}
+
+// Gibt zurück, ob bestimmte Styles nicht gesetzt wurden
+//  style: Die Styles, die geprüft werden sollen
+//  return: 1, falls alle Styles in style nicht gesetzt wurden
+bool Kam3D::hatStyleNicht( __int64 style ) const
+{
+    return ( this->style | style ) != this->style;
+}
+
 // Erhöht den Reference Counter um 1
 //  Return: Ein zeiger auf diesen Shader
 Kam3D *Kam3D::getThis()

+ 33 - 0
Kam3D.h

@@ -17,6 +17,16 @@ namespace Framework
     // Eine 3d Kamera, die einen Ausschnitt einer 3D Welt in einen bestimmten Teil des Bildschirms zeichnet
     class Kam3D
     {
+    public:
+        class Style
+        {
+        public:
+            const static __int64 Movable = 0x1;
+            const static __int64 Rotatable = 0x2;
+            const static __int64 Zoomable = 0x4;
+            const static __int64 Tick = 0x8;
+        };
+
     private:
         Mat4< float > view;
         Mat4< float > proj;
@@ -31,6 +41,7 @@ namespace Framework
 
         D3D11_VIEWPORT *viewport;
         Welt3D *welt;
+        int style;
         int ref;
 
         // Aktualisiert die view und projektion matrizen
@@ -69,6 +80,19 @@ namespace Framework
         // Setzt die Welt, die gezeichnet werden soll
         //  w: Die Welt
         __declspec( dllexport ) void setWelt( Welt3D *w );
+        // Setzt den Style der Kamera
+        //  style: Der neue Style bestehend aus den Flags aus der zugehörigen Style Klasse
+        __declspec( dllexport ) void setStyle( __int64 style );
+        // Setzt den Style der Kamera
+        //  style: Alle Style Flags, die verändert werden sollen
+        //  add_remove: 1, falls der Style hinzugefügt werden soll. 0, falls der Style entfernt weden soll
+        __declspec( dllexport ) void setStyle( __int64 style, bool add_remove );
+        // Fügt Style Flags hinzu
+        //  style: Der Style, der hinzugefügt werden soll
+        __declspec( dllexport ) void addStyle( __int64 style );
+        // Entfernt Style Flags
+        //  style: Der Style, der entfernt werden soll
+        __declspec( dllexport ) void removeStyle( __int64 style );
         // Verarbeitet die vergangene Zeit
         //  tickval: Die zeit in sekunden, die seit dem letzten Aufruf der Funktion vergangen ist
         //  return: true, wenn sich das Bild neu gezeichnet werden muss, false sonnst.
@@ -82,6 +106,15 @@ namespace Framework
         // Zeichnet den Auschnitt der Welt, den die Kamera filmt
         //  zRObj: Das Render Objekt, mit dem gezeichnet werden soll
         __declspec( dllexport ) void render( Render3D *zRObj );
+        // Gibt zurück, ob bestimmte Styles gesetzt wurden
+        //  style: Die Styles, die überprüft werden sollen
+        //  return: 1, falls alle Styles in style gesetzt wurden
+        __declspec( dllexport ) bool hatStyle( __int64 style ) const;
+        // Gibt zurück, ob bestimmte Styles nicht gesetzt wurden
+        //  style: Die Styles, die geprüft werden sollen
+        //  return: 1, falls alle Styles in style nicht gesetzt wurden
+        __declspec( dllexport ) bool hatStyleNicht( __int64 style ) const;
+        // Kopiert die Komplette Zeichnung, so dass sie ohne Effekt auf das Original verändert werden kann
         // Erhöht den Reference Counter um 1
         //  Return: Ein zeiger auf diesen Shader
         __declspec( dllexport ) Kam3D *getThis();

+ 36 - 16
Mat4.h

@@ -70,7 +70,7 @@ namespace Framework
         Mat4 getInverse()
         {
             Mat4 ret;
-            ret.elements[ 0 ][ 0 ] = 
+            ret.elements[ 0 ][ 0 ] =
                 elements[ 1 ][ 1 ] * elements[ 2 ][ 2 ] * elements[ 3 ][ 3 ] -
                 elements[ 1 ][ 1 ] * elements[ 2 ][ 3 ] * elements[ 3 ][ 2 ] -
                 elements[ 2 ][ 1 ] * elements[ 1 ][ 2 ] * elements[ 3 ][ 3 ] +
@@ -78,7 +78,7 @@ namespace Framework
                 elements[ 3 ][ 1 ] * elements[ 1 ][ 2 ] * elements[ 2 ][ 3 ] -
                 elements[ 3 ][ 1 ] * elements[ 1 ][ 3 ] * elements[ 2 ][ 2 ];
 
-            ret.elements[ 1 ][ 0 ] = 
+            ret.elements[ 1 ][ 0 ] =
                 -elements[ 1 ][ 0 ] * elements[ 2 ][ 2 ] * elements[ 3 ][ 3 ] +
                 elements[ 1 ][ 0 ] * elements[ 2 ][ 3 ] * elements[ 3 ][ 2 ] +
                 elements[ 2 ][ 0 ] * elements[ 1 ][ 2 ] * elements[ 3 ][ 3 ] -
@@ -86,7 +86,7 @@ namespace Framework
                 elements[ 3 ][ 0 ] * elements[ 1 ][ 2 ] * elements[ 2 ][ 3 ] +
                 elements[ 3 ][ 0 ] * elements[ 1 ][ 3 ] * elements[ 2 ][ 2 ];
 
-            ret.elements[ 2 ][ 0 ] = 
+            ret.elements[ 2 ][ 0 ] =
                 elements[ 1 ][ 0 ] * elements[ 2 ][ 1 ] * elements[ 3 ][ 3 ] -
                 elements[ 1 ][ 0 ] * elements[ 2 ][ 3 ] * elements[ 3 ][ 1 ] -
                 elements[ 2 ][ 0 ] * elements[ 1 ][ 1 ] * elements[ 3 ][ 3 ] +
@@ -94,7 +94,7 @@ namespace Framework
                 elements[ 3 ][ 0 ] * elements[ 1 ][ 1 ] * elements[ 2 ][ 3 ] -
                 elements[ 3 ][ 0 ] * elements[ 1 ][ 3 ] * elements[ 2 ][ 1 ];
 
-            ret.elements[ 3 ][ 0 ] = 
+            ret.elements[ 3 ][ 0 ] =
                 -elements[ 1 ][ 0 ] * elements[ 2 ][ 1 ] * elements[ 3 ][ 2 ] +
                 elements[ 1 ][ 0 ] * elements[ 2 ][ 2 ] * elements[ 3 ][ 1 ] +
                 elements[ 2 ][ 0 ] * elements[ 1 ][ 1 ] * elements[ 3 ][ 2 ] -
@@ -102,7 +102,7 @@ namespace Framework
                 elements[ 3 ][ 0 ] * elements[ 1 ][ 1 ] * elements[ 2 ][ 2 ] +
                 elements[ 3 ][ 0 ] * elements[ 1 ][ 2 ] * elements[ 2 ][ 1 ];
 
-            ret.elements[ 0 ][ 1 ] = 
+            ret.elements[ 0 ][ 1 ] =
                 -elements[ 0 ][ 1 ] * elements[ 2 ][ 2 ] * elements[ 3 ][ 3 ] +
                 elements[ 0 ][ 1 ] * elements[ 2 ][ 3 ] * elements[ 3 ][ 2 ] +
                 elements[ 2 ][ 1 ] * elements[ 0 ][ 2 ] * elements[ 3 ][ 3 ] -
@@ -110,7 +110,7 @@ namespace Framework
                 elements[ 3 ][ 1 ] * elements[ 0 ][ 2 ] * elements[ 2 ][ 3 ] +
                 elements[ 3 ][ 1 ] * elements[ 0 ][ 3 ] * elements[ 2 ][ 2 ];
 
-            ret.elements[ 1 ][ 1 ] = 
+            ret.elements[ 1 ][ 1 ] =
                 elements[ 0 ][ 0 ] * elements[ 2 ][ 2 ] * elements[ 3 ][ 3 ] -
                 elements[ 0 ][ 0 ] * elements[ 2 ][ 3 ] * elements[ 3 ][ 2 ] -
                 elements[ 2 ][ 0 ] * elements[ 0 ][ 2 ] * elements[ 3 ][ 3 ] +
@@ -118,7 +118,7 @@ namespace Framework
                 elements[ 3 ][ 0 ] * elements[ 0 ][ 2 ] * elements[ 2 ][ 3 ] -
                 elements[ 3 ][ 0 ] * elements[ 0 ][ 3 ] * elements[ 2 ][ 2 ];
 
-            ret.elements[ 2 ][ 1 ] = 
+            ret.elements[ 2 ][ 1 ] =
                 -elements[ 0 ][ 0 ] * elements[ 2 ][ 1 ] * elements[ 3 ][ 3 ] +
                 elements[ 0 ][ 0 ] * elements[ 2 ][ 3 ] * elements[ 3 ][ 1 ] +
                 elements[ 2 ][ 0 ] * elements[ 0 ][ 1 ] * elements[ 3 ][ 3 ] -
@@ -126,7 +126,7 @@ namespace Framework
                 elements[ 3 ][ 0 ] * elements[ 0 ][ 1 ] * elements[ 2 ][ 3 ] +
                 elements[ 3 ][ 0 ] * elements[ 0 ][ 3 ] * elements[ 2 ][ 1 ];
 
-            ret.elements[ 3 ][ 1 ] = 
+            ret.elements[ 3 ][ 1 ] =
                 elements[ 0 ][ 0 ] * elements[ 2 ][ 1 ] * elements[ 3 ][ 2 ] -
                 elements[ 0 ][ 0 ] * elements[ 2 ][ 2 ] * elements[ 3 ][ 1 ] -
                 elements[ 2 ][ 0 ] * elements[ 0 ][ 1 ] * elements[ 3 ][ 2 ] +
@@ -134,7 +134,7 @@ namespace Framework
                 elements[ 3 ][ 0 ] * elements[ 0 ][ 1 ] * elements[ 2 ][ 2 ] -
                 elements[ 3 ][ 0 ] * elements[ 0 ][ 2 ] * elements[ 2 ][ 1 ];
 
-            ret.elements[ 0 ][ 2 ] = 
+            ret.elements[ 0 ][ 2 ] =
                 elements[ 0 ][ 1 ] * elements[ 1 ][ 2 ] * elements[ 3 ][ 3 ] -
                 elements[ 0 ][ 1 ] * elements[ 1 ][ 3 ] * elements[ 3 ][ 2 ] -
                 elements[ 1 ][ 1 ] * elements[ 0 ][ 2 ] * elements[ 3 ][ 3 ] +
@@ -142,7 +142,7 @@ namespace Framework
                 elements[ 3 ][ 1 ] * elements[ 0 ][ 2 ] * elements[ 1 ][ 3 ] -
                 elements[ 3 ][ 1 ] * elements[ 0 ][ 3 ] * elements[ 1 ][ 2 ];
 
-            ret.elements[ 1 ][ 2 ] = 
+            ret.elements[ 1 ][ 2 ] =
                 -elements[ 0 ][ 0 ] * elements[ 1 ][ 2 ] * elements[ 3 ][ 3 ] +
                 elements[ 0 ][ 0 ] * elements[ 1 ][ 3 ] * elements[ 3 ][ 2 ] +
                 elements[ 1 ][ 0 ] * elements[ 0 ][ 2 ] * elements[ 3 ][ 3 ] -
@@ -150,7 +150,7 @@ namespace Framework
                 elements[ 3 ][ 0 ] * elements[ 0 ][ 2 ] * elements[ 1 ][ 3 ] +
                 elements[ 3 ][ 0 ] * elements[ 0 ][ 3 ] * elements[ 1 ][ 2 ];
 
-            ret.elements[ 2 ][ 2 ] = 
+            ret.elements[ 2 ][ 2 ] =
                 elements[ 0 ][ 0 ] * elements[ 1 ][ 1 ] * elements[ 3 ][ 3 ] -
                 elements[ 0 ][ 0 ] * elements[ 1 ][ 3 ] * elements[ 3 ][ 1 ] -
                 elements[ 1 ][ 0 ] * elements[ 0 ][ 1 ] * elements[ 3 ][ 3 ] +
@@ -158,7 +158,7 @@ namespace Framework
                 elements[ 3 ][ 0 ] * elements[ 0 ][ 1 ] * elements[ 1 ][ 3 ] -
                 elements[ 3 ][ 0 ] * elements[ 0 ][ 3 ] * elements[ 1 ][ 1 ];
 
-            ret.elements[ 3 ][ 2 ] = 
+            ret.elements[ 3 ][ 2 ] =
                 -elements[ 0 ][ 0 ] * elements[ 1 ][ 1 ] * elements[ 3 ][ 2 ] +
                 elements[ 0 ][ 0 ] * elements[ 1 ][ 2 ] * elements[ 3 ][ 1 ] +
                 elements[ 1 ][ 0 ] * elements[ 0 ][ 1 ] * elements[ 3 ][ 2 ] -
@@ -166,7 +166,7 @@ namespace Framework
                 elements[ 3 ][ 0 ] * elements[ 0 ][ 1 ] * elements[ 1 ][ 2 ] +
                 elements[ 3 ][ 0 ] * elements[ 0 ][ 2 ] * elements[ 1 ][ 1 ];
 
-            ret.elements[ 0 ][ 3 ] = 
+            ret.elements[ 0 ][ 3 ] =
                 -elements[ 0 ][ 1 ] * elements[ 1 ][ 2 ] * elements[ 2 ][ 3 ] +
                 elements[ 0 ][ 1 ] * elements[ 1 ][ 3 ] * elements[ 2 ][ 2 ] +
                 elements[ 1 ][ 1 ] * elements[ 0 ][ 2 ] * elements[ 2 ][ 3 ] -
@@ -174,7 +174,7 @@ namespace Framework
                 elements[ 2 ][ 1 ] * elements[ 0 ][ 2 ] * elements[ 1 ][ 3 ] +
                 elements[ 2 ][ 1 ] * elements[ 0 ][ 3 ] * elements[ 1 ][ 2 ];
 
-            ret.elements[ 1 ][ 3 ] = 
+            ret.elements[ 1 ][ 3 ] =
                 elements[ 0 ][ 0 ] * elements[ 1 ][ 2 ] * elements[ 2 ][ 3 ] -
                 elements[ 0 ][ 0 ] * elements[ 1 ][ 3 ] * elements[ 2 ][ 2 ] -
                 elements[ 1 ][ 0 ] * elements[ 0 ][ 2 ] * elements[ 2 ][ 3 ] +
@@ -182,7 +182,7 @@ namespace Framework
                 elements[ 2 ][ 0 ] * elements[ 0 ][ 2 ] * elements[ 1 ][ 3 ] -
                 elements[ 2 ][ 0 ] * elements[ 0 ][ 3 ] * elements[ 1 ][ 2 ];
 
-            ret.elements[ 2 ][ 3 ] = 
+            ret.elements[ 2 ][ 3 ] =
                 -elements[ 0 ][ 0 ] * elements[ 1 ][ 1 ] * elements[ 2 ][ 3 ] +
                 elements[ 0 ][ 0 ] * elements[ 1 ][ 3 ] * elements[ 2 ][ 1 ] +
                 elements[ 1 ][ 0 ] * elements[ 0 ][ 1 ] * elements[ 2 ][ 3 ] -
@@ -190,7 +190,7 @@ namespace Framework
                 elements[ 2 ][ 0 ] * elements[ 0 ][ 1 ] * elements[ 1 ][ 3 ] +
                 elements[ 2 ][ 0 ] * elements[ 0 ][ 3 ] * elements[ 1 ][ 1 ];
 
-            ret.elements[ 3 ][ 3 ] = 
+            ret.elements[ 3 ][ 3 ] =
                 elements[ 0 ][ 0 ] * elements[ 1 ][ 1 ] * elements[ 2 ][ 2 ] -
                 elements[ 0 ][ 0 ] * elements[ 1 ][ 2 ] * elements[ 2 ][ 1 ] -
                 elements[ 1 ][ 0 ] * elements[ 0 ][ 1 ] * elements[ 2 ][ 2 ] +
@@ -281,5 +281,25 @@ namespace Framework
             Mat4 i = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 };
             return i;
         }
+
+        // Gibt eine Rotationsmatrix zurück, so dass vector a wenn man ihn damit dreht in richtung des vectors b zeigt
+        //  a: der vector der gedreht werden soll
+        //  b: der vector zu dem gedreht werden soll
+        static Mat4 rotationTo( Vec3<T> &a, Vec3<T> &b )
+        {
+            Vec3 aNorm = Vec3( a ).normalize();
+            Vec3 bNorm = Vec3( b ).normalize();
+            Vec3 v = aNotm.crossProduct( bNorm );
+            T s = v.getLengthSq();
+            T c = aNorm * bNorm;
+            T m = ( 1 - c ) / s;
+            Mat3<T> cpm( { 0, -v.z, v.y, v.z, 0, -v.x, -v.y, v.x, 0 } );
+            Mat3<T> cpm2 = cpm * cpm;
+            Mat3<T> res = Mat3<T>::identity() + cpm + cpm2 * m;
+            return Mat4( { res.elements[ 0 ][ 0 ], res.elements[ 0 ][ 1 ], res.elements[ 0 ][ 2 ], 0,
+                           res.elements[ 1 ][ 0 ], res.elements[ 1 ][ 1 ], res.elements[ 1 ][ 2 ], 0,
+                           res.elements[ 2 ][ 0 ], res.elements[ 2 ][ 1 ], res.elements[ 2 ][ 2 ], 0,
+                           0, 0, 0, 1 } )
+        }
     };
 }

+ 6 - 2
Render3D.cpp

@@ -229,8 +229,12 @@ void Render3D::draw( DXIndexBuffer *zIndexBuffer, Textur *textur, D3D_PRIMITIVE_
     else
     {
         context->RSSetState( meshRS );
-        ID3D11ShaderResourceView *v = *defaultTextur;
-        context->PSSetShaderResources( 0, 1, &v );
+        if( lastTexturId == -1 || lastTexturId != defaultTextur->getId() )
+        {
+            ID3D11ShaderResourceView *v = *defaultTextur;
+            lastTexturId = defaultTextur->getId();
+            context->PSSetShaderResources( 0, 1, &v );
+        }
         context->DrawIndexed( zIndexBuffer->getElementAnzahl(), 0, 0 );
         context->RSSetState( texturRS );
     }

+ 6 - 0
Vec3.h

@@ -168,6 +168,12 @@ namespace Framework
         {
             return !( *this == r );
         }
+        // Gibt das Kreutzprodukt zwischen diesem und einem anderen Vector zurück
+        //  b: der andere Vector
+        inline Vec3 crossProduct( const Vec3 &b ) const
+        {
+            return Vec3( y * b.z - z * b.y, z * b.x - x * b.z, x * b.y - y * b.x );
+        }
     };
 }