User manual:   Main Page   Overview   Installation   User Interface   Tutorial   Example   FAQ   Version Updates
Reference manual:   Class List   Class Members   Globals, enums and defines

Renderer Class Reference

Handles the rendering functions and modes, such as backface culling, perspective/orthographic view, colors, highlights, transformations etc. More...

List of all members.

Rendering modes

RESULT setRenderMode (RENDER_MODE mode=WIREFRAME)
RESULT getRenderMode (RENDER_MODE &mode)
RESULT setPerspective (bool perspective=true)
RESULT getPerspective (bool &perspective)
RESULT setBackfaceCulling (bool enable=true)
RESULT getBackfaceCulling (bool &enable)
RESULT setLineDrawing (bool enable=true)
RESULT getLineDrawing (bool &enable)
RESULT setSphereDrawing (bool enable=true)
RESULT getSphereDrawing (bool &enable)
RESULT setCylinderDrawing (bool enable=true)
RESULT getCylinderDrawing (bool &enable)
RESULT displayText (const char *text=NULL, const Coord2D *coord=NULL)
RESULT setAutoRefresh (bool enable=true)
RESULT refreshScreen ()
RESULT setAutoScale (bool enable=true)
RESULT setMouseInteraction (bool enable=true)

Transformations

RESULT rotate (AXIS axis, int angle)
RESULT translate (int dx, int dy, int dz=0)
RESULT scale (int dy)

Colors

RESULT setBgColor (Color color)
RESULT getBgColor (Color &color)
RESULT setVerticesDefaultColor (Color color)
RESULT getVerticesDefaultColor (Color &color)
RESULT setEdgesDefaultColor (Color color)
RESULT getEdgesDefaultColor (Color &color)
RESULT setFacesDefaultColor (const Color color)
RESULT getFacesDefaultColor (Color &color)
RESULT setLinesDefaultColor (const Color color)
RESULT getLinesDefaultColor (Color &color)
RESULT setSpheresDefaultColor (const Color color)
RESULT getSpheresDefaultColor (Color &color)
RESULT setCylindersDefaultColor (const Color color)
RESULT getCylindersDefaultColor (Color &color)
RESULT setVertexColor (VertexID vID, const Color *color=NULL)
RESULT getVertexColor (VertexID vID, Color &color)
RESULT setEdgeColor (EdgeID eID, const Color *color=NULL)
RESULT getEdgeColor (EdgeID eID, Color &color)
RESULT setFaceColor (FaceID fID, const Color *color=NULL)
RESULT getFaceColor (FaceID fID, Color &color)
RESULT setLineColor (LineID lID, const Color *color=NULL)
RESULT getLineColor (LineID lID, Color &color)
RESULT setSphereColor (SphereID sID, const Color *color=NULL)
RESULT getSphereColor (SphereID sID, Color &color)
RESULT setCylinderColor (CylinderID cID, const Color *color=NULL)
RESULT getCylinderColor (CylinderID cID, Color &color)
RESULT setAllVerticesColor (Color color)
RESULT setAllEdgesColor (Color color)
RESULT setAllFacesColor (Color color)
RESULT setAllLinesColor (Color color)
RESULT setAllSpheresColor (Color color)
RESULT setAllCylindersColor (Color color)
RESULT setTextColor (Color color)
RESULT getTextColor (Color &color)
RESULT colorFaces (const LinkedList< FaceID > *faces=NULL)

Highlights

RESULT highlightAllVertices (bool highlight=true)
RESULT highlightAllEdges (bool highlight=true)
RESULT highlightAllFaces (bool highlight=true)
RESULT getHighlightAllVertices (bool &highlight)
RESULT getHighlightAllEdges (bool &highlight)
RESULT getHighlightAllFaces (bool &highlight)
RESULT highlightVertex (VertexID vID, bool highlight=true)
RESULT highlightEdge (EdgeID eID, bool highlight=true)
RESULT highlightFace (FaceID fID, bool highlight=true)

Picking objects

RESULT pickVertex (VertexID &vID, unsigned int timeOut=0)
RESULT pickEdge (EdgeID &eID, unsigned int timeOut=0)
RESULT pickFace (FaceID &fID, unsigned int timeOut=0)

