2 This file is part of the 3dengfx, realtime visualization system.
4 Copyright (c) 2004, 2005 John Tsiombikas <nuclear@siggraph.org>
6 3dengfx is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 3dengfx is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with 3dengfx; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 /* higher level 3d object abstraction
23 * Author: John Tsiombikas 2004
24 * Modified: John Tsiombikas 2005
31 #include "gfx/3dgeom.hpp"
32 #include "gfx/animation.hpp"
33 #include "n3dmath2/n3dmath2.hpp"
34 #include "material.hpp"
35 #include "3denginefx.hpp"
36 #include "gfx/bvol.hpp"
42 BlendingFactor src_blend, dest_blend;
48 scalar_t show_normals_scale;
50 Color highlight_color;
51 scalar_t highlight_line_width;
53 bool use_vertex_color;
54 TextureAddressing taddr;
62 RMODE_COLOR = 1, // unused
63 RMODE_LIGHTING = 2, // unused
70 // this bitfield determines which aspects of rendering will actually take place
71 // it overrides all render parameters.
72 extern unsigned long master_render_mode;
74 class Object : public XFormNode {
77 RenderParams render_params;
81 void render_hack(unsigned long time);
84 void draw_highlight();
86 void setup_bump_light(unsigned long time);
87 void update_bounding_volume();
94 Object(const TriMesh &mesh);
97 void set_mesh(const TriMesh &mesh);
98 TriMesh *get_mesh_ptr();
100 const TriMesh &get_mesh() const;
102 // shortcut functions for accessing the geometry easily
103 unsigned long get_vertex_count() const;
104 const Vertex *get_vertex_data() const;
105 Vertex *get_mod_vertex_data();
106 unsigned long get_triangle_count() const;
107 const Triangle *get_triangle_data() const;
108 Triangle *get_mod_triangle_data();
110 void set_dynamic(bool enable);
111 bool get_dynamic() const;
113 void set_material(const Material &mat);
114 Material *get_material_ptr();
115 Material get_material() const;
117 void set_render_params(const RenderParams &rp);
118 RenderParams get_render_params() const;
120 void set_shading(ShadeMode shading_mode);
121 void set_billboarding(bool enable);
122 void set_zwrite(bool enable);
123 void set_blending(bool enable);
124 void set_blending_mode(BlendingFactor sblend, BlendingFactor dblend);
125 void set_handle_blending(bool enable);
126 void set_wireframe(bool enable);
127 void set_gfx_program(GfxProg *prog);
128 void set_auto_cube_maps(bool enable);
129 void set_hidden(bool enable);
130 void set_show_normals(bool enable);
131 void set_show_normals_scale(scalar_t scale);
132 void set_highlight(bool enable);
133 void set_highlight_color(const Color &color);
134 void set_highlight_line_width(scalar_t width);
135 void set_auto_global(bool enable);
136 void set_use_vertex_color(bool enable);
137 void set_texture_addressing(TextureAddressing taddr);
138 void set_auto_normalize(bool enable);
139 void set_shadow_casting(bool enable);
141 void apply_xform(unsigned long time = XFORM_LOCAL_PRS);
143 void calculate_normals();
144 void normalize_normals();
146 bool render(unsigned long time = XFORM_LOCAL_PRS);
150 // --- some convinient derived objects for geom. generation ---
152 class ObjCube : public Object {
154 ObjCube(scalar_t sz, int subdiv);
157 class ObjPlane : public Object {
159 ObjPlane(const Vector3 &normal = Vector3(0, 1, 0), const Vector2 &size = Vector2(1, 1), int subdiv = 0);
162 class ObjCylinder : public Object {
164 ObjCylinder(scalar_t rad = 1.0, scalar_t len = 1.0, bool caps = true, int udiv = 12, int vdiv = 0);
167 class ObjSphere : public Object {
169 ObjSphere(scalar_t radius = 1.0, int subdiv = 5);
172 class ObjTorus : public Object {
174 ObjTorus(scalar_t circle_rad = 0.5, scalar_t revolv_rad = 1.0, int subdiv = 5);
177 class ObjTeapot : public Object {
179 ObjTeapot(scalar_t size = 1.0, int subdiv = 5);
182 #endif // _OBJECT_HPP_