Browse Source

Shader Für Knochen Animation fertig angepasst

Kolja Strohm 8 years ago
parent
commit
26d691af7d
5 changed files with 35 additions and 2 deletions
  1. 2 0
      Cube.cpp
  2. 1 1
      DefaultShader.h
  3. 1 0
      Model3D.cpp
  4. 30 0
      TexturModel.cpp
  5. 1 1
      Zeichnung3D.cpp

+ 2 - 0
Cube.cpp

@@ -34,6 +34,8 @@ Cube::Cube( float size )
         float back = front + stdSize;
 
         Vertex3D *vertecies = new Vertex3D[ 24 ];
+        for( int i = 0; i < 24; i++ )
+            vertecies[ i ].knochenId = 0;
         vertecies[ 0 ].pos = Vec3<float >( left, top, front );
         vertecies[ 0 ].tPos = Vec2< float >( 0.f, 0.f );
         vertecies[ 1 ].pos = Vec3<float >( right, top, front );

+ 1 - 1
DefaultShader.h

@@ -23,7 +23,7 @@ namespace Framework
         {                                                                                               \n\
             float4 position : POSITION;                                                                 \n\
             float2 tex : TEXCOORD0;                                                                     \n\
-            int knochen : KNOCHEN_ID;                                                                   \n\
+            uint knochen : KNOCHEN_ID0;                                                                 \n\
         };                                                                                              \n\
                                                                                                         \n\
         struct PixelInputType                                                                           \n\

+ 1 - 0
Model3D.cpp

@@ -319,6 +319,7 @@ void Model3D::render( Render3D *zRObj )
 {
     if( !model )
         return;
+    model->aktualisiereVertecies( zRObj );
     zRObj->beginnModel( this );
     model->render( welt, textur, zRObj );
 }

+ 30 - 0
TexturModel.cpp

@@ -13,6 +13,8 @@ TexturModel::TexturModel()
     : Model3D()
 {
     Vertex3D *vertecies = new Vertex3D[ 4 ];
+    for( int i = 0; i < 4; i++ )
+        vertecies[ i ].knochenId = 0;
     vertecies[ 0 ].pos = Vec3<float >( -50, 50, 0.f );
     vertecies[ 0 ].tPos = Vec2< float >( 0.f, 0.f );
     vertecies[ 1 ].pos = Vec3<float >( 50, 50, 0.f );
@@ -67,6 +69,8 @@ void TexturModel::setGr
 {
     gr /= 2;
     Vertex3D *vertecies = new Vertex3D[ 4 ];
+    for( int i = 0; i < 4; i++ )
+        vertecies[ i ].knochenId = 0;
     vertecies[ 0 ].pos = Vec3<float >( -gr.x, gr.y, 0.f );
     vertecies[ 0 ].tPos = Vec2< float >( 0.f, 0.f );
     vertecies[ 1 ].pos = Vec3<float >( gr.x, gr.y, 0.f );
@@ -76,6 +80,18 @@ void TexturModel::setGr
     vertecies[ 3 ].pos = Vec3<float >( gr.x, -gr.y, 0.f );
     vertecies[ 3 ].tPos = Vec2< float >( 1.f, 1.f );
     model->setVertecies( vertecies, 4 );
+    Polygon3D *p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[ p->indexAnz ];
+    p->indexBuffer->setLänge( p->indexAnz * 4 );
+    p->indexBuffer->setData( p->indexList );
+    p->indexList[ 0 ] = 0;
+    p->indexList[ 1 ] = 3;
+    p->indexList[ 2 ] = 2;
+    p->indexList[ 3 ] = 0;
+    p->indexList[ 4 ] = 1;
+    p->indexList[ 5 ] = 3;
+    model->addPolygon( p );
 }
 
 // Setzt die Größe, in der die Textur angezeigt wird
@@ -86,6 +102,8 @@ void TexturModel::setGr
     b /= 2;
     h /= 2;
     Vertex3D *vertecies = new Vertex3D[ 4 ];
+    for( int i = 0; i < 4; i++ )
+        vertecies[ i ].knochenId = 0;
     vertecies[ 0 ].pos = Vec3<float >( -b, h, 0.f );
     vertecies[ 0 ].tPos = Vec2< float >( 0.f, 0.f );
     vertecies[ 1 ].pos = Vec3<float >( b, h, 0.f );
@@ -95,6 +113,18 @@ void TexturModel::setGr
     vertecies[ 3 ].pos = Vec3<float >( b, -h, 0.f );
     vertecies[ 3 ].tPos = Vec2< float >( 1.f, 1.f );
     model->setVertecies( vertecies, 4 );
+    Polygon3D *p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[ p->indexAnz ];
+    p->indexBuffer->setLänge( p->indexAnz * 4 );
+    p->indexBuffer->setData( p->indexList );
+    p->indexList[ 0 ] = 0;
+    p->indexList[ 1 ] = 3;
+    p->indexList[ 2 ] = 2;
+    p->indexList[ 3 ] = 0;
+    p->indexList[ 4 ] = 1;
+    p->indexList[ 5 ] = 3;
+    model->addPolygon( p );
 }
 
 // Verringert den Reference Counting Zähler. Wenn der Zähler 0 erreicht, wird das Zeichnung automatisch gelöscht.

+ 1 - 1
Zeichnung3D.cpp

@@ -116,7 +116,7 @@ void Zeichnung3D::setAlpha( bool a )
 //  return: Die Anzahl der Matrizen, die die Zeichnung benötigt
 int Zeichnung3D::errechneMatrizen( Mat4< float > &viewProj, Mat4< float > *matBuffer )
 {
-    matBuffer[ 0 ] = welt * viewProj;
+    matBuffer[ 0 ] = viewProj * welt;
     return 1;
 }