A
download object3d.h
Language: C++
License: GPL
Copyright: (C) 2000-2005 Vincent LE PRINCE
LOC: 239
Project Info
Truevision
Server: SourceForge
Type: cvs
...evision\Truevision\include\
   atmosphere.h
   bicubic.h
   blob.h
   box.h
   camera.h
   cone.h
   cylinder.h
   density.h
   disc.h
   dlgutils.h
   fnintern.h
   fog.h
   function.h
   glview.h
   glview2d.h
   glview3d.h
   heightfield.h
   impsurface.h
   interface.h
   interior.h
   isosurface.h
   julia.h
   lathe.h
   lights.h
   linkobj.h
   main.h
   mapedit.h
   material.h
   matlib.h
   matlist.h
   matpov.h
   media.h
   mesh.h
   meshrotate.h
   meshscale.h
   meshtool.h
   meshtranslate.h
   obj3dcsg.h
   obj3ddef.h
   object3d.h
   objectlayer.h
   objectlist.h
   parametric.h
   plane.h
   polygon.h
   povfe.h
   povpreview.h
   povscript.h
   preferences.h
   prism.h
   proppanel.h
   pycamera.h
   pyengine.h
   pylights.h
   pyobjects.h
   pyscriptdb.h
   pyscriptobj.h
   pyutils.h
   rotation.h
   scene.h
   scriptobj.h
   slopemap.h
   sphere.h
   spheresweep.h
   spline2d.h
   spline3d.h
   superellipsoid.h
   texfinish.h
   texnormal.h
   texpigment.h
   text.h
   torus.h
   tvio.h
   tvwidgets.h
   undo.h
   utils3d.h
   vertex.h
   viewmanager.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
//*****************************************************************************************
// Truevision - a 3d modeler for povray
//
// object3d.cc
//
// Vincent LE PRINCE <vincentleprince@users.sourceforge.net>
// Copyright (C) 2000-2005 Vincent LE PRINCE
// This file is part of the TRUEVISION Package

//   This program is free software; you can redistribute it and/or modify
//   it under the terms of the GNU General Public License as published by
//   the Free Software Foundation; either version 2 of the License, or
//   (at your option) any later version.
//
//   This program is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program; if not, write to the Free Software
//   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */ 
//*******************************************************************************************
#ifndef TV_OBJ3D_H
#define TV_OBJ3D_H
using namespace std;
#include <iostream>
#include <fstream>
#include "GL/gl.h"
#include "GL/glu.h"

//#include "objparam.h"
#include "main.h"
#include "glview.h"
#include "dlgutils.h"

class ObjectLayer;
class Vertex;

//**************************************
// Object Types
//**************************************
enum obj3d {
	TV_OBJ3D_CAMERA = 0,
	TV_OBJ3D_POINTLIGHT,
	TV_OBJ3D_SPOTLIGHT,
	TV_OBJ3D_CYLLIGHT,
	TV_OBJ3D_AREALIGHT,
	TV_OBJ3D_BOX,
	TV_OBJ3D_SPHERE,
	TV_OBJ3D_CYLINDER,
	TV_OBJ3D_CONE,
	TV_OBJ3D_BKGD,
	TV_OBJ3D_CSGUNION,
	TV_OBJ3D_CSGMERGE,
	TV_OBJ3D_CSGINTERSECTION,
	TV_OBJ3D_CSGDIFFERENCE,	
	TV_OBJ3D_PLANE,
	TV_OBJ3D_SKY,
	TV_OBJ3D_TORUS,
	TV_OBJ3D_AMEDIA,
	TV_OBJ3D_DISC,
	TV_OBJ3D_HEIGHTFIELD,
	TV_OBJ3D_SUPERELLIPSOID,
	TV_OBJ3D_FOG,
	TV_OBJ3D_LIGHTGROUP,
	TV_OBJ3D_BLOB,
	TV_OBJ3D_BLOBSPHERE,
	TV_OBJ3D_BLOBCYLINDER,
	TV_OBJ3D_TEXT,
	TV_OBJ3D_LATHE,
	TV_OBJ3D_LINK,
	TV_OBJ3D_GROUP,
	TV_OBJ3D_PRISM,
	TV_OBJ3D_ISOSURFACE,
	TV_OBJ3D_JULIA,
	TV_OBJ3D_PARAMETRIC,
	TV_OBJ3D_POVSCRIPT, 
	TV_OBJ3D_SPHERESWEEP,
	TV_OBJ3D_BICUBIC,
	TV_OBJ3D_SCRIPTOBJ,
	TV_OBJ3D_MESH,
	TV_OBJ3D_MESH_TRANSLATION,
	TV_OBJ3D_MESH_SCALE,
	TV_OBJ3D_MESH_ROTATION,
};
typedef obj3d Object3DType;

