载入中...
搜索中...
未找到
eve::hd2d::Sprite3D类 参考

Camera-facing 2D sprite billboard rendered inside the 3D scene. 更多...

#include <Hd2d.h>

Public 成员函数

 Sprite3D ()
 Sprite 3 d.
 
 ~Sprite3D ()
 Sprite 3 d.
 
 Sprite3D (const Sprite3D &)=delete
 
Sprite3D & operator= (const Sprite3D &)=delete
 
void setTexture (graphics::Texture *texture)
 Albedo texture (a sprite frame / sheet / animation image).
 
graphics::Texture * getTexture () const
 Returns the texture.
 
void setFrame (float u0, float v0, float u1, float v1)
 Direct atlas sub-rect frame selection (0..1 UV).
 
void getFrame (float &u0, float &v0, float &u1, float &v1) const
 Returns the frame.
 
void setFlipX (bool flip)
 Flip the sampled frame horizontally / vertically.
 
void setFlipY (bool flip)
 Sets the flip y.
 
void setFrameGrid (int columns, int rows)
 Configure a sprite-sheet grid (frame 0 = top-left); stops the previous clip.
 
int getFrameGridColumns () const
 Returns the frame grid columns.
 
int getFrameGridRows () const
 Returns the frame grid rows.
 
void setFrameIndex (int index)
 Jump to a grid frame index, clamped within the grid.
 
int getFrameIndex () const
 Returns the frame index.
 
int getFrameCount () const
 Total grid frames.
 
void play (int start, int end, float fps)
 Run a frame animation.
 
void stop ()
 Stops .
 
bool isPlaying () const
 True when playing.
 
void update (float dt)
 Advance the animation clock and re-orient the billboard toward the attached camera. Call once per frame.
 
void setCamera (graphics::Camera3D *camera)
 Borrow the camera used for screen alignment, including pitch/roll.
 
void setPivot (float x, float y)
 Set the image-space pivot; (0,0) is visible top-left, (1,1) bottom-right.
 
void setPosition (float x, float y, float z)
 World position of the pivot (center by default).
 
float getPositionX () const
 Returns the position x.
 
float getPositionY () const
 Returns the position y.
 
float getPositionZ () const
 Returns the position z.
 
void setSize (float width, float height)
 Billboard size in world units.
 
float getWidth () const
 Returns the width.
 
float getHeight () const
 Returns the height.
 
void setTint (float r, float g, float b, float a=1.f)
 Color multiplier (alpha participates in cutout discards).
 
void setVisible (bool visible)
 Sets the visible.
 
bool getVisible () const
 Returns the visible.
 
void setAlphaCutoff (float cutoff)
 Alpha cutout threshold for the masked material (DopFix-style depth write).
 
float getAlphaCutoff () const
 Returns the alpha cutoff.
 
void setDepthWrite (bool enabled)
 Whether opaque/cutout texels write depth (required for DOF focus). Default true — matches HD2DURP DopFix / TransparentCutout materials.
 
bool getDepthWrite () const
 Returns the depth write.
 
void setDoubleSided (bool enabled)
 Render both faces of the billboard quad (default true).
 
bool getDoubleSided () const
 Returns the double sided.
 
void setBillboardMode (const std::string &mode)
 Billboard orientation mode.
 
std::string getBillboardMode () const
 Returns the billboard mode.
 
graphics::Mesh * quadMesh () const
 Quad mesh.
 

友元

class Hd2D
 

详细描述

Camera-facing 2D sprite billboard rendered inside the 3D scene.

A unit quad uses an ECS Renderable3D with a Graphics-owned masked material in the forward, G-buffer and shadow paths, so transparent pixels discard and the sprite casts a silhouette shadow like other billboard/card geometry. The billboard is oriented toward the attached camera each frame. Graphics owns its mesh, material and texture; they must outlive the sprite. Calls belong to the render thread and do not invoke user callbacks. 2D sprite-sheet animation: setFrameGrid(cols, rows) + setFrameIndex / play advance a frame index; update(dt) steps the clock. This lets existing 2D character animations run in 3D.

在文件 Hd2d.h 第 119 行定义.

构造及析构函数说明

◆ Sprite3D() [1/2]

eve::hd2d::Sprite3D::Sprite3D ( )
default

Sprite 3 d.

◆ ~Sprite3D()

eve::hd2d::Sprite3D::~Sprite3D ( )

Sprite 3 d.

在文件 Sprite3D.cpp 第 40 行定义.

引用了 eve::graphics::Renderable3D::setVisible().

◆ Sprite3D() [2/2]

eve::hd2d::Sprite3D::Sprite3D ( const Sprite3D &  )
delete

成员函数说明

◆ getAlphaCutoff()

float eve::hd2d::Sprite3D::getAlphaCutoff ( ) const