Texture mapping

RESULT setTextureMapping (bool enable=true)
RESULT getTextureMapping (bool &enable)
RESULT setTextureImage (const char *fileName)
RESULT getTextureImage (char *fileName)
RESULT setVertexUV (VertexID vID, double u, double v)
RESULT setVerticesUV (const LinkedList< VertexID > *vertices, const LinkedList< Coord2D > *coords)
RESULT getVertexUV (VertexID vID, double &u, double &v)


Detailed Description

Handles the rendering functions and modes, such as backface culling, perspective/orthographic view, colors, highlights, transformations etc.


Member Function Documentation

RESULT Renderer::colorFaces const LinkedList< FaceID > *    faces = NULL
 

Use random colors to color the different faces.

Parameters:
faces A list of all the FaceIDs to color. If NULL, all the faces of the mesh will be randomly colored.
Return values:
OK Operation succeeded
FaceNotFound No face was found with one of the given FaceIDs.

RESULT Renderer::displayText const char *    text = NULL,
const Coord2D   coord = NULL
 

Displays text at given screen coordinates.

Parameters:
text The text to be displayed
coord The coordinate in which the text will be displayed on the screen, where (0,0) is the top left corner
Return values:
OK Operation succeeded
OversizedString Text is longer than MAX_STRING_SIZE
Note:
  • If text is NULL, the text is cleared (equivalent to displayText("", coord)).
  • The text's maximal allowed size is MAX_STRING_SIZE.
  • If coord is NULL, the text is displayed at (0,0).
  • With each call to this function, the previous text is cleared (no matter where it was displayed on the screen).

RESULT Renderer::getBackfaceCulling bool &    enable
 

Get current backface culling mode (enabled/disabled).

Parameters:
enable [output] If true, backface culling is enabled. Otherwise, it's disabled.
Return values:
OK Operation succeeded

RESULT Renderer::getBgColor Color   color
 

Set background color.

Parameters:
color [output] The current background color
Return values:
OK Operation succeeded

RESULT Renderer::getCylinderColor CylinderID    cID,
Color   color
 

Get the color of the given cylinder.

Parameters:
cID The ID of the cylinder
color [output] The color of the given cylinder
Return values:
OK Operation succeeded
CylinderNotFound No cylinder was found with the given ID

RESULT Renderer::getCylinderDrawing bool &    enable
 

Gets the current cylinder drawing policy.

Parameters:
enable [output] If true, cylinder drawing is enabled. Otherwise, it's disabled.
Return values:
OK Operation succeeded

RESULT Renderer::getCylindersDefaultColor Color   color
 

Get the default cylinders color.

Parameters:
color [output] The default cylinders color
Return values:
OK Operation succeeded

RESULT Renderer::getEdgeColor EdgeID    eID,
Color   color
 

Get the color of the given edge.

Parameters:
eID The ID of the edge
color [output] The color of the given edge
Return values:
OK Operation succeeded
EdgeNotFound No edge was found with the given ID

RESULT Renderer::getEdgesDefaultColor Color   color
 

Get the default edges color.

Parameters:
color [output] The default edges color
Return values:
OK Operation succeeded

RESULT Renderer::getFaceColor FaceID    fID,
Color   color
 

Get the color of the given face.

Parameters:
fID The ID of the face
color [output] The color of the given face
Return values:
OK Operation succeeded
FaceNotFound No face was found with the given ID

RESULT Renderer::getFacesDefaultColor Color   color
 

Get the default faces color.

Parameters:
color [output] The default faces color
Return values:
OK Operation succeeded

RESULT Renderer::getHighlightAllEdges bool &    highlight
 

Gets the mode of the edges highlighting (enabled/disabled).

Parameters:
highlight [output] If true, edges highlighting is enabled. Else, it's false
Return values:
OK Operation succeeded

RESULT Renderer::getHighlightAllFaces bool &    highlight
 

Gets the mode of the faces highlighting (enabled/disabled).

Parameters:
highlight [output] If true, faces highlighting is enabled. Else, it's false
Return values:
OK Operation succeeded

RESULT Renderer::getHighlightAllVertices bool &    highlight
 

Gets the mode of the vertices highlighting (enabled/disabled).