enum obj3dcat {
	TV_OBJ3D_NOCAT = 0,
	TV_OBJ3D_LIGHTS,
	TV_OBJ3D_OBJECTS,
	TV_OBJ3D_ATMOS1,
	TV_OBJ3D_ATMOS2,
	TV_OBJ3D_TRANSFORMATION,
};
typedef obj3dcat Object3DCategory;




//**************************************
// Classe de base pour les objets 3D
//**************************************
class Object3D {
	#define SENDER ((Object3D*)data)
	friend void sign_entry( GtkWidget *wid, gpointer data ) { SENDER->name_changed(); }
	friend bool sign_entry2( GtkWidget *wid, GdkEvent *ev, gpointer data ) { SENDER->name_changed(); return false; }
	friend void sign_hidden_changed( GtkWidget *wid, gpointer data ) { SENDER->set_visibility_pix(); }
	friend void sign_render_changed( GtkWidget *wid, gpointer data ) { SENDER->set_render_pix(); }	
	#undef SENDER

	protected:
		Object3D *parent;
		ObjectLayer *layer;
		Object3DType type;
		Object3DCategory category;
		int pick_name;
		bool can_be_converted;
		static app_objs *app_ref;
		GlDisplayList list;
		bool update_solid_list, update_wire_list;
		GtkWidget *widget;
		GtkWidget *nm_entry;
		
		static GtkTreeStore *tree_store;
		static GtkWidget *tree_view;
		static GtkTreeSelection *tree_selection;
		GtkTreeIter node_iter;
		GtkTreeIter *parent_node_iter;
		void set_visibility_pix();
		void set_render_pix();

	protected:
		Rolling_box *render_box, *general_box, *transfo_box;
		TvWidget_entry *name;
		TvWidget_bool *hidden;
		TvWidget_bool *render;
		TvWidget_bool *no_shadow;
		TvWidget_bool *hollow;
		TvWidget_bool *inverse;
		TvWidget_bool *no_image;
		TvWidget_bool *no_reflection;
		TvWidget_bool *double_illuminate;
		bool selected;
		GtkWidget *frame, *table;
		GtkWidget *edit_cont;

		void check_name();
		void new_frame( GtkWidget *wid, char *name );
		void new_table( GtkWidget *wid, char *name, int rows );
		void new_table_no_frame( GtkWidget *box, int rows );
		void name_changed();
		
	public:
		Object3D( app_objs *appref );
		Object3D( Object3D & ref );
		virtual ~Object3D();

		virtual Object3D *duplicate_yourself() { return NULL; }
		Object3DType get_type() { return type; }
		Object3DCategory get_category() { return category; }
		char *get_name() { return name->value(); }
		char *get_type_name();
		void get_underscore_name( ofstream & file );
		GtkTreeIter *get_node() { return &node_iter; }
		Object3D *get_parent() { return parent; }
		virtual void set_layer( ObjectLayer *lay ) { layer = lay; }
		ObjectLayer *get_layer() { return layer; }

		virtual void display( glview *view, bool set_color = true );
		void invalidate_list() { list.invalidate(); }
		virtual void set_color();
		virtual void set_point_color();

		virtual void add_to_tree( GtkWidget *view, GtkTreeStore *store, GtkTreeSelection *sel, GtkTreeIter *parent, GtkTreeIter *sibling, const gchar *pixmap = NULL );
		void remove_from_tree() { gtk_tree_store_remove( tree_store, &node_iter );  }
		virtual void save_tree() {};
		void toggle_visibility() { hidden->toggle(); hidden->update_widget(); set_visibility_pix(); }
		void toggle_render() { render->toggle(); render->update_widget(); set_render_pix(); }

		virtual void edit_widget( GtkWidget *wid ) { edit_widget( wid, true ); }
		virtual void edit_widget( GtkWidget *wid, bool solid_object );
		void edit_widget_base( GtkWidget *wid );
		virtual void destroy_editor();
		virtual void pref_changed();
		virtual void flush() {}

		virtual void mouse_drag( struct drag_info *drag ) {}
		virtual void pointer_mode_changed() {}
		virtual void select_param_picked( int name , bool ctrl) {};
		virtual float *get_location() { return NULL; }
		virtual Rotation *get_rotation() { return NULL; }
		virtual float get_strength_radius() { return 1; }
		virtual float get_strength( float x, float y, float z ) { return 0; }
		virtual bool changed() { return false; }
		virtual void unchange() {}

