Axmol Engine 2.4.0-258ceca
Loading...
Searching...
No Matches
Mesh Class Reference

Mesh: contains ref to index buffer, GLProgramState, texture, skin, blend function, aabb and so on. More...

#include <Mesh.h>

Inherits Object.

Public Member Functions

backend::BuffergetVertexBuffer () const
 get vertex buffer
 
bool hasVertexAttrib (shaderinfos::VertexKey attrib) const
 has vertex attribute?
 
ssize_t getMeshVertexAttribCount () const
 get mesh vertex attribute count
 
const MeshVertexAttribgetMeshVertexAttribute (int idx)
 get MeshVertexAttribute by index
 
int getVertexSizeInBytes () const
 get per vertex size in bytes
 
void setTexture (std::string_view texPath)
 set texture (diffuse), which is responsible for the main appearance.
 
void setTexture (Texture2D *tex)
 set texture (diffuse), which is responsible for the main appearance.
 
void setTexture (Texture2D *tex, NTextureData::Usage usage, bool cacheFileName=true)
 set texture
 
void setTexture (std::string_view texPath, NTextureData::Usage usage)
 set texture
 
Texture2DgetTexture () const
 Get texture (diffuse), which is responsible for the main appearance.
 
Texture2DgetTexture (NTextureData::Usage usage)
 Get texture.
 
void setVisible (bool visible)
 visible getter and setter
 
MeshSkingetSkin () const
 skin getter
 
MeshIndexDatagetMeshIndexData () const
 mesh index data getter
 
backend::ProgramState * getProgramState () const
 get ProgramState
 
std::string_view getName () const
 name getter
 
CustomCommand::PrimitiveType getPrimitiveType () const
 get primitive type
 
ssize_t getIndexCount () const
 get index count
 
CustomCommand::IndexFormat getIndexFormat () const
 get index format
 
void setIndexFormat (CustomCommand::IndexFormat indexFormat)
 set index format
 
backend::BuffergetIndexBuffer () const
 get index buffer
 
const AABBgetAABB () const
 get AABB
 
void setProgramState (backend::ProgramState *programState)
 Sets a new ProgramState for the Mesh A new Material will be created for it.
 
void setMaterial (Material *material)
 Sets a new Material to the Mesh.
 
MaterialgetMaterial () const
 Returns the Material being used by the Mesh.
 
void setSkin (MeshSkin *skin)
 skin setter
 
void setMeshIndexData (MeshIndexData *indexdata)
 Mesh index data setter.
 
void setName (std::string_view name)
 name setter
 
void calculateAABB ()
 calculate the AABB of the mesh
 
void enableInstancing (bool instance, int count=0)
 Enables instancing for this Mesh Renderer, keep in mind that a special vertex shader has to be used, make sure that your shader has a mat4 attribute set on the location of total vertex attributes +1.
 
void setDynamicInstancing (bool dynamic)
 Set this to true and instancing objects within this mesh renderer will be recalculated each frame, use it when you plan to move objects, Otherwise, transforms will be built once for better performance.
 
void addInstanceChild (Node *child)
 Adds a child to use it's transformations for instancing.
 
void shrinkToFitInstances ()
 shrinks the instance transform buffer after many steps of expansion to increase performance.
 
void rebuildInstances ()
 rebuilds the instance transform buffer next frame.
 
- Public Member Functions inherited from Object
void retain ()
 Retains the ownership.
 
void release ()
 Releases the ownership immediately.
 
Objectautorelease ()
 Releases the ownership sometime soon automatically.
 
unsigned int getReferenceCount () const
 Returns the Object's current reference count.
 
virtual ~Object ()
 Destructor.
 

Static Public Member Functions

static Meshcreate (const std::vector< float > &positions, const std::vector< float > &normals, const std::vector< float > &texs, const IndexArray &indices)
 create mesh from positions, normals, and so on, single SubMesh
 
static Meshcreate (const std::vector< float > &vertices, int perVertexSizeInFloat, const IndexArray &indices, const std::vector< MeshVertexAttrib > &attribs)
 @lua NA
 
