5#ifndef DCPP_I_MESH_MANIPULATOR_HPP_INCLUDED
6#define DCPP_I_MESH_MANIPULATOR_HPP_INCLUDED
8#include <duckcpp/core/engine/IReferenceCounted.hpp>
9#include <duckcpp/core/engine/vector3d.hpp>
10#include <duckcpp/core/engine/aabbox3d.hpp>
11#include <duckcpp/core/engine/matrix4.hpp>
12#include <duckcpp/core/engine/IAnimatedMesh.hpp>
13#include <duckcpp/core/engine/IMeshBuffer.hpp>
14#include <duckcpp/core/engine/SVertexManipulator.hpp>
76 bool angleWeighted =
false)
const=0;
83 bool smooth =
false,
bool angleWeighted =
false)
const=0;
93 bool angleWeighted=
false)
const=0;
103 bool angleWeighted=
false)
const=0;
162 if ( normalsUpdate == 1 )
171 if ( normalizeNormals )
190 if ( normalsUpdate == 1 )
199 if ( normalizeNormals )
376 template <
typename Functor>
379 return apply_(func, buffer, boundingBoxUpdate, func);
388 template <
typename Functor>
389 bool apply(
const Functor& func,
IMesh* mesh,
bool boundingBoxUpdate=
false)
const
398 if (boundingBoxUpdate)
406 if (boundingBoxUpdate)
418 template <
typename Functor>
448 if (boundingBoxUpdate)
456 if (boundingBoxUpdate)
Base class of most objects of the Duckcpp Engine.
Definition IReferenceCounted.hpp:46
4x4 matrix. Mostly used as transformation matrix for 3d calculations.
Definition matrix4.hpp:49
PMatrix4< T > getTransposed() const
Gets transposed matrix.
Definition matrix4.hpp:2036
bool getInverse(PMatrix4< T > &out) const
Gets the inverse matrix of this one.
Definition matrix4.hpp:1404
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
void addInternalBox(const aabbox3d< T > &b)
Adds another bounding box.
Definition aabbox3d.hpp:82
void reset(T x, T y, T z)
Resets the bounding box to a one-point box.
Definition aabbox3d.hpp:50
void addInternalPoint(const vector3d< T > &p)
Adds a point to the bounding box.
Definition aabbox3d.hpp:74
2d vector template class with lots of operators and methods.
Definition vector2d.hpp:22
3d vector template class with lots of operators and methods.
Definition vector3d.hpp:32
Interface for an animated mesh.
Definition IAnimatedMesh.hpp:21
Class for holding a mesh with a single material.
Definition IMeshBuffer.hpp:41
virtual dcpp::uint32_kt getVertexCount() const =0
Get amount of vertices in meshbuffer.
virtual dcpp::video::E_VERTEX_TYPE getVertexType() const =0
Get type of vertex data which is stored in this meshbuffer.
virtual const dcpp::nub::vector3df & getPosition(dcpp::uint32_kt i) const =0
returns position of vertex i
virtual void setBoundingBox(const dcpp::nub::aabbox3df &box)=0
Set axis aligned bounding box.
virtual const dcpp::nub::aabbox3df & getBoundingBox() const =0
Get the axis aligned bounding box of this meshbuffer.
virtual const void * getVertices() const =0
Get access to vertex data. The data is an array of vertices.
An interface for easy manipulation of meshes.
Definition IMeshManipulator.hpp:30
virtual void makePlanarTextureMapping(IMesh *mesh, dcpp::float32_kt resolution=0.001f) const =0
Creates a planar texture mapping on the mesh.
virtual void recalculateNormals(IMesh *mesh, bool smooth=false, bool angleWeighted=false) const =0
Recalculates all normals of the mesh.
virtual IAnimatedMesh * createAnimatedMesh(IMesh *mesh, dcpp::scene::E_ANIMATED_MESH_TYPE type=dcpp::scene::EAMT_UNKNOWN) const =0
Create a new AnimatedMesh and adds the mesh to it.
void setVertexColorAlpha(IMeshBuffer *buffer, dcpp::int32_kt alpha) const
Sets the alpha vertex color value of the whole mesh to a new value.
Definition IMeshManipulator.hpp:50
virtual SMesh * createMeshCopy(IMesh *mesh) const =0
Clones a static IMesh into a modifiable SMesh.
bool apply(const Functor &func, IMesh *mesh, bool boundingBoxUpdate=false) const
Apply a manipulator on the Mesh.
Definition IMeshManipulator.hpp:389
bool apply(const Functor &func, IMeshBuffer *buffer, bool boundingBoxUpdate=false) const
Apply a manipulator on the MeshBuffer.
Definition IMeshManipulator.hpp:377
void transform(IMesh *mesh, const dcpp::nub::matrix4 &m, dcpp::uint32_kt normalsUpdate=0, bool normalizeNormals=false) const
Applies a transformation to a mesh.
Definition IMeshManipulator.hpp:158
virtual void makePlanarTextureMapping(dcpp::scene::IMeshBuffer *meshbuffer, dcpp::float32_kt resolution=0.001f) const =0
Creates a planar texture mapping on the meshbuffer.
virtual IMesh * createMeshWith2TCoords(IMesh *mesh) const =0
Creates a copy of the mesh, which will only consist of S3DVertex2TCoord vertices.
void setVertexColors(IMesh *mesh, dcpp::video::SColor color) const
Sets the colors of all vertices to one color.
Definition IMeshManipulator.hpp:58
virtual dcpp::int32_kt getPolyCount(IMesh *mesh) const =0
Get amount of polygons in mesh.
void setVertexColors(IMeshBuffer *buffer, dcpp::video::SColor color) const
Sets the colors of all vertices to one color.
Definition IMeshManipulator.hpp:66
virtual void heightmapOptimizeMesh(IMesh *const mesh, const dcpp::float32_kt tolerance=dcpp::nub::ROUNDING_ERROR_Float32) const =0
Optimize the mesh with an algorithm tuned for heightmaps.
void scale(IMeshBuffer *buffer, const dcpp::nub::vector3df &factor) const
Scales the actual meshbuffer, not a scene node.
Definition IMeshManipulator.hpp:120
virtual void heightmapOptimizeMesh(IMeshBuffer *const mb, const dcpp::float32_kt tolerance=dcpp::nub::ROUNDING_ERROR_Float32) const =0
Optimize the meshbuffer with an algorithm tuned for heightmaps.
virtual void makePlanarTextureMapping(dcpp::scene::IMesh *mesh, dcpp::float32_kt resolutionS, dcpp::float32_kt resolutionT, dcpp::uint8_kt axis, const dcpp::nub::vector3df &offset) const =0
Creates a planar texture mapping on the buffer.
virtual void recalculateTangents(IMesh *mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const =0
Recalculates tangents, requires a tangent mesh.
bool apply_(const Functor &func, IMeshBuffer *buffer, bool boundingBoxUpdate, const IVertexManipulator &typeTest) const
Apply a manipulator based on the type of the functor.
Definition IMeshManipulator.hpp:419
void scaleTCoords(dcpp::scene::IMeshBuffer *buffer, const dcpp::nub::vector2df &factor, dcpp::uint32_kt level=1) const
Scale the texture coords of a meshbuffer.
Definition IMeshManipulator.hpp:144
virtual IMesh * createForsythOptimizedMesh(const IMesh *mesh) const =0
Vertex cache optimization according to the Forsyth paper.
virtual void makePlanarTextureMapping(dcpp::scene::IMeshBuffer *buffer, dcpp::float32_kt resolutionS, dcpp::float32_kt resolutionT, dcpp::uint8_kt axis, const dcpp::nub::vector3df &offset) const =0
Creates a planar texture mapping on the meshbuffer.
virtual dcpp::int32_kt getPolyCount(IAnimatedMesh *mesh) const =0
Get amount of polygons in mesh.
void transform(IMeshBuffer *buffer, const dcpp::nub::matrix4 &m, dcpp::uint32_kt normalsUpdate=0, bool normalizeNormals=false) const
Applies a transformation to a meshbuffer.
Definition IMeshManipulator.hpp:186
void scale(IMesh *mesh, const dcpp::nub::vector3df &factor) const
Scales the actual mesh, not a scene node.
Definition IMeshManipulator.hpp:110
virtual DCPP_DEPRECATED void transformMesh(IMesh *mesh, const dcpp::nub::matrix4 &m) const
Applies a transformation to a mesh.
Definition IMeshManipulator.hpp:209
void setVertexColorAlpha(IMesh *mesh, dcpp::int32_kt alpha) const
Sets the alpha vertex color value of the whole mesh to a new value.
Definition IMeshManipulator.hpp:42
virtual IMesh * createMeshWithTangents(IMesh *mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false, bool recalculateTangents=true) const =0
Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices.
virtual IMesh * createMeshUniquePrimitives(IMesh *mesh) const =0
Creates a copy of a mesh with all vertices unwelded.
virtual IMesh * createMeshWith1TCoords(IMesh *mesh) const =0
Creates a copy of the mesh, which will only consist of S3DVertex vertices.
virtual void recalculateTangents(IMeshBuffer *buffer, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const =0
Recalculates tangents, requires a tangent mesh buffer.
virtual IMesh * createMeshWelded(IMesh *mesh, dcpp::float32_kt tolerance=dcpp::nub::ROUNDING_ERROR_Float32) const =0
Creates a copy of a mesh with vertices welded.
virtual void flipSurfaces(IMesh *mesh) const =0
Flips the direction of surfaces.
virtual void recalculateNormals(IMeshBuffer *buffer, bool smooth=false, bool angleWeighted=false) const =0
Recalculates all normals of the mesh buffer.
void scaleTCoords(dcpp::scene::IMesh *mesh, const dcpp::nub::vector2df &factor, dcpp::uint32_kt level=1) const
Scale the texture coords of a mesh.
Definition IMeshManipulator.hpp:135
DCPP_DEPRECATED void scaleMesh(IMesh *mesh, const dcpp::nub::vector3df &factor) const
Scales the actual mesh, not a scene node.
Definition IMeshManipulator.hpp:129
Class which holds the geometry of an object.
Definition IMesh.hpp:72
virtual void setBoundingBox(const dcpp::nub::aabbox3df &box)=0
Set user-defined axis aligned bounding box.
virtual dcpp::uint32_kt getMeshBufferCount() const =0
Get the amount of mesh buffers.
virtual IMeshBuffer * getMeshBuffer(dcpp::uint32_kt nr) const =0
Get pointer to a mesh buffer.
Interface for vertex manipulators.
Definition SVertexManipulator.hpp:25
Simple implementation of the IMesh interface.
Definition SMesh.hpp:19
Vertex manipulator to set the alpha value of the vertex color to a fixed value.
Definition SVertexManipulator.hpp:41
Vertex manipulator to set color to a fixed color for all vertices.
Definition SVertexManipulator.hpp:29
Vertex manipulator which transforms the normal of the vertex with the rotate/scale part of the given ...
Definition SVertexManipulator.hpp:282
Vertex manipulator which normalizes the normal of the vertex.
Definition SVertexManipulator.hpp:296
Vertex manipulator which scales the position of the vertex.
Definition SVertexManipulator.hpp:223
Vertex manipulator which scales the TCoords of the vertex.
Definition SVertexManipulator.hpp:308
Vertex with two texture coordinates.
Definition S3DVertex.hpp:116
Vertex with a tangent and binormal vector.
Definition S3DVertex.hpp:199
standard vertex used by the Duckcpp engine.
Definition S3DVertex.hpp:45
Class representing a 32 bit ARGB color.
Definition SColor.hpp:317
E_ANIMATED_MESH_TYPE
Possible types of meshes.
Definition IMesh.hpp:20
@ EAMT_UNKNOWN
Unknown animated mesh type.
Definition IMesh.hpp:22
@ EVT_2TCOORDS
Vertex with two texture coordinates, dcpp::video::S3DVertex2TCoords.
Definition S3DVertex.hpp:25
@ EVT_TANGENTS
Vertex with a tangent and binormal vector, dcpp::video::S3DVertexTangents.
Definition S3DVertex.hpp:31
@ EVT_STANDARD
Standard vertex type used by the Duckcpp engine, dcpp::video::S3DVertex.
Definition S3DVertex.hpp:21
As of Duckcpp 1.6, position2d is a synonym for vector2d.
Definition shared_device.hpp:34
unsigned char uint8_kt
8 bit unsigned variable.
Definition irrTypes.hpp:24
unsigned int uint32_kt
32 bit unsigned variable.
Definition irrTypes.hpp:64
float float32_kt
32 bit floating point variable.
Definition irrTypes.hpp:108
signed int int32_kt
32 bit signed variable.
Definition irrTypes.hpp:72