Advertisement
Ember

app

Dec 14th, 2015
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.86 KB | None | 0 0
  1. Void Testbed::Create()
  2. {
  3.     Scene::Manager* sceneManager = Scene::Manager::Singleton;
  4.  
  5.     Array<Mesh::Vertex> vertices;
  6.     // Setup some vertices
  7.     Float x, y, z; x = y = z = 1.0f;
  8.     // -- //
  9.     vertices.Reserve(8);
  10.     // -- //
  11.     vertices[0].Position = Float3(x, y, z);
  12.     vertices[1].Position = Float3(-x, y, z);
  13.     vertices[2].Position = Float3(x, -y, z);
  14.     vertices[3].Position = Float3(-x, -y, z);
  15.     vertices[4].Position = Float3(x, y, -z);
  16.     vertices[5].Position = Float3(-x, y, -z);
  17.     vertices[6].Position = Float3(x, -y, -z);
  18.     vertices[7].Position = Float3(-x, -y, -z);
  19.     // -- //
  20.     vertices.Count = 8;
  21.  
  22.     Array<UShort3> indices;
  23.     // Set up the indices
  24.     indices.Reserve(12);
  25.     // +x (yz plane)
  26.     indices[0] = UShort3(0, 2, 6);
  27.     indices[1] = UShort3(6, 4, 0);
  28.     // +y (xz)
  29.     indices[2] = UShort3(1, 0, 4);
  30.     indices[3] = UShort3(4, 5, 1);
  31.     // +z (xy)
  32.     indices[4] = UShort3(0, 2, 3);
  33.     indices[5] = UShort3(3, 1, 0);
  34.     // -x
  35.     indices[6] = UShort3(1, 3, 7);
  36.     indices[7] = UShort3(7, 5, 1);
  37.     // -y
  38.     indices[8] = UShort3(3, 2, 6);
  39.     indices[9] = UShort3(6, 7, 3);
  40.     // -z
  41.     indices[10] = UShort3(4, 6, 7);
  42.     indices[11] = UShort3(7, 5, 4);
  43.     // -- //
  44.     indices.Count = 12;
  45.  
  46.     mModel = Model::Create("Test/Cube", vertices, indices);
  47.  
  48.     // Create a node and attach the model to it
  49.     mNode = sceneManager->CreateNode();
  50.     mNode->Attachment = mModel.Handle;
  51.  
  52.     // Reset our timer
  53.     mTimer.Reset();
  54. }
  55.  
  56. Void Testbed::Update()
  57. {
  58.     Float time = mTimer.Elapsed(Timer::Seconds);
  59.     // Generate the transforms and constant buffer data
  60.     //Aligned Float4x4 world = Identity(); //To4x4(RotationZ(time * (1 + key->Held('D')))); //To4x4(RotationZ(fmod(ttime * 1.0f, 1.0f) * Pi * 2.0f));
  61.     mNode->Position.xy = Float2(1.0f * cosf(time), 1.0f * sinf(time));
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement