File: surface.cpp

package info (click to toggle)
ghemical 2.10-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 5,660 kB
  • ctags: 2,106
  • sloc: cpp: 17,100; sh: 8,840; makefile: 184
file content (656 lines) | stat: -rw-r--r-- 17,221 bytes parent folder | download
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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
// SURFACE.CPP

// Copyright (C) 1998 Tommi Hassinen.

// This program is free software; you can redistribute it and/or modify it
// under the terms of the license (GNU GPL) which comes with this package.

/*################################################################################################*/

#include "surface.h"	// config.h is here -> we get ENABLE-macros here...

#include "project.h"
#include "appdefine.h"

#include <deque>
#include <sstream>
using namespace std;

/*################################################################################################*/

color_surface::color_surface(cs_param & p1)
{
	prj = p1.prj;
	data = p1.data;
	
	my_glname = p1.my_glname;
	
	transparent = p1.transparent;
	automatic_cv2 = p1.automatic_cv2;
	wireframe = p1.wireframe;
	
	for (i32s n1 = 0;n1 < 3;n1++)
	{
		np[n1] = p1.np[n1];
		dist[n1] = new fGL[np[n1]];
	}
	
	ref = p1.ref;
	GetSurfaceValue = p1.vf1;
	GetColorValue = p1.vf2;
	GetColor = p1.cf;
	
	svalue = p1.svalue;
	cvalue1 = p1.cvalue1;
	cvalue2 = p1.cvalue2;
	alpha = p1.alpha;
	
	tolerance = p1.toler;
	max_cycles = p1.maxc;
	
	grid = vector<bool>(np[0] * np[1] * np[2]);
	
	SetDimension(p1.dim);
	Update();
}

color_surface::~color_surface(void)
{
	if (transparent) prj->RemoveAllTPs((void *) this);
	
	delete[] dist[0];
	delete[] dist[1];
	delete[] dist[2];
}