Parameters:
highlight [output] If true, vertices highlighting is enabled. Else, it's false
Return values:
OK Operation succeeded

RESULT Renderer::getLineColor LineID    lID,
Color   color
 

Get the color of the given line.

Parameters:
lID The ID of the line
color [output] The color of the given line
Return values:
OK Operation succeeded
LineNotFound No line was found with the given ID

RESULT Renderer::getLineDrawing bool &    enable
 

Gets the current line drawing policy.

Parameters:
enable [output] If true, line drawing is enabled. Otherwise, it's disabled.
Return values:
OK Operation succeeded

RESULT Renderer::getLinesDefaultColor Color   color
 

Get the default lines color.

Parameters:
color [output] The default lines color
Return values:
OK Operation succeeded

RESULT Renderer::getPerspective bool &    perspective
 

Get current perspective/orthographics mode.

Parameters:
perspective [output] If true, current mode is perspective. Otherwise, mode is orthographics
Return values:
OK Operation succeeded

RESULT Renderer::getRenderMode RENDER_MODE   mode
 

Get current rendering mode.

Parameters:
mode [output] Current rendering mode
Return values:
OK Operation succeeded

RESULT Renderer::getSphereColor SphereID    sID,
Color   color
 

Get the color of the given sphere.

Parameters:
sID The ID of the sphere
color [output] The color of the given sphere
Return values:
OK Operation succeeded
SphereNotFound No sphere was found with the given ID

RESULT Renderer::getSphereDrawing bool &    enable
 

Gets the current sphere drawing policy.

Parameters:
enable [output] If true, sphere drawing is enabled. Otherwise, it's disabled.
Return values:
OK Operation succeeded

RESULT Renderer::getSpheresDefaultColor Color   color
 

Get the default spheres color.

Parameters:
color [output] The default spheres color
Return values:
OK Operation succeeded

RESULT Renderer::getTextColor Color   color
 

Get the text color.

Parameters:
color [output] The text color
Return values:
OK Operation succeeded

RESULT Renderer::getTextureImage char *    fileName
 

Get the image used in the texture mapping.

Parameters:
fileName The file name of the bitmap image used in the texture mapping
Return values:
OK Operation succeeded
NullPointerGiven fileName is NULL
Note:
If fileName is not NULL, the function will copy the file name into it. fileName needs to be allocated by the user before use!

RESULT Renderer::getTextureMapping bool &    enable
 

Get the current texture mapping state.

Parameters:
enable [output] If true, texture mapping is enabled
Return values:
OK Operation succeeded

RESULT Renderer::getVertexColor VertexID    vID,
Color   color
 

Get the color of the given vertex.

Parameters:
vID The ID of the vertex
color [output] The color of the given vertex
Return values:
OK Operation succeeded
VertexNotFound No vertex was found with the given ID

RESULT Renderer::getVertexUV VertexID    vID,
double &    u,
double &    v
 

Get the (u,v) texture mapping coordinate of a vertex.

Parameters:
vID The ID of the vertex to get (u,v) coordinates of
u [output] The u-coordinate of the texture mapping (for this vertex)
v [output] The v-coordinate of the texture mapping (for this vertex)
Return values:
OK Operation succeeded
VertexNotFound No vertex was found with the given ID

RESULT Renderer::getVerticesDefaultColor Color   color
 

Get the default vertices color.

Parameters:
color [output] The default vertices color
Return values:
OK Operation succeeded

RESULT Renderer::highlightAllEdges bool    highlight = true
 

Toggles rendering of all edges as thick lines.

Parameters:
highlight If true, all edges will be rendered as thick lines.
Return values:
OK Operation succeeded
Note:
Highlighted edges will be shown in all rendering modes

RESULT Renderer::highlightAllFaces bool    highlight = true
 

Toggles highlighting of all faces.

Parameters:
highlight If true, all faces will be highlighted.
Return values:
OK Operation succeeded
Note:
Highlighted faces will be shown in all rendering modes

RESULT Renderer::highlightAllVertices bool    highlight = true
 

Toggles rendering of all vertices as small cubes.

Parameters:
highlight If true, all vertices will be rendered as small cubes.
Return values:
OK Operation succeeded
Note:
Highlighted vertices will be shown in all rendering modes