static Meshcreate (std::string_view name, MeshIndexData *indexData, MeshSkin *skin=nullptr)
 create mesh @lua NA
 

Additional Inherited Members

- Public Attributes inherited from Object
unsigned int _ID
 object id, ScriptSupport need public _ID
 
int _luaID
 Lua reference id.
 

Detailed Description

Mesh: contains ref to index buffer, GLProgramState, texture, skin, blend function, aabb and so on.

Member Function Documentation

◆ getVertexBuffer()

backend::Buffer * getVertexBuffer ( ) const

get vertex buffer

@lua NA

◆ hasVertexAttrib()

bool hasVertexAttrib ( shaderinfos::VertexKey attrib) const

has vertex attribute?

@lua NA

◆ setTexture() [1/4]

void setTexture ( std::string_view texPath)

set texture (diffuse), which is responsible for the main appearance.

It is also means main texture, you can also call setTexture(texPath, NTextureData::Usage::Diffuse)

Parameters
texPathtexture path

◆ setTexture() [2/4]

void setTexture ( Texture2D * tex)

set texture (diffuse), which is responsible for the main appearance.

It is also means main texture, you can also call setTexture(texPath, NTextureData::Usage::Diffuse)

Parameters
textexture to be set

◆ setTexture() [3/4]

void setTexture ( Texture2D * tex,
NTextureData::Usage usage,
bool cacheFileName = true )

set texture

Parameters
textexture to be set
usageUsage of this texture
whetherrefresh the cache file name

◆ setTexture() [4/4]

void setTexture ( std::string_view texPath,
NTextureData::Usage usage )

set texture

Parameters
texPathtexture path
usageUsage of this texture

◆ getTexture() [1/2]

Texture2D * getTexture ( ) const

Get texture (diffuse), which is responsible for the main appearance.

It is also means main texture, you can also call getTexture(NTextureData::Usage::Diffuse)

Returns
Texture used, return the texture of first mesh if multiple meshes exist

◆ getTexture() [2/2]

Texture2D * getTexture ( NTextureData::Usage usage)

Get texture.

Parameters
usageUsage of returned texture
Returns
The texture of this usage, return the texture of first mesh if multiple meshes exist

◆ getSkin()

MeshSkin * getSkin ( ) const
inline

skin getter

@lua NA

◆ getMeshIndexData()

MeshIndexData * getMeshIndexData ( ) const
inline

mesh index data getter

@lua NA

◆ getProgramState()

backend::ProgramState * getProgramState ( ) const

get ProgramState

@lua NA

◆ getPrimitiveType()

CustomCommand::PrimitiveType getPrimitiveType ( ) const

get primitive type

@lua NA

◆ getIndexCount()

ssize_t getIndexCount ( ) const

get index count

@lua NA

◆ getIndexFormat()

CustomCommand::IndexFormat getIndexFormat ( ) const

get index format

@lua NA

◆ setIndexFormat()

void setIndexFormat ( CustomCommand::IndexFormat indexFormat)

set index format

@lua NA

◆ getIndexBuffer()

backend::Buffer * getIndexBuffer ( ) const

get index buffer

@lua NA

◆ calculateAABB()

void calculateAABB ( )

calculate the AABB of the mesh

Note
the AABB is in the local space, not the world space

◆ setDynamicInstancing()

void setDynamicInstancing ( bool dynamic)

Set this to true and instancing objects within this mesh renderer will be recalculated each frame, use it when you plan to move objects, Otherwise, transforms will be built once for better performance.

to update transforms on demand use rebuildInstances()

◆ addInstanceChild()

void addInstanceChild ( Node * child)

Adds a child to use it's transformations for instancing.

The child is in the space of this Node, keep in mind that the node isn't added to the scene graph, it is instead retained and it's parent is set to this node, updates and actions will not run. the reason for this is performance.

Parameters
child,Thechild to use for instancing.

The documentation for this class was generated from the following file: