5#ifndef NIRT_C_DYNAMIC_MESHBUFFER_HPP_INCLUDED
6#define NIRT_C_DYNAMIC_MESHBUFFER_HPP_INCLUDED
8#include <nirtcpp/core/engine/IDynamicMeshBuffer.hpp>
10#include <nirtcpp/core/engine/CVertexBuffer.hpp>
11#include <nirtcpp/core/engine/CIndexBuffer.hpp>
43 virtual IIndexBuffer& getIndexBuffer()
const override
48 virtual void setVertexBuffer(IVertexBuffer *newVertexBuffer)
override
51 newVertexBuffer->
grab();
55 VertexBuffer=newVertexBuffer;
58 virtual void setIndexBuffer(IIndexBuffer *newIndexBuffer)
override
61 newIndexBuffer->
grab();
65 IndexBuffer=newIndexBuffer;
95 if (!getVertexBuffer().size())
96 BoundingBox.
reset(0,0,0);
99 BoundingBox.
reset(getVertexBuffer()[0].Pos);
100 for (
u32 i=1; i<getVertexBuffer().
size(); ++i)
111 virtual void append(
const void*
const vertices,
u32 numVertices,
const u16*
const indices,
u32 numIndices)
override
148 if (cloneFlags & ECF_VERTICES)
150 const u32 numVertices = VertexBuffer->
size();
151 clone->VertexBuffer->reallocate(numVertices);
152 for (
u32 i=0; i<numVertices; ++i )
154 clone->VertexBuffer->
push_back((*VertexBuffer)[i]);
156 clone->BoundingBox = BoundingBox;
161 const u32 numIndices = IndexBuffer->
size();
162 clone->IndexBuffer->reallocate(numIndices);
163 for (
u32 i=0; i<numIndices; ++i )
165 clone->IndexBuffer->
push_back((*IndexBuffer)[i]);
171 clone->Material = Material;
bool drop() const
Drops the object. Decrements the reference counter by one.
Definition IReferenceCounted.hpp:126
void grab() const
Grabs the object. Increments the reference counter by one.
Definition IReferenceCounted.hpp:96
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
void addInternalPoint(const vector3d< T > &p)
Adds a point to the bounding box.
Definition aabbox3d.hpp:74
void reset(T x, T y, T z)
Resets the bounding box to a one-point box.
Definition aabbox3d.hpp:50
Implementation of the IMeshBuffer interface for which can work with 16 and 32 bit indices as well as ...
Definition CDynamicMeshBuffer.hpp:19
virtual void setPrimitiveType(E_PRIMITIVE_TYPE type) override
Describe what kind of primitive geometry is used by the meshbuffer.
Definition CDynamicMeshBuffer.hpp:126
virtual void append(const IMeshBuffer *const other) override
Append the meshbuffer to the current buffer.
Definition CDynamicMeshBuffer.hpp:119
virtual video::SMaterial & getMaterial() override
Get Material of this buffer.
Definition CDynamicMeshBuffer.hpp:75
virtual E_PRIMITIVE_TYPE getPrimitiveType() const override
Get the kind of primitive geometry which is used by the meshbuffer.
Definition CDynamicMeshBuffer.hpp:132
virtual EMESH_BUFFER_TYPE getType() const override
Returns type of the class implementing the IMeshBuffer.
Definition CDynamicMeshBuffer.hpp:138
virtual const video::SMaterial & getMaterial() const override
Get Material of this buffer.
Definition CDynamicMeshBuffer.hpp:69
CDynamicMeshBuffer(video::E_VERTEX_TYPE vertexType, video::E_INDEX_TYPE indexType)
constructor
Definition CDynamicMeshBuffer.hpp:22
virtual void append(const void *const vertices, u32 numVertices, const u16 *const indices, u32 numIndices) override
Append the vertices and indices to the current buffer.
Definition CDynamicMeshBuffer.hpp:111
virtual void recalculateBoundingBox() override
Recalculate bounding box.
Definition CDynamicMeshBuffer.hpp:93
virtual const core::aabbox3d< f32 > & getBoundingBox() const override
Get bounding box.
Definition CDynamicMeshBuffer.hpp:81
virtual void setBoundingBox(const core::aabbox3df &box) override
Set bounding box.
Definition CDynamicMeshBuffer.hpp:87
E_PRIMITIVE_TYPE PrimitiveType
Primitive type used for rendering (triangles, lines, ...)
Definition CDynamicMeshBuffer.hpp:180
virtual IMeshBuffer * createClone(int cloneFlags) const override
Create copy of the meshbuffer.
Definition CDynamicMeshBuffer.hpp:144
virtual ~CDynamicMeshBuffer()
destructor
Definition CDynamicMeshBuffer.hpp:30
Definition CIndexBuffer.hpp:16
Definition CVertexBuffer.hpp:17
Definition IDynamicMeshBuffer.hpp:19
Definition IIndexBuffer.hpp:20
virtual E_HARDWARE_MAPPING getHardwareMappingHint() const =0
get the current hardware mapping hint
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING NewMappingHint)=0
set the hardware mapping hint, for driver
virtual u32 size() const =0
Number of elements.
virtual void push_back(u32 value)=0
Add value to end. Note that for 16 bit index types values shouldn't be larger than u16.
Class for holding a mesh with a single material.
Definition IMeshBuffer.hpp:41
@ ECF_INDICES
clone the vertices (or copy pointer for SSharedMeshBuffer)
Definition IMeshBuffer.hpp:205
Definition IVertexBuffer.hpp:19
virtual void push_back(const video::S3DVertex &element)=0
Add vertex to end.
virtual E_HARDWARE_MAPPING getHardwareMappingHint() const =0
get the current hardware mapping hint
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING NewMappingHint)=0
set the hardware mapping hint, for driver
virtual u32 size() const =0
Number of elements.
Class for holding parameters for a material renderer.
Definition SMaterial.hpp:304
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
EMESH_BUFFER_TYPE
An enumeration for all types of built-in mesh buffers.
Definition EMeshBufferTypes.hpp:18
@ EMBT_DYNAMIC
CDynamicMeshBuffer (16 or 32 bit buffers)
Definition EMeshBufferTypes.hpp:29
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