RESULT Renderer::highlightEdge EdgeID    eID,
bool    highlight = true
 

Toggles highlighting of a given edge.

Parameters:
eID The ID of the edge to highlight
highlight If true, the edge will be highlighted
Return values:
OK Operation succeeded
EdgeNotFound No edge was found with the given ID

RESULT Renderer::highlightFace FaceID    fID,
bool    highlight = true
 

Toggles highlighting of a given face.

Parameters:
fID The ID of the face to highlight
highlight If true, the face will be highlighted
Return values:
OK Operation succeeded
FaceNotFound No face was found with the given ID

RESULT Renderer::highlightVertex VertexID    vID,
bool    highlight = true
 

Toggles highlighting of a given vertex.

Parameters:
vID The ID of the vertex to highlight
highlight If true, the vertex will be highlighted
Return values:
OK Operation succeeded
VertexNotFound No vertex was found with the given ID

RESULT Renderer::pickEdge EdgeID   eID,
unsigned int    timeOut = 0
 

Allows the user to pick an edge with a mouse left-click.

Parameters:
timeOut The desired time until time-out occurs, in milliseconds. If 0, time-out will never occur and the function will wait infinitely until the user picks an edge
eID [output] The ID of the picked edge
Return values:
OK Operation succeeded
TimeOut The user didn't respond in the given time

RESULT Renderer::pickFace FaceID   fID,
unsigned int    timeOut = 0
 

Allows the user to pick a face with a mouse left-click.

Parameters:
timeOut The desired time until time-out occurs, in milliseconds. If 0, time-out will never occur and the function will wait infinitely until the user picks a face
fID [output] The ID of the picked face
Return values:
OK Operation succeeded
TimeOut The user didn't respond in the given time

RESULT Renderer::pickVertex VertexID   vID,
unsigned int    timeOut = 0
 

Allows the user to pick a vertex with a mouse left-click.

Parameters:
timeOut The desired time until time-out occurs, in milliseconds. If 0, time-out will never occur and the function will wait infinitely until the user picks a vertex
vID [output] The ID of the picked vertex
Return values:
OK Operation succeeded
TimeOut The user didn't respond in the given time

RESULT Renderer::refreshScreen  
 

Refreshes the model viewed in the window (in case the user made a change which has not yet been shown).

Return values:
OK Operation succeeded
See also:
setAutoRefresh()

RESULT Renderer::rotate AXIS    axis,
int    angle
 

Rotate the mesh around a given axis at a given angle.

Parameters:
axis The axis to rotate around
angle The angel to rotate by (in degrees)
Return values:
OK Operation succeeded

RESULT Renderer::scale int    dy
 

Scale the mesh (uniformly on each axis).

Parameters:
dy How much to scale the model. If dy>0, the model will be enlarged, otherwise it will be shrinked.
Return values:
OK Operation succeeded

RESULT Renderer::setAllCylindersColor Color    color
 

Sets all the cylinders to use the default cylinder color.

The default cylinders color will be changed to the given color

Parameters:
color The new default cylinders color
Return values:
OK Operation succeeded

RESULT Renderer::setAllEdgesColor Color    color
 

Sets all the edges to use the default edge color.

The default edges color will be changed to the given color

Parameters:
color The new default edges color
Return values:
OK Operation succeeded

RESULT Renderer::setAllFacesColor Color    color
 

Sets all the faces to use the default face color.

The default faces color will be changed to the given color

Parameters:
color The new default faces color
Return values:
OK Operation succeeded

RESULT Renderer::setAllLinesColor Color    color
 

Sets all the lines to use the default line color.

The default lines color will be changed to the given color

Parameters:
color The new default lines color
Return values:
OK Operation succeeded

RESULT Renderer::setAllSpheresColor Color    color
 

Sets all the spheres to use the default sphere color.

The default spheres color will be changed to the given color

Parameters:
color The new default spheres color
Return values:
OK Operation succeeded

RESULT Renderer::setAllVerticesColor Color    color
 

Sets all the vertices to use the default vertex color.

The default vertices color will be changed to the given color

Parameters:
color The new default vertices color
Return values:
OK Operation succeeded

