aboutsummaryrefslogtreecommitdiff
path: root/NvBlast/tools/ArtistTools/source/BlastPlugin/SampleBase/renderer/PrimitiveRenderMesh.cpp
diff options
context:
space:
mode:
authorBryan Galdrikian <[email protected]>2017-02-24 09:32:20 -0800
committerBryan Galdrikian <[email protected]>2017-02-24 09:32:20 -0800
commite1bf674c16e3c8472b29574159c789cd3f0c64e0 (patch)
tree9f0cfce09c71a2c27ff19589fcad6cd83504477c /NvBlast/tools/ArtistTools/source/BlastPlugin/SampleBase/renderer/PrimitiveRenderMesh.cpp
parentfirst commit (diff)
downloadblast-e1bf674c16e3c8472b29574159c789cd3f0c64e0.tar.xz
blast-e1bf674c16e3c8472b29574159c789cd3f0c64e0.zip
Updating to [email protected] and [email protected] with a new directory structure.
NvBlast folder is gone, files have been moved to top level directory. README is changed to reflect this.
Diffstat (limited to 'NvBlast/tools/ArtistTools/source/BlastPlugin/SampleBase/renderer/PrimitiveRenderMesh.cpp')
-rw-r--r--NvBlast/tools/ArtistTools/source/BlastPlugin/SampleBase/renderer/PrimitiveRenderMesh.cpp284
1 files changed, 0 insertions, 284 deletions
diff --git a/NvBlast/tools/ArtistTools/source/BlastPlugin/SampleBase/renderer/PrimitiveRenderMesh.cpp b/NvBlast/tools/ArtistTools/source/BlastPlugin/SampleBase/renderer/PrimitiveRenderMesh.cpp
deleted file mode 100644
index 06c7616..0000000
--- a/NvBlast/tools/ArtistTools/source/BlastPlugin/SampleBase/renderer/PrimitiveRenderMesh.cpp
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
-* Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
-*
-* NVIDIA CORPORATION and its licensors retain all intellectual property
-* and proprietary rights in and to this software, related documentation
-* and any modifications thereto. Any use, reproduction, disclosure or
-* distribution of this software and related documentation without an express
-* license agreement from NVIDIA CORPORATION is strictly prohibited.
-*/
-
-
-#include "PrimitiveRenderMesh.h"
-#include "Renderer.h"
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Base Mesh internal class
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-PrimitiveRenderMesh::PrimitiveRenderMesh(const float v[], UINT numVertices)
-{
- std::vector<D3D11_INPUT_ELEMENT_DESC> layout;
- layout.push_back({ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 });
- layout.push_back({ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 });
-
- initialize(v, numVertices, sizeof(float) * 6, layout, nullptr, 0);
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Box Mesh
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-const float boxVertices[] =
-{
- -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f,
- 1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f,
- 1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f,
- 1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f,
- -1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f,
- -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f,
-
- -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
- 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
- 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
- 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
- -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
- -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
-
- -1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 0.0f,
- -1.0f, -1.0f, -1.0f, -1.0f, 0.0f, 0.0f,
- -1.0f, 1.0f, -1.0f, -1.0f, 0.0f, 0.0f,
- -1.0f, -1.0f, -1.0f, -1.0f, 0.0f, 0.0f,
- -1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 0.0f,
- -1.0f, -1.0f, 1.0f, -1.0f, 0.0f, 0.0f,
-
- 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f,
- 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f,
- 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f,
- 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f,
- 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f,
- 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f,
-
- -1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f,
- 1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f,
- 1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f,
- 1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f,
- -1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f,
- -1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f,
-
- -1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
- 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
- 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f,
- 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f,
- -1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f,
- -1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f
-};
-
-BoxRenderMesh::BoxRenderMesh() : PrimitiveRenderMesh(boxVertices, sizeof(boxVertices) / (6 * sizeof(boxVertices[0]))) {}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Plane Mesh
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-const float planeSize = 1.0f; // we use scaling instead
-const float planeTilesCount = 1000.0f;
-
-const float planeVertices[] =
-{
- 0, planeSize, planeSize, 1.0f, 0.0f, 0.0f, planeTilesCount, planeTilesCount,
- 0, planeSize, -planeSize, 1.0f, 0.0f, 0.0f, planeTilesCount, -planeTilesCount,
- 0, -planeSize, -planeSize, 1.0f, 0.0f, 0.0f, -planeTilesCount, -planeTilesCount,
- 0, -planeSize, -planeSize, 1.0f, 0.0f, 0.0f, -planeTilesCount, -planeTilesCount,
- 0, -planeSize, planeSize, 1.0f, 0.0f, 0.0f, -planeTilesCount, planeTilesCount,
- 0, planeSize, planeSize, 1.0f, 0.0f, 0.0f, planeTilesCount, planeTilesCount
-};
-
-PlaneRenderMesh::PlaneRenderMesh()
-{
- std::vector<D3D11_INPUT_ELEMENT_DESC> layout;
- layout.push_back({ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 });
- layout.push_back({ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 });
- layout.push_back({ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 });
-
- initialize(planeVertices, sizeof(planeVertices) / (8 * sizeof(planeVertices[0])), sizeof(float) * 8, layout, nullptr, 0);
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Sphere Mesh
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-const uint32_t g_numSlices = 8; // along lines of longitude
-const uint32_t g_numStacks = 16; // along lines of latitude
-
-const uint32_t g_numSphereVertices = (g_numSlices * 2 + 1)*(g_numStacks + 1);
-const uint32_t g_numSphereIndices = g_numSlices * 2 * g_numStacks * 6;
-
-const uint32_t g_numConeVertices = (g_numSlices * 2 + 1) * 2;
-const uint32_t g_numConeIndices = g_numSlices * 2 * 6;
-
-PxVec3 g_spherePositions[g_numSphereVertices];
-uint16_t g_sphereIndices[g_numSphereIndices];
-
-void generateSphereMesh(uint16_t slices, uint16_t stacks, PxVec3* positions, uint16_t* indices)
-{
- const PxF32 thetaStep = PxPi / stacks;
- const PxF32 phiStep = PxTwoPi / (slices * 2);
-
- PxF32 theta = 0.0f;
-
- // generate vertices
- for (uint16_t y = 0; y <= stacks; ++y)
- {
- PxF32 phi = 0.0f;
-
- PxF32 cosTheta = PxCos(theta);
- PxF32 sinTheta = PxSin(theta);
-
- for (uint16_t x = 0; x <= slices * 2; ++x)
- {
- PxF32 cosPhi = PxCos(phi);
- PxF32 sinPhi = PxSin(phi);
-
- PxVec3 p(cosPhi*sinTheta, cosTheta, sinPhi*sinTheta);
-
- // write vertex
- *(positions++) = p;
-
- phi += phiStep;
- }
-
- theta += thetaStep;
- }
-
- const uint16_t numRingQuads = 2 * slices;
- const uint16_t numRingVerts = 2 * slices + 1;
-
- // add faces
- for (uint16_t y = 0; y < stacks; ++y)
- {
- for (uint16_t i = 0; i < numRingQuads; ++i)
- {
- // add a quad
- *(indices++) = (y + 0)*numRingVerts + i;
- *(indices++) = (y + 1)*numRingVerts + i;
- *(indices++) = (y + 1)*numRingVerts + i + 1;
-
- *(indices++) = (y + 1)*numRingVerts + i + 1;
- *(indices++) = (y + 0)*numRingVerts + i + 1;
- *(indices++) = (y + 0)*numRingVerts + i;
- }
- }
-}
-
-
-struct SphereVertex
-{
- PxVec3 position;
- PxVec3 normal;
-};
-
-SphereRenderMesh::SphereRenderMesh()
-{
- generateSphereMesh(g_numSlices, g_numStacks, g_spherePositions, g_sphereIndices);
-
- std::vector<SphereVertex> vertices;
- for (uint32_t i = 0; i < g_numSphereVertices; i++)
- {
- vertices.push_back({ g_spherePositions[i], g_spherePositions[i] });
- }
-
- std::vector<D3D11_INPUT_ELEMENT_DESC> layout;
- layout.push_back({ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 });
- layout.push_back({ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 });
-
- initialize(vertices.data(), (uint32_t)vertices.size(), sizeof(SphereVertex), layout, g_sphereIndices, g_numSphereIndices);
-}
-
-
-SphereRenderMesh::~SphereRenderMesh()
-{
-}
-
-// Add By Lixu Begin
-const float coneVertices[] =
-{
- 0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 0.0f,//top
- -1.0f, -1.0f, 1.0f, -1.0f, 0.0f, 0.0f,//left bottom
- -1.0f, -1.0f, -1.0f, -1.0f, 0.0f, 0.0f,//left top
-
- 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f,//top
- 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f,//right top
- 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f,//right bottom
-
- 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f,//top
- -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f,//left top
- 1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f,//right top
-
- 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f,//top
- 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f,//right bottom
- -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f,//left bottom
-
- -1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f,//left top
- 1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f,//right bottom
- 1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f,//right top
-
- 1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f,//right bottom
- -1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f,//left top
- -1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f,//left bottom
-};
-
-ConeRenderMesh::ConeRenderMesh() : PrimitiveRenderMesh(coneVertices, sizeof(coneVertices) / (6 * sizeof(coneVertices[0]))) {}
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// FBX Mesh class
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-#include <AnimUtil.h>
-#include <PxVec2.h>
-#include <vector>
-
-struct FBXVertex
-{
- PxVec3 position;
- PxVec3 normal;
- PxVec2 uv;
-};
-
-FBXRenderMesh::FBXRenderMesh(MeshDesc* pMeshData)
-{
- std::vector<D3D11_INPUT_ELEMENT_DESC> layout;
- layout.push_back({ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 });
- layout.push_back({ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 });
- layout.push_back({ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 });
-
- std::vector<FBXVertex> vertices;
- std::vector<uint16_t> indices;
-
- for (uint32_t i = 0; i < pMeshData->m_NumVertices; ++i)
- {
- atcore_float3 pos = pMeshData->m_pVertices[i];
- atcore_float3 vertexNormal = pMeshData->m_pVertexNormals[i];
- atcore_float2 texcoord = pMeshData->m_pTexCoords[i];
-
- FBXVertex newVertex;
- newVertex.position = physx::PxVec3(pos.x, pos.y, pos.z);
- newVertex.normal = physx::PxVec3(vertexNormal.x, vertexNormal.y, vertexNormal.z);
- newVertex.uv = physx::PxVec2(texcoord.x, texcoord.y);
-
- vertices.push_back(newVertex);
- }
-
- for (uint32_t i = 0; i < pMeshData->m_NumTriangles; ++i)
- {
- indices.push_back(pMeshData->m_pIndices[i * 3 + 0]);
- indices.push_back(pMeshData->m_pIndices[i * 3 + 1]);
- indices.push_back(pMeshData->m_pIndices[i * 3 + 2]);
- }
-
- initialize(vertices.data(), (uint32_t)vertices.size(), sizeof(FBXVertex), layout, indices.data(), (uint32_t)indices.size());
-}
-// Add By Lixu End \ No newline at end of file