void color_surface::Update(void)
{
	xdir = data->ydir.vpr(data->zdir);
	
	vdata.resize(0);
	tdata.resize(0);
	ldata.resize(0);
	
	prj->PrintToLog("evaluating grid");
	for (i32s n1 = 0;n1 < np[0];n1++)
	{
		prj->PrintToLog("*");	// slow to update???
		
		for (i32s n2 = 0;n2 < np[1];n2++)
		{
			for (i32s n3 = 0;n3 < np[2];n3++)
			{
				i32s tmp1[3] = { n1, n2, n3 }; fGL tmp2[3]; GetCRD(tmp1, tmp2);
				grid[n1 * np[1] * np[2] + n2 * np[2] + n3] = (GetSurfaceValue(ref, tmp2, NULL) < svalue);
			}
		}
	}
	
	prj->PrintToLog(" done\n");
	
	avrg = 0.0; acnt = 0;
	for (i32s n1 = 0;n1 < 3;n1++)
	{
		i32s tmp1[2]; i32s tmp2[2] = { 0, 0 };
		prj->PrintToLog("interpolating in ");
		switch (n1)
		{
			case 0:
			tmp1[0] = 1; tmp1[1] = 2;
			prj->PrintToLog("x");
			break;
			
			case 1:
			tmp1[0] = 2; tmp1[1] = 0;
			prj->PrintToLog("y");
			break;
			
			case 2:
			tmp1[0] = 0; tmp1[1] = 1;
			prj->PrintToLog("z");
			break;
		}
		
		prj->PrintToLog("-direction... ");
		
		range[n1][0] = vdata.size();
		Interpolate(n1, tmp1, tmp2);
		range[n1][1] = vdata.size();
		
		ostringstream str1;
		str1 << tmp2[0] << " points, " << tmp2[1] << " cycles" << endl << ends;
		prj->PrintToLog(str1.str().c_str());
	}
	
	if (automatic_cv2)
	{
		// AUTO makes only partial correction -> just looks better and one can estimate the "bias".
		// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
		
		cvalue2 = -0.80 * avrg / (f64) acnt;
	}
	
	for (i32u n1 = 0;n1 < vdata.size();n1++)
	{
		GetColor((vdata[n1].cvalue + cvalue2) / cvalue1, alpha, vdata[n1].color);
	}
	
	prj->PrintToLog("generating image... ");
	
	for (i32s n1 = 0;n1 < np[0] - 1;n1++)
	{
		for (i32s n2 = 0;n2 < np[1] - 1;n2++)
		{
			for (i32s n3 = 0;n3 < np[2] - 1;n3++)
			{
				vector<cs_line> line_vector;
				
				for (i32s n4 = 0;n4 < 2;n4++)
				{
					for (i32s n5 = 0;n5 < 2;n5++)
					{
						for (i32s n6 = 0;n6 < 2;n6++)
						{
							i32s id1[4];
							id1[0] = (n1 + n4) * np[1] * np[2] + (n2 + n5) * np[2] + (n3 + n6);
							id1[1] = (n1 + !n4) * np[1] * np[2] + (n2 + n5) * np[2] + (n3 + n6);
							id1[2] = (n1 + n4) * np[1] * np[2] + (n2 + !n5) * np[2] + (n3 + n6);
							id1[3] = (n1 + n4) * np[1] * np[2] + (n2 + n5) * np[2] + (n3 + !n6);
							
							i32s id2[3] = { NOT_DEFINED, NOT_DEFINED, NOT_DEFINED };
							
							for (i32s n7 = 0;n7 < 3;n7++)
							{
								if (grid[id1[0]] != grid[id1[n7 + 1]])
								{
					i32s tmp1 = min(id1[0], id1[n7 + 1]); id2[n7] = range[n7][0];
					while (id2[n7] < range[n7][1] && vdata[id2[n7]].id != tmp1) id2[n7]++;
					if (id2[n7] == range[n7][1]) cout << "color_surface problem #1" << endl;
								}
							}
							
							for (i32s n7 = 0;n7 < 3;n7++)
							{
								cs_line newline;
								newline.index[0] = id2[n7];
								newline.index[1] = id2[(n7 + 1) % 3];
								newline.Arrange();
								
								if (newline.index[0] < 0) continue;
								if (newline.index[1] < 0) continue;
								
								line_vector.push_back(newline);
							}
						}
					}
				}
				
				for (i32s n4 = 0;n4 < 3;n4++)
				{
					i32s id1a[4]; i32s id1b[4];
					i32s tmp1[2] = { (n4 + 1) % 3, (n4 + 2) % 3 };
					
					i32s t1a[3] = { n1, n2, n3 };
					id1a[0] = t1a[0] * np[1] * np[2] + t1a[1] * np[2] + t1a[2];
					i32s t2a[3] = { n1, n2, n3 }; t2a[tmp1[0]]++;
					id1a[1] = t2a[0] * np[1] * np[2] + t2a[1] * np[2] + t2a[2];
					i32s t3a[3] = { n1, n2, n3 }; t3a[tmp1[0]]++; t3a[tmp1[1]]++;
					id1a[2] = t3a[0] * np[1] * np[2] + t3a[1] * np[2] + t3a[2];
					i32s t4a[3] = { n1, n2, n3 }; t4a[tmp1[1]]++;
					id1a[3] = t4a[0] * np[1] * np[2] + t4a[1] * np[2] + t4a[2];
					
					i32s t1b[3] = { n1, n2, n3 }; t1b[n4]++;
					id1b[0] = t1b[0] * np[1] * np[2] + t1b[1] * np[2] + t1b[2];
					i32s t2b[3] = { n1, n2, n3 }; t2b[n4]++; t2b[tmp1[0]]++;
					id1b[1] = t2b[0] * np[1] * np[2] + t2b[1] * np[2] + t2b[2];
					i32s t3b[3] = { n1, n2, n3 }; t3b[n4]++; t3b[tmp1[0]]++; t3b[tmp1[1]]++;
					id1b[2] = t3b[0] * np[1] * np[2] + t3b[1] * np[2] + t3b[2];
					i32s t4b[3] = { n1, n2, n3 }; t4b[n4]++; t4b[tmp1[1]]++;
					id1b[3] = t4b[0] * np[1] * np[2] + t4b[1] * np[2] + t4b[2];
					
					i32s id2[4] = { NOT_DEFINED, NOT_DEFINED, NOT_DEFINED, NOT_DEFINED };
					
					for (i32s n5 = 0;n5 < 4;n5++)
					{
						if (grid[id1a[n5]] != grid[id1b[n5]])
						{
			id2[n5] = range[n4][0]; while (id2[n5] < range[n4][1] && vdata[id2[n5]].id != id1a[n5]) id2[n5]++;
			if (id2[n5] == range[n4][1]) cout << "color_surface problem #2" << endl;
						}
					}
					
					for (i32s n5 = 0;n5 < 4;n5++)
					{
						cs_line newline;
						newline.index[0] = id2[n5];
						newline.index[1] = id2[(n5 + 1) % 4];
						newline.Arrange();
						
						if (newline.index[0] < 0) continue;
						if (newline.index[1] < 0) continue;
						
						line_vector.push_back(newline);
					}
				}
				
				ldata.insert(ldata.end(), line_vector.begin(), line_vector.end());
								
				while (!line_vector.empty())
				{
					deque<i32s> polygon;
					
					polygon.push_front(line_vector.back().index[0]);
					polygon.push_back(line_vector.back().index[1]);
					line_vector.pop_back();
					
					i32s counter = 0;
					while (counter < (i32s) line_vector.size())
					{
						for (i32s dir = 0;dir < 2;dir++)
						{
							if (line_vector[counter].index[dir] == polygon.front())
							{
								polygon.push_front(line_vector[counter].index[!dir]);
								line_vector.erase(line_vector.begin() + counter);
								counter = -1; break;
							}
							
							if (line_vector[counter].index[dir] == polygon.back())
							{
								polygon.push_back(line_vector[counter].index[!dir]);
								line_vector.erase(line_vector.begin() + counter);
								counter = -1; break;
							}
						}
						
						counter++;
					}
					
					for (i32s n4 = 1;n4 < ((i32s) polygon.size()) - 2;n4++)
					{
						cs_triangle newtriangle;
						newtriangle.index[0] = polygon[0];
						newtriangle.index[1] = polygon[n4];
						newtriangle.index[2] = polygon[n4 + 1];
						
						if (newtriangle.index[0] == newtriangle.index[1]) cout << "E";
						if (newtriangle.index[0] == newtriangle.index[2]) cout << "E";
						if (newtriangle.index[1] == newtriangle.index[2]) cout << "E";
						tdata.push_back(newtriangle);
					}
				}
			}
		}
	}
	
	// there are some duplicated lines -> make unique !!!
	// there are some duplicated lines -> make unique !!!
	// there are some duplicated lines -> make unique !!!
	
	sort(ldata.begin(), ldata.end());
	vector<cs_line>::iterator it1 = unique(ldata.begin(), ldata.end());
	if (it1 != ldata.end()) ldata.erase(it1, ldata.end());
	
	// check the counterclockwise winding of triangles !!!
	// check the counterclockwise winding of triangles !!!
	// check the counterclockwise winding of triangles !!!
	
	for (i32s n1 = 0;n1 < (i32s) tdata.size();n1++)
	{
		v3d<fGL> nv1 = v3d<fGL>(vdata[tdata[n1].index[0]].normal);
		v3d<fGL> nv2 = v3d<fGL>(vdata[tdata[n1].index[1]].normal);
		v3d<fGL> nv3 = v3d<fGL>(vdata[tdata[n1].index[2]].normal);
		
		v3d<fGL> v1 = nv1 + nv2; v1 = v1 + nv3;
		v3d<fGL> v2 = v3d<fGL>(vdata[tdata[n1].index[0]].crd, vdata[tdata[n1].index[1]].crd);
		v3d<fGL> v3 = v3d<fGL>(vdata[tdata[n1].index[1]].crd, vdata[tdata[n1].index[2]].crd);
		bool flag = !(v1.tor(v2, v3) < 0.0);
		
		if (flag)
		{
			i32s tmp1 = tdata[n1].index[0];
			tdata[n1].index[0] = tdata[n1].index[1];
			tdata[n1].index[1] = tmp1;
		}
	}
	
	ostringstream str1;
	str1 << ldata.size() << " lines, " << tdata.size() << " triangles." << endl << ends;
	prj->PrintToLog(str1.str().c_str());
	
	// add/update the primitives, if this is a transparent object...
	// add/update the primitives, if this is a transparent object...
	// add/update the primitives, if this is a transparent object...
	
	if (transparent && !wireframe)
	{
		prj->RemoveAllTPs((void *) this);
		
		for (i32s n1 = 0;n1 < (i32s) tdata.size();n1++)
		{
			fGL * c1 = vdata[tdata[n1].index[0]].color;
			fGL * p1 = vdata[tdata[n1].index[0]].crd;
			
			fGL * c2 = vdata[tdata[n1].index[1]].color;
			fGL * p2 = vdata[tdata[n1].index[1]].crd;
			
			fGL * c3 = vdata[tdata[n1].index[2]].color;
			fGL * p3 = vdata[tdata[n1].index[2]].crd;
			
			tpd_tri_3c * tmp4;
			tmp4 = new tpd_tri_3c(c1, p1, c2, p2, c3, p3);
			
			transparent_primitive * tmp5;
			tmp5 = new transparent_primitive((void *) this, * tmp4);
			
			prj->AddTP((void *) this, (* tmp5));
			
			// tmp4, the tpd_tri_3c-object, will be deleted when
			// prj->RemoveAllTPs() is called for this object...
			
			delete tmp5;
		}
	}
}

