Rig3DSampleScene() : mMouseX(0.0f), mMouseY(0.0f), mAllocator(2048), mRenderer(nullptr), mCubeMesh(nullptr), mQuadMesh(nullptr), mRenderContext(nullptr), mBlurShaderResource(nullptr), mSphereShaderResource(nullptr), mVertexShader(nullptr), mPixelShader(nullptr), mSCPixelShader(nullptr), mQuadVertexShader(nullptr), mQuadBlurPixelShader(nullptr), mMotionBlurPixelShader(nullptr), mSphereColliders(nullptr) { mOptions.mWindowCaption = "Rig3D Sample"; mOptions.mWindowWidth = 800; mOptions.mWindowHeight = 600; mOptions.mGraphicsAPI = GRAPHICS_API_DIRECTX11; mOptions.mFullScreen = false; mBlurType = BLUR_TYPE_NONE; mClearColor = { 0.2f, 0.2f, 0.2f, 1.0f }; mMeshLibrary.SetAllocator(&mAllocator); }
void InitializeGeometry() { OBJResource<Vertex4> resource ("Models\\Sphere.obj"); mMeshLibrary.LoadMesh(&mCubeMesh, mRenderer, resource); SampleVertex qVertices[4]; qVertices[0].mPosition = { -1.0f, 1.0f, 0.0f }; qVertices[0].mUV = { 0.0f, 0.0f}; qVertices[1].mPosition = { 1.0f, 1.0f, 0.0f }; qVertices[1].mUV = { 1.0f, 0.0f}; qVertices[2].mPosition = { 1.0f, -1.0f, 0.0f }; qVertices[2].mUV = { 1.0f, 1.0f }; qVertices[3].mPosition = { -1.0f, -1.0f, 0.0f }; qVertices[3].mUV = { 0.0f, 1.0f}; uint16_t qIndices[6]; qIndices[0] = 0; qIndices[1] = 1; qIndices[2] = 2; qIndices[3] = 2; qIndices[4] = 3; qIndices[5] = 0; mMeshLibrary.NewMesh(&mQuadMesh, mRenderer); mRenderer->VSetStaticMeshVertexBuffer(mQuadMesh, qVertices, sizeof(SampleVertex) * 4, sizeof(SampleVertex)); mRenderer->VSetStaticMeshIndexBuffer(mQuadMesh, qIndices, 6); mSphereColliders = reinterpret_cast<SphereCollider*>(mAllocator.Allocate(sizeof(SphereCollider) * NODE_COUNT, alignof(SphereCollider), 0)); for (int i = 0; i < NODE_COUNT; i++) { mSceneNodes[i].mTransform.SetPosition((float)(rand() % 10) - 5.0f, (float)(rand() % 10) - 5.0f, (float)(rand() % 5)); mSceneNodes[i].mColor = { SATURATE_RANDOM, SATURATE_RANDOM, SATURATE_RANDOM, 1.0f }; mSceneNodes[i].mMesh = mCubeMesh; mSceneNodes[i].mCollider = &mSphereColliders[i]; mSceneNodes[i].mCollider->origin = mSceneNodes[i].mTransform.GetPosition(); mSceneNodes[i].mCollider->radius = 0.5f; } mCamera.SetPosition( 0.0f, 0.0, -10.0f ); }
Rig3DSampleScene() : mAllocator(1024) { mOptions.mWindowCaption = "SIMD Bezier"; mOptions.mWindowWidth = 800; mOptions.mWindowHeight = 600; mOptions.mGraphicsAPI = GRAPHICS_API_DIRECTX11; mOptions.mFullScreen = false; mMeshLibrary.SetAllocator(&mAllocator); size_t a = alignof(Bezier); }
Rig3DSampleScene() : mAllocator(1024), mCubeMesh(nullptr), mRenderer(nullptr), mVertexShader(nullptr), mPixelShader(nullptr), mShaderResource(nullptr) { mOptions.mWindowCaption = "Key Frame Sample"; mOptions.mWindowWidth = 800; mOptions.mWindowHeight = 600; mOptions.mGraphicsAPI = GRAPHICS_API_DIRECTX11; mOptions.mFullScreen = false; mAnimationTime = 0.0f; mIsPlaying = false; mMeshLibrary.SetAllocator(&mAllocator); mInterpolationMode = INTERPOLATION_MODE_LINEAR; }
void InitializeGeometry() { // ---- Bezier // allocate a sizeof BEZIER_VERTEX_COUNT * 2 to simplify our upcoming loop. uint16_t bezierIndices[BEZIER_VERTEX_COUNT * 2]; for (size_t i = 0, j = 0; i < BEZIER_VERTEX_COUNT; i++, j += 2) { mBezierVertices[i].mColor = { 1.0f, 1.0f, 0.0f }; mBezierVertices[i].mPosition = vec3f(); bezierIndices[j] = i; bezierIndices[j + 1] = i + 1; } mMeshLibrary.NewMesh(&mBezierMesh, mRenderer); mRenderer->VSetMeshVertexBufferData(mBezierMesh, mBezierVertices, sizeof(BezierVertex) * BEZIER_VERTEX_COUNT, sizeof(BezierVertex), GPU_MEMORY_USAGE_DEFAULT); mRenderer->VSetMeshIndexBufferData(mBezierMesh, bezierIndices, BEZIER_INDEX_COUNT, GPU_MEMORY_USAGE_DEFAULT); // -- Handles uint16_t handlesIndices[HANDLES_INDEX_COUNT]; for (size_t i = 0; i < HANDLES_VERTEX_COUNT; i++) { mHandlesVertices[i].mColor = { 0.5f, 0.5f, 0.5f }; mHandlesVertices[i].mPosition = vec3f(1); handlesIndices[i] = i; } mMeshLibrary.NewMesh(&mHandlesMesh, mRenderer); mRenderer->VSetMeshVertexBufferData(mHandlesMesh, mHandlesVertices, sizeof(BezierVertex) * HANDLES_VERTEX_COUNT, sizeof(BezierVertex), GPU_MEMORY_USAGE_DEFAULT); mRenderer->VSetMeshIndexBufferData(mHandlesMesh, handlesIndices, HANDLES_INDEX_COUNT, GPU_MEMORY_USAGE_DEFAULT); // -- Circle BezierVertex circleVertices[CIRCLE_VERTEX_COUNT]; uint16_t circleIndices[CIRCLE_INDEX_COUNT]; circleVertices[0].mColor = { 0.6f, 0.6f, 0.6f }; circleVertices[0].mPosition = vec3f(); float t; auto index = 0; for (size_t i = 1; i < CIRCLE_VERTEX_COUNT; i++) { t = -static_cast<float>(i) * 2 * PI / (CIRCLE_VERTEX_COUNT - 1); circleVertices[i].mColor = { 0.6f, 0.6f, 0.6f }; circleVertices[i].mPosition = { cos(t), sin(t), 0.0f }; circleIndices[index++] = 0; circleIndices[index++] = i; circleIndices[index++] = i + 1; } circleIndices[index - 1] = 1; mMeshLibrary.NewMesh(&mCircleMesh, mRenderer); mRenderer->VSetMeshVertexBufferData(mCircleMesh, circleVertices, sizeof(BezierVertex) * CIRCLE_VERTEX_COUNT, sizeof(BezierVertex), GPU_MEMORY_USAGE_DEFAULT); mRenderer->VSetMeshIndexBufferData(mCircleMesh, circleIndices, CIRCLE_INDEX_COUNT, GPU_MEMORY_USAGE_DEFAULT); }
void InitializeGeometry() { SampleVertex vertices[VERTEX_COUNT]; vertices[0].mPosition = { -0.5f, +0.5f, +0.5f }; // Front Top Left vertices[0].mColor = { +1.0f, +1.0f, +0.0f }; vertices[1].mPosition = { +0.5f, +0.5f, +0.5f }; // Front Top Right vertices[1].mColor = { +1.0f, +1.0f, +1.0f }; vertices[2].mPosition = { +0.5f, -0.5f, +0.5f }; // Front Bottom Right vertices[2].mColor = { +1.0f, +0.0f, +1.0f }; vertices[3].mPosition = { -0.5f, -0.5f, +0.5f }; // Front Bottom Left vertices[3].mColor = { +1.0f, +0.0f, +0.0f }; vertices[4].mPosition = { -0.5f, +0.5f, -0.5f };; // Back Top Left vertices[4].mColor = { +0.0f, +1.0f, +0.0f }; vertices[5].mPosition = { +0.5f, +0.5f, -0.5f }; // Back Top Right vertices[5].mColor = { +0.0f, +1.0f, +1.0f }; vertices[6].mPosition = { +0.5f, -0.5f, -0.5f }; // Back Bottom Right vertices[6].mColor = { +1.0f, +0.0f, +1.0f }; vertices[7].mPosition = { -0.5f, -0.5f, -0.5f }; // Back Bottom Left vertices[7].mColor = { +0.0f, +0.0f, +0.0f }; uint16_t indices[INDEX_COUNT]; // Front Face indices[0] = 0; indices[1] = 1; indices[2] = 2; indices[3] = 2; indices[4] = 3; indices[5] = 0; // Right Face indices[6] = 1; indices[7] = 5; indices[8] = 6; indices[9] = 6; indices[10] = 2; indices[11] = 1; // Back Face indices[12] = 5; indices[13] = 4; indices[14] = 7; indices[15] = 7; indices[16] = 6; indices[17] = 5; // Left Face indices[18] = 4; indices[19] = 0; indices[20] = 3; indices[21] = 3; indices[22] = 7; indices[23] = 4; // Top Face indices[24] = 4; indices[25] = 5; indices[26] = 1; indices[27] = 1; indices[28] = 0; indices[29] = 4; // Bottom Face indices[30] = 3; indices[31] = 2; indices[32] = 6; indices[33] = 6; indices[34] = 7; indices[35] = 3; mMeshLibrary.NewMesh(&mCubeMesh, mRenderer); mRenderer->VSetMeshVertexBuffer(mCubeMesh, vertices, sizeof(SampleVertex) * VERTEX_COUNT, sizeof(SampleVertex)); mRenderer->VSetMeshIndexBuffer(mCubeMesh, indices, INDEX_COUNT); }