Nirtcpp 2.1.0
Nirtcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
IMeshBuffer.hpp
1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in nirtcpp/nirtcpp.hpp
4
5#ifndef NIRT_I_MESH_BUFFER_HPP_INCLUDED
6#define NIRT_I_MESH_BUFFER_HPP_INCLUDED
7
8#include <nirtcpp/core/engine/IReferenceCounted.hpp>
9#include <nirtcpp/core/engine/SMaterial.hpp>
10#include <nirtcpp/core/engine/aabbox3d.hpp>
11#include <nirtcpp/core/engine/S3DVertex.hpp>
12#include <nirtcpp/core/engine/SVertexIndex.hpp>
13#include <nirtcpp/core/engine/EHardwareBufferFlags.hpp>
14#include <nirtcpp/core/engine/EPrimitiveTypes.hpp>
15#include <nirtcpp/core/engine/EMeshBufferTypes.hpp>
16
17namespace nirt
18{
19namespace scene
20{
22
40 class IMeshBuffer : public virtual IReferenceCounted
41 {
42 public:
43
45
47
49
50 virtual const video::SMaterial& getMaterial() const = 0;
51
53
55
57
59 virtual const void* getVertices() const = 0;
60
62
64 virtual void* getVertices() = 0;
65
67
68 virtual u32 getVertexCount() const = 0;
69
71
72 virtual video::E_INDEX_TYPE getIndexType() const =0;
73
75
79 virtual const u16* getIndices() const = 0;
80
82
86 virtual u16* getIndices() = 0;
87
89
90 virtual u32 getIndexCount() const = 0;
91
93
94 virtual const core::aabbox3df& getBoundingBox() const = 0;
95
97
99 virtual void setBoundingBox(const core::aabbox3df& box) = 0;
100
102 virtual void recalculateBoundingBox() = 0;
103
105 virtual const core::vector3df& getPosition(u32 i) const = 0;
106
109
111 virtual const core::vector3df& getNormal(u32 i) const = 0;
112
115
117 virtual const core::vector2df& getTCoords(u32 i) const = 0;
118
121
123 virtual video::SColor& getColor(u32 i) = 0;
124
126 virtual const video::SColor& getColor(u32 i) const = 0;
127
129
135 virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) = 0;
136
139
141 virtual void append(const IMeshBuffer* const other) = 0;
142
145
148
151
154
156
157 virtual u32 getChangedID_Vertex() const = 0;
158
160
161 virtual u32 getChangedID_Index() const = 0;
162
164
168 virtual void setPrimitiveType(E_PRIMITIVE_TYPE type) = 0;
169
172
174 virtual u32 getPrimitiveCount() const
175 {
176 const u32 indexCount = getIndexCount();
177 switch (getPrimitiveType())
178 {
179 case scene::EPT_POINTS: return indexCount;
180 case scene::EPT_LINE_STRIP: return indexCount-1;
181 case scene::EPT_LINE_LOOP: return indexCount;
182 case scene::EPT_LINES: return indexCount/2;
183 case scene::EPT_TRIANGLE_STRIP: return (indexCount-2);
184 case scene::EPT_TRIANGLE_FAN: return (indexCount-2);
185 case scene::EPT_TRIANGLES: return indexCount/3;
186 case scene::EPT_QUAD_STRIP: return (indexCount-2)/2;
187 case scene::EPT_QUADS: return indexCount/4;
188 case scene::EPT_POLYGON: return indexCount; // (not really primitives, that would be 1, works like line_strip)
189 case scene::EPT_POINT_SPRITES: return indexCount;
190 }
191 return 0;
192 }
193
195
197 {
198 return EMBT_UNKNOWN;
199 }
200
203 {
204 ECF_VERTICES = 1,
205 ECF_INDICES = 2
206 };
207
209 //\param cloneFlags A combination of ECloneFlags
210 virtual IMeshBuffer* createClone(int cloneFlags=ECF_VERTICES|ECF_INDICES) const = 0;
211
212 };
213
214} // end namespace scene
215} // end namespace nirt
216
217#endif
Base class of most objects of the Nirtcpp Engine.
Definition IReferenceCounted.hpp:46
Struct for holding a mesh with a single material.
Definition IMeshBuffer.hpp:41
virtual video::SMaterial & getMaterial()=0
Get the material of this meshbuffer.
virtual const video::SMaterial & getMaterial() const =0
Get the material of this meshbuffer.
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const =0
get the current hardware mapping hint
virtual const core::vector3df & getNormal(u32 i) const =0
returns normal of vertex i
virtual const video::SColor & getColor(u32 i) const =0
returns color of vertex i
virtual u32 getChangedID_Index() const =0
Get the currently used ID for identification of changes.
virtual u32 getVertexCount() const =0
Get amount of vertices in meshbuffer.
virtual void recalculateBoundingBox()=0
Recalculates the bounding box. Should be called if the mesh changed.
virtual void setBoundingBox(const core::aabbox3df &box)=0
Set axis aligned bounding box.
virtual core::vector2df & getTCoords(u32 i)=0
returns texture coord of vertex i
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const =0
get the current hardware mapping hint
virtual u32 getPrimitiveCount() const
Calculate how many geometric primitives are used by this meshbuffer.
Definition IMeshBuffer.hpp:174
virtual const core::vector3df & getPosition(u32 i) const =0
returns position of vertex i
virtual const core::vector2df & getTCoords(u32 i) const =0
returns texture coord of vertex i
virtual u32 getChangedID_Vertex() const =0
Get the currently used ID for identification of changes.
virtual const core::aabbox3df & getBoundingBox() const =0
Get the axis aligned bounding box of this meshbuffer.
virtual video::E_VERTEX_TYPE getVertexType() const =0
Get type of vertex data which is stored in this meshbuffer.
virtual core::vector3df & getNormal(u32 i)=0
returns normal of vertex i
virtual IMeshBuffer * createClone(int cloneFlags=ECF_VERTICES|ECF_INDICES) const =0
Create a new object with a copy of the meshbuffer.
virtual u32 getIndexCount() const =0
Get amount of indices in this meshbuffer.
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)=0
set the hardware mapping hint, for driver
virtual const u16 * getIndices() const =0
Get access to indices.
virtual void * getVertices()=0
Get access to vertex data. The data is an array of vertices.
ECloneFlags
Bitflags with options for cloning.
Definition IMeshBuffer.hpp:203
@ ECF_INDICES
clone the vertices (or copy pointer for SSharedMeshBuffer)
Definition IMeshBuffer.hpp:205
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)=0
flags the meshbuffer as changed, reloads hardware buffers
virtual u16 * getIndices()=0
Get access to indices.
virtual void append(const IMeshBuffer *const other)=0
virtual void setPrimitiveType(E_PRIMITIVE_TYPE type)=0
Describe what kind of primitive geometry is used by the meshbuffer.
virtual video::SColor & getColor(u32 i)=0
returns color of vertex i
virtual core::vector3df & getPosition(u32 i)=0
returns position of vertex i
virtual video::E_INDEX_TYPE getIndexType() const =0
Get type of index data which is stored in this meshbuffer.
virtual void append(const void *const vertices, u32 numVertices, const u16 *const indices, u32 numIndices)=0
Append the vertices and indices to the current buffer.
virtual E_PRIMITIVE_TYPE getPrimitiveType() const =0
Get the kind of primitive geometry which is used by the meshbuffer.
virtual const void * getVertices() const =0
Get access to vertex data. The data is an array of vertices.
virtual EMESH_BUFFER_TYPE getType() const
Returns type of the class implementing the IMeshBuffer.
Definition IMeshBuffer.hpp:196
Class representing a 32 bit ARGB color.
Definition SColor.hpp:317
Struct for holding parameters for a material renderer.
Definition SMaterial.hpp:304
E_BUFFER_TYPE
Definition EHardwareBufferFlags.hpp:29
@ EBT_VERTEX_AND_INDEX
Change both vertex and index mapping to the same value.
Definition EHardwareBufferFlags.hpp:37
E_PRIMITIVE_TYPE
Enumeration for all primitive types there are.
Definition EPrimitiveTypes.hpp:15
@ EPT_TRIANGLES
Explicitly set all vertices for each triangle.
Definition EPrimitiveTypes.hpp:37
@ EPT_LINE_STRIP
All vertices form a single connected line.
Definition EPrimitiveTypes.hpp:20
@ EPT_LINES
Every two vertices are connected creating n/2 lines.
Definition EPrimitiveTypes.hpp:26
@ EPT_LINE_LOOP
Just as LINE_STRIP, but the last and the first vertex is also connected.
Definition EPrimitiveTypes.hpp:23
@ EPT_TRIANGLE_FAN
Definition EPrimitiveTypes.hpp:34
@ EPT_POINTS
All vertices are non-connected points.
Definition EPrimitiveTypes.hpp:17
@ EPT_POINT_SPRITES
The single vertices are expanded to quad billboards on the GPU.
Definition EPrimitiveTypes.hpp:54
@ EPT_QUADS
Definition EPrimitiveTypes.hpp:46
@ EPT_POLYGON
Definition EPrimitiveTypes.hpp:51
@ EPT_TRIANGLE_STRIP
Definition EPrimitiveTypes.hpp:30
@ EPT_QUAD_STRIP
Definition EPrimitiveTypes.hpp:41
E_HARDWARE_MAPPING
Definition EHardwareBufferFlags.hpp:14
EMESH_BUFFER_TYPE
An enumeration for all types of built-in mesh buffers.
Definition EMeshBufferTypes.hpp:18
@ EMBT_UNKNOWN
Unknown class type.
Definition EMeshBufferTypes.hpp:38
E_VERTEX_TYPE
Enumeration for all vertex types there are.
Definition S3DVertex.hpp:19
As of Nirtcpp 1.6, position2d is a synonym for vector2d.
Definition vector3d.hpp:11
unsigned short u16
16 bit unsigned variable.
Definition irrTypes.hpp:46
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.hpp:64

Nirtcpp    @cppfx.xyz

Utxcpp    utx::print