void color_surface::Render(void)
{
	glPushName(GLNAME_OBJECT);
	glPushName(my_glname);
	
	if (wireframe)
	{
		glBegin(GL_LINES);
		for (i32s n1 = 0;n1 < (i32s) ldata.size();n1++)
		{
			i32s ind1 = ldata[n1].index[0]; i32s ind2 = ldata[n1].index[1];
			glColor3fv(vdata[ind1].color); glVertex3fv(vdata[ind1].crd);
			glColor3fv(vdata[ind2].color); glVertex3fv(vdata[ind2].crd);
		}
		
		glEnd();	// GL_LINES
	}
	else if (!transparent)
	{
		glEnable(GL_LIGHTING);
		glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, true);
		
		glBegin(GL_TRIANGLES);
		for (i32s n1 = 0;n1 < (i32s) tdata.size();n1++)
		{
			vdata[tdata[n1].index[0]].Render(true);		// aina TRUE!??!?!?!
			vdata[tdata[n1].index[1]].Render(true);
			vdata[tdata[n1].index[2]].Render(true);
		}
		
		glEnd();	// GL_TRIANGLES
		
		glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, false);
		glDisable(GL_LIGHTING);
	}
	
	glPopName();
	glPopName();
}

void color_surface::SetDimension(fGL * p1)
{
	for (i32s n1 = 0;n1 < 3;n1++)
	{
		dim[n1] = p1[n1];
		fGL tmp1 = np[n1] - 1;
		
		for (i32s n2 = 0;n2 < np[n1];n2++)
		{
			fGL tmp2 = (fGL) n2 / tmp1;
			dist[n1][n2] = dim[n1] * (tmp2 - 0.5);
		}
	}
}