Returns the alpha cutoff.

在文件 Sprite3D.cpp 第 281 行定义.

◆ getBillboardMode()

std::string eve::hd2d::Sprite3D::getBillboardMode ( ) const

Returns the billboard mode.

在文件 Sprite3D.cpp 第 305 行定义.

◆ getDepthWrite()

bool eve::hd2d::Sprite3D::getDepthWrite ( ) const

Returns the depth write.

在文件 Sprite3D.cpp 第 287 行定义.

◆ getDoubleSided()

bool eve::hd2d::Sprite3D::getDoubleSided ( ) const

Returns the double sided.

在文件 Sprite3D.cpp 第 293 行定义.

◆ getFrame()

void eve::hd2d::Sprite3D::getFrame ( float &  u0,
float &  v0,
float &  u1,
float &  v1 
) const

Returns the frame.

在文件 Sprite3D.cpp 第 122 行定义.

◆ getFrameCount()

int eve::hd2d::Sprite3D::getFrameCount ( ) const

Total grid frames.

在文件 Sprite3D.cpp 第 148 行定义.

◆ getFrameGridColumns()

int eve::hd2d::Sprite3D::getFrameGridColumns ( ) const

Returns the frame grid columns.

在文件 Sprite3D.cpp 第 146 行定义.

◆ getFrameGridRows()

int eve::hd2d::Sprite3D::getFrameGridRows ( ) const

Returns the frame grid rows.

在文件 Sprite3D.cpp 第 147 行定义.

◆ getFrameIndex()

int eve::hd2d::Sprite3D::getFrameIndex ( ) const

Returns the frame index.

在文件 Sprite3D.cpp 第 160 行定义.

◆ getHeight()

float eve::hd2d::Sprite3D::getHeight ( ) const

Returns the height.

在文件 Sprite3D.cpp 第 258 行定义.

◆ getPositionX()

float eve::hd2d::Sprite3D::getPositionX ( ) const

Returns the position x.

在文件 Sprite3D.cpp 第 246 行定义.

◆ getPositionY()

float eve::hd2d::Sprite3D::getPositionY ( ) const

Returns the position y.

在文件 Sprite3D.cpp 第 247 行定义.

◆ getPositionZ()

float eve::hd2d::Sprite3D::getPositionZ ( ) const

Returns the position z.

在文件 Sprite3D.cpp 第 248 行定义.

◆ getTexture()

graphics::Texture * eve::hd2d::Sprite3D::getTexture ( ) const

Returns the texture.

在文件 Sprite3D.cpp 第 113 行定义.

◆ getVisible()

bool eve::hd2d::Sprite3D::getVisible ( ) const

Returns the visible.

在文件 Sprite3D.cpp 第 274 行定义.

◆ getWidth()

float eve::hd2d::Sprite3D::getWidth ( ) const

Returns the width.

在文件 Sprite3D.cpp 第 257 行定义.

◆ isPlaying()

bool eve::hd2d::Sprite3D::isPlaying ( ) const

True when playing.

在文件 Sprite3D.cpp 第 170 行定义.

◆ operator=()

Sprite3D & eve::hd2d::Sprite3D::operator= ( const Sprite3D &  )
delete

◆ play()

void eve::hd2d::Sprite3D::play ( int  start,
int  end,
float  fps 
)

Run a frame animation.

参数
startFirst grid frame.
endInclusive last grid frame.
fpsFrames per second (must be > 0).

在文件 Sprite3D.cpp 第 162 行定义.

引用了 end, setFrameIndex() , 以及 start.

◆ quadMesh()

graphics::Mesh * eve::hd2d::Sprite3D::quadMesh ( ) const
inline

Quad mesh.

在文件 Hd2d.h 第 247 行定义.

◆ setAlphaCutoff()

void eve::hd2d::Sprite3D::setAlphaCutoff ( float  cutoff)

Alpha cutout threshold for the masked material (DopFix-style depth write).

参数
cutoffFinite value clamped to [0,1]; default 0.5.

在文件 Sprite3D.cpp 第 276 行定义.

◆ setBillboardMode()

void eve::hd2d::Sprite3D::setBillboardMode ( const std::string &  mode)

Billboard orientation mode.

参数
mode"screen" (default, full camera basis) or "yaw" (Y-up cylindrical).

在文件 Sprite3D.cpp 第 295 行定义.

◆ setCamera()

void eve::hd2d::Sprite3D::setCamera ( graphics::Camera3D *  camera)

Borrow the camera used for screen alignment, including pitch/roll.

Render-thread only, no callbacks. The camera must outlive this binding; detach with null before destroying it. Null or a degenerate camera basis preserves the last valid orientation. All sprites share the camera image-plane basis rather than pointing individually at its eye.

在文件 Sprite3D.cpp 第 189 行定义.

引用了 camera.