RESULT Renderer::setAutoRefresh bool    enable = true
 

Toggles auto rendering after each model change.

If set to false, rendering of the window will occur only when the user calls refreshScreen(). Otherwise, the window will be re-rendered after each mouse move and model change.

Parameters:
enable Toggles on (true) or off (false)
Return values:
OK Operation succeeded
See also:
refreshScreen()

RESULT Renderer::setAutoScale bool    enable = true
 

Toggles auto scaling after each model change.

If set to true, rescaling of the model will occur automatically after every model change.

Parameters:
enable Toggles on (true) or off (false)
Return values:
OK Operation succeeded
Note:
This function is usually used with the Mesh::startNewModel() function, in order to rescale the model after each change, to fit nicely in the render window.
See also:
Mesh::startNewModel()

RESULT Renderer::setBackfaceCulling bool    enable = true
 

Enable/disable backface culling.

Parameters:
enable If true, backface culling is enabled
Return values:
OK Operation succeeded

RESULT Renderer::setBgColor Color    color
 

Set background color.

Parameters:
color The new color for the background
Return values:
OK Operation succeeded

RESULT Renderer::setCylinderColor CylinderID    cID,
const Color   color = NULL
 

Set the color of the given cylinder.

Parameters:
cID The ID of the cylinder
color A pointer to the new color. If NULL, the default cylinders color is used
Return values:
OK Operation succeeded
CylinderNotFound No cylinder was found with the given ID

RESULT Renderer::setCylinderDrawing bool    enable = true
 

Toggles rendering of cylinders.

Parameters:
enable Toggles on (true) or off (false)
Return values:
OK Operation succeeded

RESULT Renderer::setCylindersDefaultColor const Color    color
 

Set the default cylinders color.

Parameters:
color The new default cylinders color
Return values:
OK Operation succeeded

RESULT Renderer::setEdgeColor EdgeID    eID,
const Color   color = NULL
 

Set the color of the given edge.

Parameters:
eID The ID of the edge
color A pointer to the new color. If NULL, the default edges color is used
Return values:
OK Operation succeeded
EdgeNotFound No edge was found with the given ID

RESULT Renderer::setEdgesDefaultColor Color    color
 

Set the default edges color.

Parameters:
color The new default edges color
Return values:
OK Operation succeeded

RESULT Renderer::setFaceColor FaceID    fID,
const Color   color = NULL
 

Set the color of the given face.

Parameters:
fID The ID of the face
color A pointer to the new color. If NULL, the default faces color is used
Return values:
OK Operation succeeded
FaceNotFound No face was found with the given ID

RESULT Renderer::setFacesDefaultColor const Color    color
 

Set the default faces color.

Parameters:
color The new default faces color
Return values:
OK Operation succeeded

RESULT Renderer::setLineColor LineID    lID,
const Color   color = NULL
 

Set the color of the given line.

Parameters:
lID The ID of the line
color A pointer to the new color. If NULL, the default lines color is used
Return values:
OK Operation succeeded
LineNotFound No line was found with the given ID

RESULT Renderer::setLineDrawing bool    enable = true
 

Toggles rendering of lines.

Parameters:
enable Toggles on (true) or off (false)
Return values:
OK Operation succeeded

RESULT Renderer::setLinesDefaultColor const Color    color
 

Set the default lines color.

Parameters:
color The new default lines color
Return values:
OK Operation succeeded

RESULT Renderer::setMouseInteraction bool    enable = true
 

Toggles interacting with the model (using the mouse events).

Parameters:
enable If true, all mouse events are enabled (the model can transformed, scaled and rotated); else, they're disabled
Return values:
OK Operation succeeded

RESULT Renderer::setPerspective bool    perspective = true
 

Set to perspective/orthographics mode.

Parameters:
perspective The new perspective/orthographics mode (true for perspective, else false)
Return values:
OK Operation succeeded

RESULT Renderer::setRenderMode RENDER_MODE    mode = WIREFRAME
 

Set the rendering mode.

Parameters:
mode The new render mode
Return values:
OK Operation succeeded

RESULT Renderer::setSphereColor SphereID    sID,
const Color   color = NULL
 

Set the color of the given sphere.