void color_surface::GetCRD(i32s * p1, fGL * p2)
{
	for (i32s n1 = 0;n1 < 3;n1++)
	{
		fGL tmp1 = xdir[n1] * dist[0][p1[0]];
		fGL tmp2 = data->ydir[n1] * dist[1][p1[1]];
		fGL tmp3 = data->zdir[n1] * dist[2][p1[2]];
		p2[n1] = data->crd[n1] + tmp1 + tmp2 + tmp3;
	}
}

void color_surface::Interpolate(i32s p1, i32s * p2, i32s * p3)
{
	i32s tmp1[3]; i32s tmp2[3];
	for (i32s n1 = 0;n1 < np[p2[0]];n1++)
	{
		tmp1[p2[0]] = tmp2[p2[0]] = n1;
		
		for (i32s n2 = 0;n2 < np[p2[1]];n2++)
		{
			tmp1[p2[1]] = tmp2[p2[1]] = n2;
			
			for (i32s n3 = 0;n3 < np[p1] - 1;n3++)
			{
				tmp1[p1] = n3; tmp2[p1] = n3 + 1;
				bool test1 = grid[tmp1[0] * np[1] * np[2] + tmp1[1] * np[2] + tmp1[2]];
				bool test2 = grid[tmp2[0] * np[1] * np[2] + tmp2[1] * np[2] + tmp2[2]];
				if (test1 == test2) continue;
				
				fGL tmp3a[3]; GetCRD(tmp1, tmp3a);
				fGL tmp3b[3]; GetCRD(tmp2, tmp3b);
				
				v3d<fGL> tmpv1 = v3d<fGL>(tmp3a);
				v3d<fGL> tmpv2 = v3d<fGL>(tmp3a, tmp3b);
				
				v3d<fGL> tmpv3;
				
				fGL tmp4[2]; tmp4[0] = 0.0; tmpv3 = tmpv1 + (tmpv2 * tmp4[0]);
				tmp4[1] = GetSurfaceValue(ref, tmpv3.data, NULL) - svalue;
				
				fGL tmp5[2]; tmp5[0] = 1.0; tmpv3 = tmpv1 + (tmpv2 * tmp5[0]);
				tmp5[1] = GetSurfaceValue(ref, tmpv3.data, NULL) - svalue;
				
				// this is a "regula falsi"-type search...
				
				fGL tmp6 = 0.0; i32s tmp7 = 0;
				while (tmp7++ < max_cycles)
				{
					fGL tmp8 = tmp5[0] - tmp5[1] * (tmp5[0] - tmp4[0]) / (tmp5[1] - tmp4[1]);
					
					tmpv3 = tmpv1 + (tmpv2 * tmp8);
					tmp6 = GetSurfaceValue(ref, tmpv3.data, NULL) - svalue;
					
					if ((tmp6 < 0.0) ^ (tmp4[1] < 0.0))
					{
						tmp5[0] = tmp8;
						tmp5[1] = tmp6;
					}
					else
					{
						tmp4[0] = tmp8;
						tmp4[1] = tmp6;
					}
					
					if (fabs(tmp4[1]) < fabs(tmp5[1]))
					{
						tmp6 = tmp4[0];
						tmp8 = fabs(tmp4[1]);
					}
					else
					{
						tmp6 = tmp5[0];
						tmp8 = fabs(tmp5[1]);
					}
					
					if (tmp8 < tolerance) break;
					else p3[1]++;
				}
				
				cs_vertex vertex; tmpv3 = tmpv1 + (tmpv2 * tmp6);
				vertex.cvalue = GetColorValue(ref, tmpv3.data, NULL);
				
				if (automatic_cv2)
				{
					avrg += vertex.cvalue;
					acnt++;
				}
				
				fGL tmp9[4];
				
				if (!wireframe)
				{
					tmp9[3] = 0.0; GetSurfaceValue(ref, tmpv3.data, tmp9);
					for (i32s n4 = 0;n4 < 3;n4++) tmp9[3] += tmp9[n4] * tmp9[n4];
					tmp9[3] = sqrt(tmp9[3]);
				}
				
				for (i32s n4 = 0;n4 < 3;n4++)
				{
					vertex.crd[n4] = tmpv3[n4];
					if (!wireframe) vertex.normal[n4] = tmp9[n4] / tmp9[3];
				}
				
				vertex.id = (tmp1[0] * np[1] * np[2] + tmp1[1] * np[2] + tmp1[2]);
				vdata.push_back(vertex); p3[0]++;
			}
		}
	}
}