◆ setDepthWrite()

void eve::hd2d::Sprite3D::setDepthWrite ( bool  enabled)

Whether opaque/cutout texels write depth (required for DOF focus). Default true — matches HD2DURP DopFix / TransparentCutout materials.

在文件 Sprite3D.cpp 第 283 行定义.

引用了 enabled.

◆ setDoubleSided()

void eve::hd2d::Sprite3D::setDoubleSided ( bool  enabled)

Render both faces of the billboard quad (default true).

在文件 Sprite3D.cpp 第 289 行定义.

引用了 enabled.

◆ setFlipX()

void eve::hd2d::Sprite3D::setFlipX ( bool  flip)

Flip the sampled frame horizontally / vertically.

在文件 Sprite3D.cpp 第 128 行定义.

◆ setFlipY()

void eve::hd2d::Sprite3D::setFlipY ( bool  flip)

Sets the flip y.

在文件 Sprite3D.cpp 第 132 行定义.

◆ setFrame()

void eve::hd2d::Sprite3D::setFrame ( float  u0,
float  v0,
float  u1,
float  v1 
)

Direct atlas sub-rect frame selection (0..1 UV).

在文件 Sprite3D.cpp 第 115 行定义.

被这些函数引用 setFrameIndex().

◆ setFrameGrid()

void eve::hd2d::Sprite3D::setFrameGrid ( int  columns,
int  rows 
)

Configure a sprite-sheet grid (frame 0 = top-left); stops the previous clip.

在文件 Sprite3D.cpp 第 137 行定义.

引用了 columns, rows, setFrameIndex() , 以及 stop().

◆ setFrameIndex()

void eve::hd2d::Sprite3D::setFrameIndex ( int  index)

Jump to a grid frame index, clamped within the grid.

在文件 Sprite3D.cpp 第 150 行定义.

引用了 cx, cy, index , 以及 setFrame().

被这些函数引用 play(), setFrameGrid() , 以及 update().

◆ setPivot()

void eve::hd2d::Sprite3D::setPivot ( float  x,
float  y 
)

Set the image-space pivot; (0,0) is visible top-left, (1,1) bottom-right.

参数
xFinite horizontal fraction; default 0.5.
yFinite vertical fraction; default 0.5. Use 1 for bottom center.
前置条件
Both values are finite. Values outside [0,1] allow an external pivot.

Render-thread only; no callbacks. Position remains fixed while the geometry rotates/scales about this pivot. UV flips do not move the pivot.

在文件 Sprite3D.cpp 第 230 行定义.

引用了 EV_PARAM_CHECK, x , 以及 y.

◆ setPosition()

void eve::hd2d::Sprite3D::setPosition ( float  x,
float  y,
float  z 
)

World position of the pivot (center by default).

在文件 Sprite3D.cpp 第 237 行定义.

引用了 eve::graphics::Renderable3D::setPosition(), x, y , 以及 z.

◆ setSize()

void eve::hd2d::Sprite3D::setSize ( float  width,
float  height 
)

Billboard size in world units.

在文件 Sprite3D.cpp 第 250 行定义.

引用了 height, eve::graphics::Renderable3D::setScale() , 以及 width.

◆ setTexture()

void eve::hd2d::Sprite3D::setTexture ( graphics::Texture *  texture)

Albedo texture (a sprite frame / sheet / animation image).

在文件 Sprite3D.cpp 第 106 行定义.

引用了 eve::graphics::Renderable3D::setTexture().

◆ setTint()

void eve::hd2d::Sprite3D::setTint ( float  r,
float  g,
float  b,
float  a = 1.f 
)

Color multiplier (alpha participates in cutout discards).

在文件 Sprite3D.cpp 第 260 行定义.

引用了 a, b, g, r , 以及 eve::graphics::Renderable3D::setTint().

◆ setVisible()

void eve::hd2d::Sprite3D::setVisible ( bool  visible)

Sets the visible.

在文件 Sprite3D.cpp 第 270 行定义.

引用了 eve::graphics::Renderable3D::setVisible() , 以及 visible.

◆ stop()

void eve::hd2d::Sprite3D::stop ( )

Stops .

在文件 Sprite3D.cpp 第 169 行定义.

被这些函数引用 setFrameGrid().

◆ update()

void eve::hd2d::Sprite3D::update ( float  dt)

Advance the animation clock and re-orient the billboard toward the attached camera. Call once per frame.

参数
dtSeconds elapsed since the last update. Non-positive and non-finite values do not advance animation; camera orientation is still refreshed.

在文件 Sprite3D.cpp 第 172 行定义.

引用了 offset, setFrameIndex() , 以及 steps.

友元及相关函数文档

◆ Hd2D

friend class Hd2D
friend

在文件 Hd2d.h 第 250 行定义.


该类的文档由以下文件生成: