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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
/*
* Copyright (c) 2008-2017, 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.
*/
#ifndef RENDER_MESH_H
#define RENDER_MESH_H
/*!
\file
\brief classes RenderSubmesh, VertexBuffer, and MaterialNamingConvention enums
*/
#include "ApexUsingNamespace.h"
#include "VertexFormat.h"
namespace nvidia
{
namespace apex
{
PX_PUSH_PACK_DEFAULT
class RenderMeshActor;
class Context;
struct VertexUV;
/**
\brief a vertex buffer that supports multiple formats
*/
class VertexBuffer
{
public:
/**
\brief Returns the number of vertices in the buffer
*/
virtual uint32_t getVertexCount() const = 0;
/**
\brief Returns the data format. See VertexFormat.
*/
virtual const VertexFormat& getFormat() const = 0;
/**
\brief Returns the data format. See VertexFormat. Can be changed.
*/
virtual VertexFormat& getFormatWritable() = 0;
/**
\brief Accessor for the data buffer indexed by bufferIndex. To get the buffer format, use getFormat().getBufferFormat( index ).
If the data channel doesn't exist then this function returns NULL.
*/
virtual const void* getBuffer(uint32_t bufferIndex) const = 0;
/**
\brief Like getBuffer(), but also returns the buffer's format.
*/
virtual const void* getBufferAndFormat(RenderDataFormat::Enum& format, uint32_t bufferIndex) const = 0;
/**
\brief Like getBuffer(), but also returns the buffer's format. Can be changed.
*/
virtual void* getBufferAndFormatWritable(RenderDataFormat::Enum& format, uint32_t bufferIndex) = 0;
/**
\brief Accessor for data in a desired format from the buffer indexed by bufferIndex. If the channel does not exist, or if it is in
a format for which there is not presently a converter to the the desired format dstBufferFormat, this function returns false.
The dstBufferStride field must be at least the size of the dstBufferFormat data, or zero (in which case the stride is assumed to be
the size of the dstBufferFormat data). If neither of these conditions hold, this function returns false.
Otherwise, dstBuffer is filled in with elementCount elements of the converted data, starting from startVertexIndex, withe the given stride.
*/
virtual bool getBufferData(void* dstBuffer, nvidia::RenderDataFormat::Enum dstBufferFormat, uint32_t dstBufferStride, uint32_t bufferIndex,
uint32_t startVertexIndex, uint32_t elementCount) const = 0;
protected:
/* Do not allow class to be created directly */
VertexBuffer() {}
};
/**
\brief a mesh that has only one material (or render state, in general)
*/
class RenderSubmesh
{
public:
virtual ~RenderSubmesh() {}
/**
Returns the number of vertices associated with the indexed part.
*/
virtual uint32_t getVertexCount(uint32_t partIndex) const = 0;
/**
Returns the submesh's vertex buffer (contains all parts' vertices)
*/
virtual const VertexBuffer& getVertexBuffer() const = 0;
/**
Returns the submesh's index buffer (contains all parts' vertices). Can be changed.
*/
virtual VertexBuffer& getVertexBufferWritable() = 0;
/**
Vertices for a given part are contiguous within the vertex buffer. This function
returns the first vertex index for the indexed part.
*/
virtual uint32_t getFirstVertexIndex(uint32_t partIndex) const = 0;
/**
Returns the number of indices in the part's index buffer.
*/
virtual uint32_t getIndexCount(uint32_t partIndex) const = 0;
/**
Returns the index buffer associated with the indexed part.
*/
virtual const uint32_t* getIndexBuffer(uint32_t partIndex) const = 0;
/**
Returns an array of smoothing groups for the given part, if one exists. Otherwise, returns NULL.
If not NULL, the size of the array is the number of triangles in the part. Since only triangle
lists are currently supported, the size of this array is getIndexCount(partIndex)/3.
*/
virtual const uint32_t* getSmoothingGroups(uint32_t partIndex) const = 0;
protected:
RenderSubmesh() {}
};
PX_POP_PACK
}
} // end namespace nvidia::apex
#endif // RENDER_MESH_H
|