/*################################################################################################*/

color_surface_object::color_surface_object(const object_location & p1, cs_param & p2, const char * p3) : smart_object(p1)
{
	transform_in_progress = false;
	
	dim[0] = p2.dim[0];	// now we have several copies
	dim[1] = p2.dim[1];	// of dimension, but it should
	dim[2] = p2.dim[2];	// be the same everywhere...
	
	cs_param * param = & p2;
	
	while (true)
	{
		param->data = GetLocData();
		param->my_glname = p2.prj->RegisterGLName((dummy_object *) this);
		
		cs_vector.push_back(new color_surface(* param));
		
		if (param->next != NULL) param = param->next;
		else break;
	}
	
	ostringstream str;
	str << p3 << "surface" << ends;
	
	copy_of_ref = p2.ref;
	
	object_name = new char[strlen(str.str().c_str()) + 1];
	strcpy(object_name, str.str().c_str());
}

color_surface_object::~color_surface_object(void)
{
	for (i32u n1 = 0;n1 < cs_vector.size();n1++)
	{
		delete cs_vector[n1];
	}
	
	delete[] object_name;
}

bool color_surface_object::BeginTransformation(void)
{
	transform_in_progress = true;
	return true;
}

bool color_surface_object::EndTransformation(void)
{
	transform_in_progress = false;
	
	Update();	// update the surfaces!!!!!
	
	return true;
}

