forked from nvpro-samples/vk_raytracing_tutorial_KHR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
obj.hpp
66 lines (58 loc) · 1.93 KB
/
obj.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-FileCopyrightText: Copyright (c) 2014-2021 NVIDIA CORPORATION
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "obj_loader.h"
// The OBJ model
struct ObjModel
{
uint32_t nbIndices{0};
uint32_t nbVertices{0};
nvvk::Buffer vertexBuffer; // Device buffer of all 'Vertex'
nvvk::Buffer indexBuffer; // Device buffer of the indices forming triangles
nvvk::Buffer matColorBuffer; // Device buffer of array of 'Wavefront material'
nvvk::Buffer matIndexBuffer; // Device buffer of array of 'Wavefront material'
};
struct ObjInstance
{
nvmath::mat4f transform; // Matrix of the instance
uint32_t objIndex{0}; // Model index reference
};
enum EObjType
{
eSphere = 0,
eCube
};
// One single implicit object
struct ObjImplicit
{
nvmath::vec3f minimum{0, 0, 0}; // Aabb
nvmath::vec3f maximum{0, 0, 0}; // Aabb
int objType{0}; // 0: Sphere, 1: Cube
int matId{0};
};
// All implicit objects
struct ImplInst
{
std::vector<ObjImplicit> objImpl; // All objects
std::vector<MaterialObj> implMat; // All materials used by implicit obj
nvvk::Buffer implBuf; // Buffer of objects
nvvk::Buffer implMatBuf; // Buffer of material
int blasId{0};
nvmath::mat4f transform{1};
};