NTrace
GPU ray tracing framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Scene.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2011, NVIDIA Corporation
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of NVIDIA Corporation nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
32 #pragma once
33 #include "base/Math.hpp"
34 #include "3d/Mesh.hpp"
35 #include "3d/TextureAtlas.hpp"
36 
37 namespace FW
38 {
39 //------------------------------------------------------------------------
40 
44 class Scene
45 {
46 public:
51  Scene (const MeshBase& mesh);
52 
56  ~Scene (void);
57 
61  int getNumTriangles (void) const { return m_numTriangles; }
62 
66  int getNumVertices (void) const { return m_numVertices; }
67 
68  int getNumEmissive (void) const { return m_numEmissive; }
69 
75  Buffer& getTriVtxIndexBuffer (void) { return m_triVtxIndex; }
76 
82  Buffer& getTriNormalBuffer (void) { return m_triNormal; }
83 
89  Buffer& getTriMaterialColorBuffer (void) { return m_triMaterialColor; }
90 
96  Buffer& getTriShadedColorBuffer (void) { return m_triShadedColor; }
97 
103  Buffer& getVtxPosBuffer (void) { return m_vtxPos; }
104 
110  Buffer& getVtxNormalBuffer (void) { return m_vtxNorm; }
111 
117  Buffer& getVtxTexCoordBuffer (void) { return m_vtxTC; }
118 
124  Buffer& getTextureAtlasInfo (void) { return m_atlasInfo; }
125 
131  Buffer& getMaterialIds (void) { return m_matId; }
132 
138  Buffer& getEmissiveTris (void) { return m_emissiveTris; }
139 
145  Buffer& getMaterialInfo (void) { return m_matInfo; }
146 
151  TextureAtlas* getTextureAtlas (void) { return m_texture; }
152 
156  U32 hash (void);
157 
163  void getBBox(Vec3f& lo, Vec3f &hi) const {lo = m_AABBMin; hi = m_AABBMax;};
164 private:
165  Scene (const Scene&); // forbidden
166  Scene& operator= (const Scene&); // forbidden
167 
168 private:
169  S32 m_numTriangles;
170  S32 m_numVertices;
171  S32 m_numEmissive;
172  Buffer m_triVtxIndex;
173  Buffer m_triNormal;
174  Buffer m_triMaterialColor;
175  Buffer m_triShadedColor;
176  Buffer m_vtxPos;
177  Buffer m_vtxNorm;
178  Buffer m_vtxTC;
179  Buffer m_atlasInfo;
180  Buffer m_matId;
181  Buffer m_emissiveTris;
182  Buffer m_matInfo;
183  Vec3f m_AABBMin, m_AABBMax;
184  TextureAtlas* m_texture;
185 };
186 
187 //------------------------------------------------------------------------
188 }
Buffer & getTriMaterialColorBuffer(void)
Returns material color buffer.
Definition: Scene.hpp:89
Buffer & getTriVtxIndexBuffer(void)
Returns buffer of triangle's vertex indieces.
Definition: Scene.hpp:75
Buffer & getMaterialIds(void)
Returns material id buffer.
Definition: Scene.hpp:131
Scene(const MeshBase &mesh)
Constructor.
Definition: Scene.cpp:34
Buffer & getTriNormalBuffer(void)
Returns triangle normal buffer.
Definition: Scene.hpp:82
Buffer & getVtxPosBuffer(void)
Returns vertex position buffer.
Definition: Scene.hpp:103
TextureAtlas * getTextureAtlas(void)
Returns texture atlas holding scene's textures.
Definition: Scene.hpp:151
void getBBox(Vec3f &lo, Vec3f &hi) const
Gets scene AABB's minimum and maximum vector.
Definition: Scene.hpp:163
int getNumVertices(void) const
Definition: Scene.hpp:66
Buffer & getTriShadedColorBuffer(void)
Returns shaded color buffer.
Definition: Scene.hpp:96
Buffer & getTextureAtlasInfo(void)
Returns texture atlas information buffer.
Definition: Scene.hpp:124
int getNumTriangles(void) const
Definition: Scene.hpp:61
~Scene(void)
Destructor.
Definition: Scene.cpp:168
signed int S32
Definition: Defs.hpp:88
Buffer & getMaterialInfo(void)
Returns material info buffer.
Definition: Scene.hpp:145
unsigned int U32
Definition: Defs.hpp:85
Class holding 3d scene.
Definition: Scene.hpp:44
int getNumEmissive(void) const
Definition: Scene.hpp:68
Buffer & getVtxNormalBuffer(void)
Returns vertex normal buffer.
Definition: Scene.hpp:110
Buffer & getEmissiveTris(void)
Returns buffer of emissive triangles.
Definition: Scene.hpp:138
U32 hash(void)
Definition: Scene.cpp:174
Buffer & getVtxTexCoordBuffer(void)
Returns vertex texture coordinate buffer.
Definition: Scene.hpp:117