void color_surface_object::OrbitObject(const fGL * p1, const camera & p2)
{
	dummy_object::RotateObject(p1, p2);
}

void color_surface_object::RotateObject(const fGL * p1, const camera & p2)
{
	dummy_object::OrbitObject(p1, p2);
}

void color_surface_object::TranslateObject(const fGL * p1, const obj_loc_data * p2)
{
	fGL tmp1[3] = { p1[0], p1[1], p1[2] };
	
	if (p2 == GetLocData())
	{
		tmp1[0] = -tmp1[0];
		tmp1[2] = -tmp1[2];
	}
	
	dummy_object::TranslateObject(tmp1, p2);
}

void color_surface_object::Render(void)
{
	if (transform_in_progress)
	{
		glPushMatrix(); SetModelView();
		fGL dx[2]; dx[0] = dim[0] / 2.0; dx[1] = -dx[0];
		fGL dy[2]; dy[0] = dim[1] / 2.0; dy[1] = -dy[0];
		fGL dz[2]; dz[0] = dim[2] / 2.0; dz[1] = -dz[0];
		
		glBegin(GL_LINES);
		
		glColor3f(0.0, 0.0, 1.0);
		
		glVertex3f(dx[0], dy[0], dz[0]); glVertex3f(dx[1], dy[0], dz[0]);
		glVertex3f(dx[0], dy[1], dz[0]); glVertex3f(dx[1], dy[1], dz[0]);
		glVertex3f(dx[0], dy[1], dz[1]); glVertex3f(dx[1], dy[1], dz[1]);
		glVertex3f(dx[0], dy[0], dz[1]); glVertex3f(dx[1], dy[0], dz[1]);
		
		glVertex3f(dx[0], dy[0], dz[0]); glVertex3f(dx[0], dy[1], dz[0]);
		glVertex3f(dx[1], dy[0], dz[0]); glVertex3f(dx[1], dy[1], dz[0]);
		glVertex3f(dx[1], dy[0], dz[1]); glVertex3f(dx[1], dy[1], dz[1]);
		glVertex3f(dx[0], dy[0], dz[1]); glVertex3f(dx[0], dy[1], dz[1]);
		
		glVertex3f(dx[0], dy[0], dz[0]); glVertex3f(dx[0], dy[0], dz[1]);
		glVertex3f(dx[1], dy[0], dz[0]); glVertex3f(dx[1], dy[0], dz[1]);
		glVertex3f(dx[1], dy[1], dz[0]); glVertex3f(dx[1], dy[1], dz[1]);
		glVertex3f(dx[0], dy[1], dz[0]); glVertex3f(dx[0], dy[1], dz[1]);
		
		glColor3f(1.0, 1.0, 1.0);
		
		glVertex3f(dx[0] / 2.0, 0.0, 0.0); glVertex3f(dx[1] / 2.0, 0.0, 0.0);
		glVertex3f(0.0, dy[0] / 2.0, 0.0); glVertex3f(0.0, dy[1] / 2.0, 0.0);
		glVertex3f(0.0, 0.0, dz[0] / 2.0); glVertex3f(0.0, 0.0, dz[1] / 2.0);
		
		glEnd(); glPopMatrix();
	}
	else
	{
		for (i32u n1 = 0;n1 < cs_vector.size();n1++)
		{
			cs_vector[n1]->Render();
		}
	}
}

void color_surface_object::Update(void)
{
	for (i32u n1 = 0;n1 < cs_vector.size();n1++)
	{
		cs_vector[n1]->Update();
	}
}

/*################################################################################################*/

// eof