Parameters:
sID The ID of the sphere
color A pointer to the new color. If NULL, the default spheres color is used
Return values:
OK Operation succeeded
SphereNotFound No sphere was found with the given ID

RESULT Renderer::setSphereDrawing bool    enable = true
 

Toggles rendering of spheres.

Parameters:
enable Toggles on (true) or off (false)
Return values:
OK Operation succeeded

RESULT Renderer::setSpheresDefaultColor const Color    color
 

Set the default spheres color.

Parameters:
color The new default spheres color
Return values:
OK Operation succeeded

RESULT Renderer::setTextColor Color    color
 

Set the text color.

Parameters:
color The new text color
Return values:
OK Operation succeeded

RESULT Renderer::setTextureImage const char *    fileName
 

Set the image to use in the texture mapping.

Parameters:
fileName The file name of the bitmap image to be used in the texture mapping
Return values:
OK Operation succeeded
NullPointerGiven fileName is NULL
FileNotFound The file was not found in the given location
Note:
The image can be only of type 24-bit bitmap (i.e. *.bmp). If the image's height or width are not a power of 2, the image will be automatically cropped to the proper size (the closest lower power of 2).

RESULT Renderer::setTextureMapping bool    enable = true
 

Enable/disable texture mapping.

Parameters:
enable If true, texture mapping is enabled
Return values:
OK Operation succeeded

RESULT Renderer::setVertexColor VertexID    vID,
const Color   color = NULL
 

Set the color of the given vertex.

Parameters:
vID The ID of the vertex
color A pointer to the new color. If NULL, the default vertices color is used
Return values:
OK Operation succeeded
VertexNotFound No vertex was found with the given ID

RESULT Renderer::setVertexUV VertexID    vID,
double    u,
double    v
 

Set the (u,v) texture mapping coordinate of a vertex.

Parameters:
vID The ID of the vertex to set
u The u-coordinate of the texture mapping (for this vertex)
v The v-coordinate of the texture mapping (for this vertex)
Return values:
OK Operation succeeded
VertexNotFound No vertex was found with the given ID
Note:
u and v should usually be in the range [0, 1]. u is the coordinate in the x-axis of the bitmap, and v is the coordinate in the y-axis. The coordinate (0,0) is the bottom left corner of the bitmap file, and the coordinate (1,1) is the top right corner. If u or v are outside that range, the image will be repeated as needed.

RESULT Renderer::setVerticesDefaultColor Color    color
 

Set the default vertices color.

Parameters:
color The new default vertices color
Return values:
OK Operation succeeded

RESULT Renderer::setVerticesUV const LinkedList< VertexID > *    vertices,
const LinkedList< Coord2D > *    coords
 

Set the (u,v) texture mapping coordinate for a list of vertices.

Parameters:
vertices The list of VertexIDs of the vertices to set (u,v) coordinates for
coords The (u,v) coordinates of the texture mapping, given as a 2D coord. The first cell in each coordinate (i.e. coord[0]) represents the u-coordinate, the second cell (i.e. coord[1]) represents the v-coordinate.
Return values:
OK Operation succeeded
NullPointerGiven One of the given lists is NULL
VertexNotFound No vertex was found one of the given IDs in vertices
Note:
The 2 lists should be of the same size. The i'th coord in coords defines the (u,v) coordinate for the i'th VertexID in vertices. If the lists have different lengths (meaning there are extra vertices IDs or extra coordinates), the extra data in the longer list will be ignored.
u and v should usually be in the range [0, 1]. u is the coordinate in the x-axis of the bitmap, and v is the coordinate in the y-axis. The coordinate (0,0) is the bottom left corner of the bitmap file, and the coordinate (1,1) is the top right corner. If u or v are outside that range, the image will be repeated as needed.

RESULT Renderer::translate int    dx,
int    dy,
int    dz = 0
 

Translate the mesh.

Parameters:
dx How much to translate in the X axis
dy How much to translate in the Y axis
dz How much to translate in the Z axis
Return values:
OK Operation succeeded


The documentation for this class was generated from the following file:
MeshMaker 5.2 Manual
This software library was written by Roni Raab, ronir@cs.technion.ac.il.
Last updated on May 2003.
This software is for academic and research use only.