contains object information(unique name, type), 3D data(vertices, faces, normal and texture coordinates), position, rotation and scale, link to material and some specific settings (like shadow casting) More...
#include <object.h>
Public Member Functions | |
TObject () | |
Set default values, primitive type and resets position. | |
~TObject () | |
Destructor. | |
void | Create (const char *name, int primitive, GLfloat size, GLfloat height, GLint sliceX, GLint sliceY) |
Creates object using direct parameters. Objects are generated directly and then stored in VBO for faster further drawing. | |
VBO | Create (const char *name, const char *file, bool load=true) |
Creates object from external 3DS file. | |
VBO | Create (Lib3dsMesh *mesh) |
Creates object directly from 3DS mesh. | |
void | CreateInstance (const TObject &ref) |
create object as instance from existing object | |
void | SetVBOdata (VBO data) |
void | SetGInstances (int count) |
Set number of current object GI instances. | |
GLint | GetVertexBuffer () |
Return vertex buffer ID. | |
void | Draw (TMatrix &viewMatrix, bool render_mat=true) |
Draws object by calling it's display list. Before this object is transformed and rotated to it's current position. Then attached material is rendered(TMaterial::RenderMaterial()) There are specific types of settings, when object is not rendered (e.g. when rendering into shadow map is active and object don't cast shadows). | |
void | DrawScreenQuad () |
Draws screen aligned quad. | |
void | DrawObject (bool flag) |
turn on/off object drawing | |
void | SetMaterial (TMaterial *m) |
Set material to object (material referenced as TMaterial class). | |
float | GetReflect () |
Has object reflections? | |
bool | HasMaterial () |
Return if object has assigned material. | |
string | GetMatName () |
Return material name. | |
void | Move (GLfloat wx, GLfloat wy, GLfloat wz) |
Move object from current position by position vector(relative). | |
void | MoveAbs (GLfloat wx, GLfloat wy, GLfloat wz) |
Move object to new position(relative). | |
void | MoveAbs (TVector w) |
Move object to new absolute position. | |
void | Rotate (GLfloat angle, GLint axis) |
Rotate object by adding angle to current rotation(relative). | |
void | RotateAbs (GLfloat angle, GLint axis) |
Rotate object by new angle(absolute). | |
void | Resize (GLfloat sx, GLfloat sy, GLfloat sz) |
Resize object. | |
void | CastShadow (bool flag=true) |
Enable/disable shadow casting by object. | |
string | GetName () |
Return object name. | |
TVector | GetPosition () |
Return object position (as TVector). | |
bool | IsTransparent () |
has object bound a transparent material? | |
bool | HasFramebuffer () |
has object bound framebuffer for reflection? | |
Public Attributes | |
GLuint | cf_buffer |
framebuffer for dynamic reflection | |
GLuint | cr_buffer |
renderbuffer for dynamic reflection | |
GLuint | render_cubemap |
cubemap to render into | |
GLuint | render_cubemap_depth |
depth texture for cubemap | |
GLuint | refl_size |
reflection render size |
contains object information(unique name, type), 3D data(vertices, faces, normal and texture coordinates), position, rotation and scale, link to material and some specific settings (like shadow casting)
TObject::~TObject | ( | ) |
VBO TObject::Create | ( | Lib3dsMesh * | mesh | ) |
Creates object directly from 3DS mesh.
mesh | 3DS mesh |
VBO TObject::Create | ( | const char * | _name, | |
const char * | _file, | |||
bool | load = true | |||
) |
Creates object from external 3DS file.
_name | object name | |
_file | file with object data in 3DS format | |
load | has object data been loaded before? |
void TObject::Create | ( | const char * | _name, | |
int | primitive, | |||
GLfloat | size, | |||
GLfloat | height, | |||
GLint | sliceX, | |||
GLint | sliceY | |||
) |
Creates object using direct parameters. Objects are generated directly and then stored in VBO for faster further drawing.
_name | object name(must be unique) | |
primitive | object type (can be CUBE,PLANE,CONE,CYLINDER,DISK,SPHERE,TORUS,TEAPOT,SPLINE,FONT) | |
size | basic object size (depends on primitive type) | |
height | object height (depends on primitive type) | |
sliceX | polygon count horizontal (depends on primitive type) | |
sliceY | polygon count vertical (depends on primitive type) |
Every primitive type use parameters differently:
cube: 1 param: size
plane: 2 params, size, sizeY
strip plane: 4 params, size, sizeY, sliceX, sliceY
cone: 4 params: baseRadius, height, sliceX, sliceY
cylinder: 4 params: baseRadius, height, sliceX, sliceY
disk: 4 params: innerRadius, outerRadius, sliceX, sliceY
sphere: 3 params: radius, sliceX, sliceY
torus: 4 params: innerRadius, outerRadius, nsides, rings
(torus creation - thanks to http://www.sulaco.co.za/)
void TObject::Draw | ( | TMatrix & | viewMatrix, | |
bool | render_mat = true | |||
) |
Draws object by calling it's display list. Before this object is transformed and rotated to it's current position. Then attached material is rendered(TMaterial::RenderMaterial()) There are specific types of settings, when object is not rendered (e.g. when rendering into shadow map is active and object don't cast shadows).
viewMatrix | actual view matrix | |
render_mat | whether object material should be drawn |
void TObject::Move | ( | GLfloat | wx, | |
GLfloat | wy, | |||
GLfloat | wz | |||
) |
Move object from current position by position vector(relative).
wx | X-coordinate of vector | |
wy | Y-coordinate of vector | |
wz | Z-coordinate of vector |
void TObject::MoveAbs | ( | TVector | w | ) | [inline] |
Move object to new absolute position.
w | new position coordinates |
void TObject::MoveAbs | ( | GLfloat | wx, | |
GLfloat | wy, | |||
GLfloat | wz | |||
) |
Move object to new position(relative).
wx | X-coordinate of vector | |
wy | Y-coordinate of vector | |
wz | Z-coordinate of vector |
void TObject::Resize | ( | GLfloat | sx, | |
GLfloat | sy, | |||
GLfloat | sz | |||
) |
Resize object.
sx | scale in X-axis (<1.0 - smaller, >1.0 - bigger) | |
sy | scale in Y-axis (<1.0 - smaller, >1.0 - bigger) | |
sz | scale in Z-axis (<1.0 - smaller, >1.0 - bigger) |
void TObject::Rotate | ( | GLfloat | angle, | |
GLint | axis | |||
) |
Rotate object by adding angle to current rotation(relative).
angle | rotation increment in degrees | |
axis | rotational axis (can be A_X, A_Y, A_Z) |
void TObject::RotateAbs | ( | GLfloat | angle, | |
GLint | axis | |||
) |
Rotate object by new angle(absolute).
angle | new rotation angle in degrees | |
axis | rotational axis (can be A_X, A_Y, A_Z) |
void TObject::SetVBOdata | ( | VBO | data | ) | [inline] |