		virtual void output_to_povray_pass1( ofstream & file );
		virtual void output_to_povray_pass2( ofstream & file ) { if ( !render->value() ) return; file << "\n\tobject {"; get_underscore_name( file ); file << "}"; }
		void tree_node_select() { selected = true; gtk_tree_selection_select_iter( tree_selection, &node_iter ); }
		void set_name( char *name );
		void select() { selected = true; /*list.invalidate();*/ }
		virtual void expand_parent() { if ( parent != NULL ) parent->expand_parent(); }
		void unselect();
		virtual void destroy();
		virtual void undo( Object3D *copy ) {}
		virtual void push_undo_item();
		
		virtual void save( ofstream & file ) {}
		virtual void save_basics( ofstream & file );
		virtual bool load( ifstream & file, char *tag ) { return false; }
		virtual bool load_basics( ifstream & file, char *tag );
		void set_load_progress( ifstream & file );
		virtual void get_materials( vector<Material*> & mlist ) {}

		virtual bool is_group() { return false; }
		virtual int get_children_num() { return 0; }
		virtual Object3D* get_children( int i ) { return NULL; }
		void set_parent( Object3D *obj ) { parent = obj; }
		virtual void duplicate_object( Object3D *obj ) {}
		virtual void remove_object( Object3D *obj ) {}
		virtual void paste_object( Object3D *obj ) {}		
		virtual void move_child_up( Object3D *obj ) {}
		virtual void move_child_down( Object3D *obj ) {}
		virtual int get_child_pos( Object3D *obj ) { return -1; }
		virtual void insert_child( Object3D *obj, int position ) {}
		virtual bool has_as_ancester( Object3D *obj )  { return false; }
		
		virtual bool pick_test( int name ) { return ( name == pick_name ) ? true : false; }
		
		void help_on_object();
		
		virtual void transform_points( vector<Vertex*> &pt, bool output = false ) {}
		virtual void apply_transformations() {}
		virtual void delete_polygons() {}
		virtual void tesselate() {}
		virtual void flatten() {}
		virtual void flatten_region() {}
		virtual void select_all_poly() {}
		virtual void unselect_all_poly() {}
		virtual void invert_selection_poly() {}
			
		virtual bool can_convert_to_mesh() { return can_be_converted; }
		virtual void mesh_convert() {}

		// Access methods
		bool is_hidden() { return hidden->value(); }
		bool is_render() { return render->value(); };
		bool is_no_shadow() { return no_shadow->value(); };
		bool is_hollow() { return hollow->value(); };
		bool is_inverse() { return inverse->value(); };
		bool is_no_image() { return no_image->value(); };
		bool is_no_reflection() { return no_reflection->value(); };
		bool is_double_illuminate() { return double_illuminate->value(); };
		bool is_selected() { return selected; }
		
		void set_hidden( bool val ) { hidden->set( val ); hidden->update_widget(); }
		void set_render( bool val ) { render->set( val ); render->update_widget(); }
		void set_no_shadow( bool val ) { no_shadow->set( val ); no_shadow->update_widget(); }
		void set_hollow( bool val ) { hollow->set( val ); hollow->update_widget(); }
		void set_inverse( bool val ) { inverse->set( val ); inverse->update_widget(); }
		void set_no_image( bool val ) { no_image->set( val ); no_image->update_widget(); }
		void set_no_reflection( bool val ) { no_reflection->set( val ); no_reflection->update_widget(); }
		void set_double_illuminate( bool val ) { double_illuminate->set( val ); double_illuminate->update_widget(); }
};

class Object3D_with_material : public Object3D {
	protected:
		TvWidget_matref *texture;
		TvWidget_bool *target, *refraction, *reflection, *collect, *pass_through;
		TvWidget_float *spacing;
		Rolling_box *photon_box;

	public:
		Object3D_with_material( app_objs *appref );
		Object3D_with_material( Object3D_with_material & ref );
		~Object3D_with_material();

		//virtual void flush() { texture->flush(); }
		virtual void set_color();
		virtual void destroy_editor();
		virtual void save_basics( ofstream & file );
		virtual bool load_basics( ifstream & file, char *tag );
		virtual void get_materials( vector<Material*> & mlist ) { texture->get_material( mlist ); }
		void get_texture_widgets( GtkWidget *wid, bool tt );
		virtual void output_to_povray_pass1( ofstream & file );

		// Access methods
		bool is_target() { return target->value(); }
		bool is_refraction() { return refraction->value(); }
		bool is_reflection() { return reflection->value(); }
		bool is_collect() { return collect->value(); }
		bool is_pass_through() { return pass_through->value(); }
		void set_target( bool val ) { target->set( val ); }
		void set_refraction( bool val ) { refraction->set( val ); }
		void set_reflection( bool val ) { reflection->set( val ); }
		void set_collect( bool val ) { collect->set( val ); }
		void set_pass_through( bool val ) { pass_through->set( val ); }
		float get_spacing() { return spacing->value(); }
		void set_spacing( float sp ) { spacing->set( sp ); } 
};

#endif

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us