CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::MeshGenerator::SvgWriter Class Reference

A simple svg writer class for generating preview and debug images. More...

#include <CeresEngine/Mesh/Generator/SvgWriter.hpp>

Classes

class  BaseElem
 
class  LineElem
 
class  TriangleElem
 
class  VertexElem
 

Public Member Functions

 SvgWriter (int width, int height)
 
void modelView (const Matrix4 &matrix)
 Sets the model view matrix. Default is the identity matrix.
 
void perspective (double fovy, double aspect, double zNear, double zFar)
 Sets the projection mode to perspective projection.
 
void ortho (double left, double right, double bottom, double top)
 Sets the projection mode to orthographic projection.
 
void viewport (int x, int y, int width, int height)
 Sets the viewport. Default fills the whole image.
 
void cullface (bool cullface)
 Sets if backfacing triangles should be culled. Default is true.
 
void writePoint (const Vector3 &p, const Vector3 &color={0.0, 0.0, 0.0})
 Write one point. Drawn as a circle.
 
void writeLine (const Vector3 &p1, const Vector3 &p2, const Vector3 &color={0.0, 0.0, 0.0})
 Write one line.
 
void writeTriangle (const Vector3 &p1, const Vector3 &p2, const Vector3 &p3, const Vector3 &color)
 Write one triangle.
 
void writeTriangle (const Vector3 &p1, const Vector3 &p2, const Vector3 &p3)
 Write one triangle with color automatically calculated from light.
 
template<typename Shape >
void writeShape (const Shape &shape, bool writeVertices=false, bool writeAxis=false)
 Write all shaped edges and optionally vertices, tangents and normals.
 
template<typename Path >
void writePath (const Path &path, const bool writeVertices=false, const bool writeAxis=false)
 Write all path edges as lines and optionally vertices, tangents, normals and binormals.
 
template<typename Mesh >
void writeMesh (const Mesh &mesh, const bool writeVertices=false, const bool writeNormals=false)
 Write all triangles from a mesh.
 
std::string str () const
 Generates svg xml from the data written so far.
 

Private Member Functions

Vector3 project (const Vector3 &p) const
 
Vector3 normalToColor (const Vector3 &normal) const
 

Private Attributes

Vector2i size_
 
Matrix4 viewMatrix_
 
Matrix4 projMatrix_
 
Matrix4 viewProjMatrix_
 
Vector2i viewportOrigin_
 
Vector2i viewportSize_
 
Vector3 lightDir_
 
bool cullface_
 
Vector< UPtr< BaseElem > > elems_
 

Detailed Description

A simple svg writer class for generating preview and debug images.

Constructor & Destructor Documentation

◆ SvgWriter()

CeresEngine::MeshGenerator::SvgWriter::SvgWriter ( int  width,
int  height 
)
Parameters
widthWidth of the image in pixels
heightHeight of the iamge in pixels

Member Function Documentation

◆ cullface()

void CeresEngine::MeshGenerator::SvgWriter::cullface ( bool  cullface)

Sets if backfacing triangles should be culled. Default is true.

◆ modelView()

void CeresEngine::MeshGenerator::SvgWriter::modelView ( const Matrix4 &  matrix)

Sets the model view matrix. Default is the identity matrix.

◆ normalToColor()

Vector3 CeresEngine::MeshGenerator::SvgWriter::normalToColor ( const Vector3 normal) const
private

◆ ortho()

void CeresEngine::MeshGenerator::SvgWriter::ortho ( double  left,
double  right,
double  bottom,
double  top 
)

Sets the projection mode to orthographic projection.

This is the default.

Parameters
leftCoordinate that maps to the left edge.
rightCoordinate that maps to the right edge.

◆ perspective()

void CeresEngine::MeshGenerator::SvgWriter::perspective ( double  fovy,
double  aspect,
double  zNear,
double  zFar 
)

Sets the projection mode to perspective projection.

Default is the orthographic.

Parameters
fovyField of view along the y-axis.
aspectaspect ratio (should usually match the vieport)

◆ project()

Vector3 CeresEngine::MeshGenerator::SvgWriter::project ( const Vector3 p) const
private

◆ str()

std::string CeresEngine::MeshGenerator::SvgWriter::str ( ) const

Generates svg xml from the data written so far.

◆ viewport()

void CeresEngine::MeshGenerator::SvgWriter::viewport ( int  x,
int  y,
int  width,
int  height 
)

Sets the viewport. Default fills the whole image.

◆ writeLine()

void CeresEngine::MeshGenerator::SvgWriter::writeLine ( const Vector3 p1,
const Vector3 p2,
const Vector3 color = {0.0, 0.0, 0.0} 
)

Write one line.

◆ writeMesh()

template<typename Mesh >
void CeresEngine::MeshGenerator::SvgWriter::writeMesh ( const Mesh mesh,
const bool  writeVertices = false,
const bool  writeNormals = false 
)
inline

Write all triangles from a mesh.

◆ writePath()

template<typename Path >
void CeresEngine::MeshGenerator::SvgWriter::writePath ( const Path path,
const bool  writeVertices = false,
const bool  writeAxis = false 
)
inline

Write all path edges as lines and optionally vertices, tangents, normals and binormals.

◆ writePoint()

void CeresEngine::MeshGenerator::SvgWriter::writePoint ( const Vector3 p,
const Vector3 color = {0.0, 0.0, 0.0} 
)

Write one point. Drawn as a circle.

◆ writeShape()

template<typename Shape >
void CeresEngine::MeshGenerator::SvgWriter::writeShape ( const Shape shape,
bool  writeVertices = false,
bool  writeAxis = false 
)
inline

Write all shaped edges and optionally vertices, tangents and normals.

◆ writeTriangle() [1/2]

void CeresEngine::MeshGenerator::SvgWriter::writeTriangle ( const Vector3 p1,
const Vector3 p2,
const Vector3 p3 
)

Write one triangle with color automatically calculated from light.

◆ writeTriangle() [2/2]

void CeresEngine::MeshGenerator::SvgWriter::writeTriangle ( const Vector3 p1,
const Vector3 p2,
const Vector3 p3,
const Vector3 color 
)

Write one triangle.

Member Data Documentation

◆ cullface_

bool CeresEngine::MeshGenerator::SvgWriter::cullface_
private

◆ elems_

Vector<UPtr<BaseElem> > CeresEngine::MeshGenerator::SvgWriter::elems_
mutableprivate

◆ lightDir_

Vector3 CeresEngine::MeshGenerator::SvgWriter::lightDir_
private

◆ projMatrix_

Matrix4 CeresEngine::MeshGenerator::SvgWriter::projMatrix_
private

◆ size_

Vector2i CeresEngine::MeshGenerator::SvgWriter::size_
private

◆ viewMatrix_

Matrix4 CeresEngine::MeshGenerator::SvgWriter::viewMatrix_
private

◆ viewportOrigin_

Vector2i CeresEngine::MeshGenerator::SvgWriter::viewportOrigin_
private

◆ viewportSize_

Vector2i CeresEngine::MeshGenerator::SvgWriter::viewportSize_
private

◆ viewProjMatrix_

Matrix4 CeresEngine::MeshGenerator::SvgWriter::viewProjMatrix_
private

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