Unravel Engine C++ Reference
Loading...
Searching...
No Matches
generator::svg_writer_t Class Reference

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

#include <svg_writer.hpp>

Public Member Functions

 svg_writer_t (int width, int height)
 
void modelView (const gml::dmat4 &matrix)
 Sets the model view matrix. Default is the identity matrix.
 
void perspective (double fovy, double aspect, double zNear, double zFar)
 
void ortho (double left, double right, double bottom, double top)
 
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 gml::dvec3 &p, const gml::dvec3 &color={0.0, 0.0, 0.0})
 Write one point. Drawn as a circle.
 
void writeLine (const gml::dvec3 &p1, const gml::dvec3 &p2, const gml::dvec3 &color={0.0, 0.0, 0.0})
 Write one line.
 
void writeTriangle (const gml::dvec3 &p1, const gml::dvec3 &p2, const gml::dvec3 &p3, const gml::dvec3 &color)
 Write one triangle.
 
void writeTriangle (const gml::dvec3 &p1, const gml::dvec3 &p2, const gml::dvec3 &p3)
 Write one triangle with color automatically calculated from light.
 
template<typename shape_t >
void writeShape (const shape_t &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, bool writeVertices=false, bool writeAxis=false)
 
template<typename Mesh >
void writeMesh (const Mesh &mesh, bool writeVertices=false, bool writeNormals=false)
 Write all triangles from a mesh.
 
std::string str () const
 Generates svg xml from the data written so far.
 

Detailed Description

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

Definition at line 23 of file svg_writer.hpp.

Constructor & Destructor Documentation

◆ svg_writer_t()

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

Definition at line 98 of file svg_writer.cpp.

Member Function Documentation

◆ cullface()

void svg_writer_t::cullface ( bool cullface)

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

Definition at line 136 of file svg_writer.cpp.

◆ modelView()

void svg_writer_t::modelView ( const gml::dmat4 & matrix)

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

Definition at line 112 of file svg_writer.cpp.

◆ ortho()

void svg_writer_t::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.

Definition at line 124 of file svg_writer.cpp.

◆ perspective()

void svg_writer_t::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)

Definition at line 118 of file svg_writer.cpp.

◆ str()

std::string svg_writer_t::str ( ) const

Generates svg xml from the data written so far.

Definition at line 176 of file svg_writer.cpp.

◆ viewport()

void svg_writer_t::viewport ( int x,
int y,
int width,
int height )

Sets the viewport. Default fills the whole image.

Definition at line 130 of file svg_writer.cpp.

◆ writeLine()

void svg_writer_t::writeLine ( const gml::dvec3 & p1,
const gml::dvec3 & p2,
const gml::dvec3 & color = {0.0, 0.0, 0.0} )

Write one line.

Definition at line 146 of file svg_writer.cpp.

◆ writeMesh()

template<typename Mesh >
void generator::svg_writer_t::writeMesh ( const Mesh & mesh,
bool writeVertices = false,
bool writeNormals = false )
inline

Write all triangles from a mesh.

Definition at line 204 of file svg_writer.hpp.

◆ writePath()

template<typename Path >
void generator::svg_writer_t::writePath ( const Path & path,
bool writeVertices = false,
bool writeAxis = false )
inline

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

Definition at line 170 of file svg_writer.hpp.

◆ writePoint()

void svg_writer_t::writePoint ( const gml::dvec3 & p,
const gml::dvec3 & color = {0.0, 0.0, 0.0} )

Write one point. Drawn as a circle.

Definition at line 141 of file svg_writer.cpp.

◆ writeShape()

template<typename shape_t >
void generator::svg_writer_t::writeShape ( const shape_t & shape,
bool writeVertices = false,
bool writeAxis = false )
inline

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

Definition at line 129 of file svg_writer.hpp.

◆ writeTriangle() [1/2]

void svg_writer_t::writeTriangle ( const gml::dvec3 & p1,
const gml::dvec3 & p2,
const gml::dvec3 & p3 )

Write one triangle with color automatically calculated from light.

Definition at line 171 of file svg_writer.cpp.

◆ writeTriangle() [2/2]

void svg_writer_t::writeTriangle ( const gml::dvec3 & p1,
const gml::dvec3 & p2,
const gml::dvec3 & p3,
const gml::dvec3 & color )

Write one triangle.

Definition at line 153 of file svg_writer.cpp.


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