-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathObject_Log.cxx
More file actions
3530 lines (3075 loc) · 75.6 KB
/
Object_Log.cxx
File metadata and controls
3530 lines (3075 loc) · 75.6 KB
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
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "Object_Log.h"
#include <vtkAppendPolyData.h>
void OBJECT_LOG::Object_Move_Down()
{
// Objects are in the following order :
// A
// B * is the object we move down
// C
// D
OBJECT_MESH * LastOBJ =NULL;
OBJECT_MESH * NewFirst =NULL;
OBJECT_MESH * A =NULL; // the non changing preceding object
OBJECT_MESH * B =NULL; // the object we move down
OBJECT_MESH * C =NULL; // the old next object (the one we switch with B)
OBJECT_MESH * D =NULL; // the non changing object after C.
if (this->OBJECTS!=NULL)
{
LastOBJ = this->OBJECTS;
//CurrOBJ = this->OBJECTS;
while(LastOBJ->nextobj !=NULL)
{
LastOBJ = LastOBJ->nextobj;
//CurrOBJ =CurrOBJ->nextobj
}
B = LastOBJ;
NewFirst=LastOBJ;
// Maintenant on remonte dans la liste
while(B!= NULL)
{
A = NULL;
A = B->prevobj;
C = NULL;
C = B->nextobj;
D = NULL;
if (C != NULL && C->nextobj !=NULL)
{
D = C->nextobj;
}
if( B->selected ==1)
{
if (C!=NULL && C->selected ==0)
{
if (A !=NULL)
{
A->nextobj =C;
}
B->prevobj = C;
B->nextobj = D;
C->prevobj = A;
C->nextobj = B;
if (D !=NULL)
{
D->prevobj = B;
}
}
}
if (A !=NULL) {NewFirst=A;}
else
{
if (B->prevobj !=NULL){NewFirst=B->prevobj;}
}
B = A; // we proceed backward
}
this->OBJECTS = NewFirst;
if (this->OBJECTS!=NULL)
{
LastOBJ = this->OBJECTS;
//CurrOBJ = this->OBJECTS;
LastOBJ->selected =0;
while(LastOBJ->nextobj !=NULL)
{
LastOBJ = LastOBJ->nextobj;
LastOBJ->selected =0;
//CurrOBJ =CurrOBJ->nextobj
}
}
//this->OBJECTS->Object_Move_Down();
}
}
void OBJECT_LOG::Update_RGB()
{
if (this->OBJECTS !=NULL)
{
OBJECT_MESH * MyOBJ =this->OBJECTS;
while(MyOBJ!= NULL)
{
MyOBJ->Update_RGB();
MyOBJ = MyOBJ->nextobj;
}
}
}
void OBJECT_LOG::Object_Move_Up()
{
OBJECT_MESH * LastOBJ =NULL;
OBJECT_MESH * NewFirst =NULL;
OBJECT_MESH * A =NULL; // the non changing preceding object
OBJECT_MESH * B =NULL; // the one (the one we switch with C)
OBJECT_MESH * C =NULL; // the object we move up
OBJECT_MESH * D =NULL; // the non changing object after C.
if (this->OBJECTS !=NULL)
{
C = this->OBJECTS;
NewFirst =this->OBJECTS;
if (C->nextobj != NULL && C->selected ==0 && C->nextobj->selected ==1)
{NewFirst=C->nextobj;}
// Maintenant on descend dans la liste
while(C!= NULL)
{
B = NULL;
B = C->prevobj;
A = NULL;
if (B !=NULL)
{A = B->prevobj;}
D = NULL;
D = C->nextobj;
if( C->selected ==1)
{
if (B!=NULL && B->selected ==0)
{
if (A !=NULL)
{A->nextobj =C;}
B->prevobj = C;
B->nextobj = D;
C->prevobj = A;
C->nextobj = B;
if (D !=NULL)
{
D->prevobj = B;
}
}
}
C = D; // we proceed onward
}
this->OBJECTS = NewFirst;
if (this->OBJECTS!=NULL)
{
LastOBJ = this->OBJECTS;
//CurrOBJ = this->OBJECTS;
LastOBJ->selected =0;
while(LastOBJ->nextobj !=NULL)
{
LastOBJ = LastOBJ->nextobj;
LastOBJ->selected =0;
//CurrOBJ =CurrOBJ->nextobj
}
}
}
}
void OBJECT_LOG::Landmark_Move_Down(int mode, int landmark_mode)
{
// mode = 0 : user landmark move up (more than one can be selected
// mode = 0 is followed by a renumbering of landmark indices
// mode = 1 : called by "Reorder_Landmarks" :
// mode = 1 is not followed by a change of landmark indices...
OBJECT_LANDMARK * LastOBJ =NULL;
OBJECT_LANDMARK * NewFirst =NULL;
OBJECT_LANDMARK * A =NULL; // the non changing preceding object
OBJECT_LANDMARK * B =NULL; // the object we move down
OBJECT_LANDMARK * C =NULL; // the old next object (the one we switch with B)
OBJECT_LANDMARK * D =NULL; // the non changing object after C.
if (landmark_mode ==0)
{
LastOBJ =this->OBJECTS_LANDMARK;
}
else if (landmark_mode==1)
{
LastOBJ =this->OBJECTS_LANDMARK_TARGET;
}
else
{
LastOBJ =this->OBJECTS_LANDMARK_LABELS;
}
if (LastOBJ !=NULL)
{
while(LastOBJ->nextobj !=NULL)
{
LastOBJ = LastOBJ->nextobj;
}
B = LastOBJ;
NewFirst=LastOBJ;
// Maintenant on remonte dans la liste
while(B!= NULL)
{
A = NULL;
A = B->prevobj;
C = NULL;
C = B->nextobj;
D = NULL;
if (C != NULL && C->nextobj !=NULL)
{
D = C->nextobj;
}
if( B->selected ==1)
{
if (C!=NULL && C->selected ==0)
{
if (A !=NULL)
{
A->nextobj =C;
}
B->prevobj = C;
B->nextobj = D;
C->prevobj = A;
C->nextobj = B;
if (D !=NULL)
{
D->prevobj = B;
}
}
}
if (A !=NULL) {NewFirst=A;}
else
{
if (B->prevobj !=NULL){NewFirst=B->prevobj;}
}
B = A; // we proceed backward
}
if (landmark_mode ==0)
{
this->OBJECTS_LANDMARK = NewFirst;
}
else if (landmark_mode==1)
{
this->OBJECTS_LANDMARK_TARGET= NewFirst;
}
else
{
this->OBJECTS_LANDMARK_LABELS= NewFirst;
}
if (NewFirst!=NULL)
{
//CurrOBJ = this->OBJECTS;
NewFirst->selected =0;
while(NewFirst->nextobj !=NULL)
{
NewFirst = NewFirst->nextobj;
NewFirst->selected =0;
//CurrOBJ =CurrOBJ->nextobj
}
}
if (mode==0)
{
Change_Landmark_Indices(landmark_mode);
}
}
}
void OBJECT_LOG::Change_Landmark_Indices(int landmark_mode)
{
// Si les landmarks sont dans l'ordre 1 2 5 6 7 3 4, les indices deviennent
// 1 2 3 4 5 6 7 sans que les objets soient réordonnés.
int num_landmarks = this->Get_Landmark_Number(landmark_mode);
/* std::cout << "There are " <<num_landmarks
<< " Landmarks" << std::endl;*/
if (num_landmarks>0)
{
int *ordered_indices;
ordered_indices = new int [num_landmarks];
OBJECT_LANDMARK * MyLM = this->LandmarkAfter(0,landmark_mode);
int i;
for (i=0; i<num_landmarks;i++)
{
ordered_indices[i]= MyLM->landmark_index;
/*std::cout << "i= " <<i
<< std::endl;
std::cout << "ordered_indices[i]= " <<ordered_indices[i]
<< std::endl;*/
MyLM = this->LandmarkAfter(ordered_indices[i], landmark_mode);
}
int ok =0;
if (landmark_mode ==0)
{
MyLM = this->OBJECTS_LANDMARK;
}
else if (landmark_mode ==1)
{
MyLM = this->OBJECTS_LANDMARK_TARGET;
}
else
{
MyLM = this->OBJECTS_LANDMARK_LABELS;
}
int cpt=0;
while (MyLM!=NULL && cpt<num_landmarks)
{
MyLM->landmark_index= ordered_indices[cpt];
/*std::cout << "cpt=" <<cpt
<< std::endl;
std::cout << "ordered_indices[cpt]= " <<ordered_indices[cpt]
<< std::endl;*/
cpt++;
MyLM = MyLM->nextobj;
}
}
}
void OBJECT_LOG::Unselect_landmarks(int landmark_mode)
{
OBJECT_LANDMARK *MyLM =NULL;
if (landmark_mode ==0)
{
MyLM =this->OBJECTS_LANDMARK;
}
else if (landmark_mode ==1)
{
MyLM =this->OBJECTS_LANDMARK_TARGET;
}
else
{
MyLM =this->OBJECTS_LANDMARK_LABELS;
}
if (MyLM !=NULL)
{
while (MyLM !=NULL)
{
MyLM->selected=0;
MyLM = MyLM->nextobj;
}
}
}
void OBJECT_LOG::Reorder_Landmarks(int landmark_mode)
{
// Cela réordonne les objets landmarks selon leur indice (sans changer l'indice à attribuer à chaque landmark).
// Cela appelle "Landmark_Move_Up (1, X)"
// Le premier paramètre est à 1 pour éviter
// Cette fonction n'est appelée que lorsqu'on a placé un nouveau landmark.
//on déselectionne tout.
int ok =0;
this->Unselect_landmarks(landmark_mode);
OBJECT_LANDMARK *MyLM =NULL;
while (ok ==0)
{
ok = Is_Landmark_List_In_Ascending_Order(landmark_mode);
/*std::cout << "Ok = " <<ok
<< std::endl;*/
int last_indice=0;
if (ok ==0)
{
if (landmark_mode ==0)
{
MyLM =this->OBJECTS_LANDMARK;
}
else if (landmark_mode ==1)
{
MyLM =this->OBJECTS_LANDMARK_TARGET;
}
else
{
MyLM =this->OBJECTS_LANDMARK_LABELS;
}
if (MyLM!=NULL)
{
while (MyLM !=NULL)
{
if (MyLM->landmark_index < last_indice)
{
MyLM->selected =1;
/*std::cout << "MyLM = " <<MyLM->landmark_index<< " move up"
<< std::endl;*/
Landmark_Move_Up(1, landmark_mode); // Function moves only selected landmarks.
MyLM->selected =0;
MyLM=NULL;
}
else
{
last_indice=MyLM->landmark_index;
MyLM=MyLM->nextobj;
}
}
}
}
}
}
int OBJECT_LOG::Is_Landmark_List_In_Ascending_Order(int landmark_mode)
{
// Cela dit si la liste des objets "Landmarks" est bien ordonnée en ordre ascendant.
// Returning 0 means there is at least 1 lm in bad order.
int ok =1;
OBJECT_LANDMARK *MyLM =NULL;
int last_indice =0;
if (landmark_mode ==0)
{
MyLM =this->OBJECTS_LANDMARK;
}
else if (landmark_mode ==1)
{
MyLM =this->OBJECTS_LANDMARK_TARGET;
}
else
{
MyLM =this->OBJECTS_LANDMARK_LABELS;
}
if (MyLM !=NULL)
{
while (MyLM !=NULL)
{
if (MyLM->landmark_index < last_indice)
{ok=0;}
last_indice=MyLM->landmark_index;
MyLM=MyLM->nextobj;
}
}
/*std::cout << "is_landmark_list_in... = " <<ok
<< std::endl;*/
return ok;
}
void OBJECT_LOG::Landmark_Move_Up(int mode, int landmark_mode)
{
// mode = 0 : user landmark move up (more than one can be selected
// mode = 0 is followed by a renumbering of landmark indices
// mode = 1 : called by "Reorder_Landmarks" (only one landmark is selected):
// mode = 1 is not followed by a change of landmark indices...
OBJECT_LANDMARK * LastOBJ =NULL;
OBJECT_LANDMARK * NewFirst =NULL;
OBJECT_LANDMARK * A =NULL; // the non changing preceding object
OBJECT_LANDMARK * B =NULL; // the one (the one we switch with C)
OBJECT_LANDMARK * C =NULL; // the object we move up
OBJECT_LANDMARK * D =NULL; // the non changing object after C.
if (landmark_mode ==0)
{
NewFirst =this->OBJECTS_LANDMARK;
}
else if (landmark_mode ==1)
{
NewFirst =this->OBJECTS_LANDMARK_TARGET;
}
else
{
NewFirst =this->OBJECTS_LANDMARK_LABELS;
}
if (NewFirst !=NULL)
{
//this->OBJECTS_LANDMARKS->Landmark_Move_Up();
C = NewFirst;
if (C->nextobj != NULL && C->selected ==0 && C->nextobj->selected ==1)
{NewFirst=C->nextobj;}
// Maintenant on descend dans la liste
while(C!= NULL)
{
B = NULL;
B = C->prevobj;
A = NULL;
if (B !=NULL)
{A = B->prevobj;}
D = NULL;
D = C->nextobj;
if( C->selected ==1)
{
if (B!=NULL && B->selected ==0)
{
if (A !=NULL)
{A->nextobj =C;}
B->prevobj = C;
B->nextobj = D;
C->prevobj = A;
C->nextobj = B;
if (D !=NULL)
{
D->prevobj = B;
}
}
}
C = D; // we proceed onward
}
if (landmark_mode ==0)
{
this->OBJECTS_LANDMARK = NewFirst;
}
else if (landmark_mode ==1)
{
this->OBJECTS_LANDMARK_TARGET= NewFirst;
}
else
{ this->OBJECTS_LANDMARK_LABELS= NewFirst;}
if (NewFirst!=NULL)
{
//CurrOBJ = this->OBJECTS;
NewFirst->selected =0;
while(NewFirst->nextobj !=NULL)
{
NewFirst = NewFirst->nextobj;
NewFirst->selected =0;
//CurrOBJ =CurrOBJ->nextobj
}
}
if (mode==0)
{
Change_Landmark_Indices(landmark_mode);
}
}
}
void OBJECT_LOG::Mesh_init_Mat()
{
Mat2[0][0]= 1;
Mat2[1][1]= 1;
Mat2[2][2]= 1;
Mat2[3][3]= 1;
Mat2[0][1]= 0;
Mat2[0][2]= 0;
Mat2[0][3]= 0;
Mat2[1][0]= 0;
Mat2[1][2]= 0;
Mat2[1][3]= 0;
Mat2[2][0]= 0;
Mat2[2][1]= 0;
Mat2[2][3]= 0;
Mat2[3][0]= 0;
Mat2[3][1]= 0;
Mat2[3][2]= 0;
Mat1[0][0]= 1;
Mat1[1][1]= 1;
Mat1[2][2]= 1;
Mat1[3][3]= 1;
Mat1[0][1]= 0;
Mat1[0][2]= 0;
Mat1[0][3]= 0;
Mat1[1][0]= 0;
Mat1[1][2]= 0;
Mat1[1][3]= 0;
Mat1[2][0]= 0;
Mat1[2][1]= 0;
Mat1[2][3]= 0;
Mat1[3][0]= 0;
Mat1[3][1]= 0;
Mat1[3][2]= 0;
mean[0] = 0;
mean[1] = 0;
mean[2] = 0;
}
void OBJECT_LOG::Mesh_DrawObj(int mode, bool bool_change_pos_obj,bool bool_vbo)
{
// If level ==0 (level 0 = root sera un unique objet impossible à supprimer...
// La camera ne sera dessinée que si on est l'objet racine
//KEEP!!!
//poupoune = 10000;
//glColorMaterial(GL_FRONT, GL_DIFFUSE);
// glEnable(GL_COLOR_MATERIAL);
VERTEX2 c;
c.x = c.y = c.z = 0;
double r = (double)1/3;
float uvx[3], uvy[3], uvz[3];
double PI = 3.1415926535897932384626;
uvx[0]=cos(PI*camera.az/180.0)*cos(-PI*camera.el/180.0);
uvx[1]=sin(PI*camera.az/180.0)*cos(-PI*camera.el/180.0);
uvx[2]=-sin(-PI*camera.el/180.0);
//"viewing" 0 1 0
uvy[0]=cos(PI*camera.az/180.0)*sin(-PI*camera.el/180.0)*sin(-PI*camera.tw/180.0) - sin(PI*camera.az/180.0)*cos(-PI*camera.tw/180.0);
uvy[1]=sin(PI*camera.az/180.0)*sin(-PI*camera.el/180.0)*sin(-PI*camera.tw/180.0) + cos(PI*camera.az/180.0)*cos(-PI*camera.tw/180.0);
uvy[2]=cos(-PI*camera.el/180.0)*sin(-PI*camera.tw/180.0);
//"viewing" 0 0 1
uvz[0]=cos(PI*camera.az/180.0)*sin(-PI*camera.el/180.0)*cos(-PI*camera.tw/180.0) + sin(PI*camera.az/180.0)*sin(-PI*camera.tw/180.0);
uvz[1]=sin(PI*camera.az/180.0)*sin(-PI*camera.el/180.0)*cos(-PI*camera.tw/180.0) - cos(PI*camera.az/180.0)*sin(-PI*camera.tw/180.0);
uvz[2]=cos(-PI*camera.el/180.0)*cos(-PI*camera.tw/180.0);
if (this->level == 1) //Grouped of first level
{
if (this->selected ==1 )//Ungrouped object
{
//glColor4fv((GLfloat*)bone_ambuse);
glMaterialfv(GL_FRONT,GL_AMBIENT,bone_ambuse);
glMaterialfv(GL_FRONT,GL_DIFFUSE,bone_ambuse);
glMaterialfv(GL_FRONT,GL_SPECULAR,bone_specular);
glMaterialfv(GL_FRONT,GL_SHININESS,bone_shininess);
glMaterialfv(GL_FRONT,GL_EMISSION,no_mat);
}
else
{
//glColor4fv((GLfloat*)this->color);
glMaterialfv(GL_FRONT,GL_AMBIENT,this->color);
glMaterialfv(GL_FRONT,GL_DIFFUSE,this->color);
glMaterialfv(GL_FRONT,GL_SPECULAR,this->color);
glMaterialfv(GL_FRONT,GL_SHININESS,bone_shininess);
glMaterialfv(GL_FRONT,GL_EMISSION,no_mat);
}
}
glPushMatrix();
//Move according to widgets only if it's selected AND IF IT'S NOT THE BIG ROOT!
if (this->selected == 1 && this->level ==1)//Grouped of first rank
{
glTranslated(tx2*uvx[0] + ty2*uvy[0]+ tz2*uvz[0],
tx2*uvx[1] + ty2*uvy[1]+ tz2*uvz[1],
tx2*uvx[2] + ty2*uvy[2]+ tz2*uvz[2]);
// Calculate new center of rotation:
//float newmean[3];
/*ApplyTransformation(this->mean, newmean, this->Mat2);//Position
glTranslated(
newmean[0],
newmean[1],
newmean[2]
);
glRotated(rotx2, uvx[0], uvx[1], uvx[2]);
glRotated(roty2, uvy[0], uvy[1], uvy[2]);
glRotated(rotz2, uvz[0], uvz[1], uvz[2]);
glTranslated(
-newmean[0],
-newmean[1],
-newmean[2]
); */
glTranslated(
g_mean[0],
g_mean[1],
g_mean[2]
);
glRotated(rotx2, uvx[0], uvx[1], uvx[2]);
glRotated(roty2, uvy[0], uvy[1], uvy[2]);
glRotated(rotz2, uvz[0], uvz[1], uvz[2]);
glTranslated(
-g_mean[0],
-g_mean[1],
-g_mean[2]
);
//}
}//Fin if selected ==1
//In Any Case of course we multiply by Mat2 and Mat1!
glMultMatrixf((GLfloat *)this->Mat2);
glTranslated(
this->mean[0],
this->mean[1],
this->mean[2]
);
glMultMatrixf((GLfloat *)this->Mat1);
glTranslated(
-this->mean[0],
-this->mean[1],
-this->mean[2]
);
//VERIFY
if (this->OBJECTS_LANDMARK !=NULL)
{
//glEnable(GL_COLOR_MATERIAL);
this->OBJECTS_LANDMARK->Landmark_DrawObj(this->level, mode);
}
if (this->OBJECTS_LANDMARK_TARGET !=NULL)
{
//glEnable(GL_COLOR_MATERIAL);
//@@@@
this->OBJECTS_LANDMARK_TARGET->Landmark_DrawObj(this->level, mode);
}
if (this->OBJECTS !=NULL)
{
this->OBJECTS->Mesh_DrawObj(this->level, bool_change_pos_obj,bool_vbo);
}
if (this->OBJECTS_LOG !=NULL)
{
this->OBJECTS_LOG->Mesh_DrawObj(mode, bool_change_pos_obj,bool_vbo);
}
if (this->OBJECTS_LANDMARK_LABELS != NULL)
{
//glEnable(GL_COLOR_MATERIAL);
//@@@@
this->OBJECTS_LANDMARK_LABELS->Landmark_DrawObj(this->level, mode);
}
glPopMatrix()
;
//glDisable(GL_COLOR_MATERIAL);
if (nextobj !=NULL)
{
nextobj->Mesh_DrawObj(mode, bool_change_pos_obj,bool_vbo);
}
}
void OBJECT_LOG::Mesh_Unselect()
{
this->selected =0;
if (this->nextobj !=NULL)
{this->nextobj->Mesh_Unselect();}
if (this->OBJECTS_LOG !=NULL)
{this->OBJECTS_LOG->Mesh_Unselect();}
if (this->OBJECTS_LANDMARK !=NULL)
{this->OBJECTS_LANDMARK->Landmark_Unselect();}
if (this->OBJECTS_LANDMARK_TARGET !=NULL)
{this->OBJECTS_LANDMARK_TARGET->Landmark_Unselect();}
if (this->OBJECTS_LANDMARK_LABELS !=NULL)
{this->OBJECTS_LANDMARK_LABELS->Landmark_Unselect();}
if (this->OBJECTS !=NULL)
{this->OBJECTS->Mesh_Unselect();}
}
void OBJECT_LOG::Mesh_Select()
{
this->selected = 1;
if (this->nextobj !=NULL)
{this->nextobj->Mesh_Select();}
if (this->OBJECTS_LOG !=NULL)
{this->OBJECTS_LOG->Mesh_Select();}
if (this->OBJECTS_LANDMARK !=NULL)
{this->OBJECTS_LANDMARK->Landmark_Select();}
if (this->OBJECTS_LANDMARK_TARGET !=NULL)
{this->OBJECTS_LANDMARK_TARGET->Landmark_Select();}
if (this->OBJECTS_LANDMARK_LABELS !=NULL)
{this->OBJECTS_LANDMARK_LABELS->Landmark_Select();}
if (this->OBJECTS !=NULL)
{this->OBJECTS->Mesh_Select();}
}
void OBJECT_LOG::Compute_Global_Scalar_List()
{
OBJECT_MESH *MyMesh;
if (this->OBJECTS !=NULL)
{
MyMesh = this->OBJECTS;
MyMesh->Compute_Global_Scalar_List();
}
}
void OBJECT_LOG::Compute_Name_Lists()
{
OBJECT_MESH *MyMesh;
if (this->OBJECTS !=NULL)
{
MyMesh = this->OBJECTS;
MyMesh->Compute_Name_Lists();
}
}
void OBJECT_LOG::Compute_Global_MinMax()
{
float minx = 9999999999;
float maxx = -9999999999;
float miny = 9999999999;
float maxy = -9999999999;
float minz = 9999999999;
float maxz = -9999999999;
glPushMatrix();
glLoadIdentity();
this->Calculate_Global_MinMax(&minx, &maxx, &miny, &maxy, &minz, &maxz );
g_minx = minx;
std::cout << "new g_minx:" << g_minx << std::endl;
g_maxx = maxx;
g_miny = miny;
g_maxy = maxy;
g_minz = minz;
g_maxz = maxz;
glPopMatrix();
}
void OBJECT_LOG::Compute_Global_Mean(int only_selected)
{
float meanx=0;
float meany=0;
float meanz =0;
float minx = 0;
float miny = 0;
float minz = 0;
float maxx = 0;
float maxy = 0;
float maxz = 0;
int nmean=0;
glPushMatrix();
glLoadIdentity();
this->Calculate_GlobalMean(&meanx, &meany,&meanz, &nmean, 1); // computes only for selected things
this->Compute_Global_MinMax();
//this->Calculate_Global_MinMax(&minx, &maxx, &miny, &maxy, &minz, &maxz);
if (nmean >0)
{
g_mean[0]=meanx/nmean;
g_mean[1]=meany/nmean;
g_mean[2]=meanz/nmean;
g_nmean = nmean;
}
else
{
g_mean[1]=0;
g_mean[2]=0;
g_mean[0]=0;
g_nmean=0;
}
if (only_selected == 0)
{
this->Calculate_GlobalMean(&meanx, &meany, &meanz, &nmean, 0); // computes for all objects
if (nmean > 0)
{
g_mean_all[0] = meanx / nmean;
g_mean_all[1] = meany / nmean;
g_mean_all[2] = meanz / nmean;
g_dmean_all = (g_maxx - g_minx + g_maxy - g_miny + g_maxz - g_minz) / 3;
g_nmean_all = nmean;
}
else
{
g_mean_all[1] = 0;
g_mean_all[2] = 0;
g_mean_all[0] = 0;
g_dmean_all = 0;
}
}
glPopMatrix();
/*std::cout << "g_mean[0]:"<<g_mean[0]<< std::endl;
std::cout << "g_mean[1]:"<<g_mean[1]<< std::endl;
std::cout << "g_mean[2]:"<<g_mean[2]<< std::endl;
std::cout << "g_nmean:"<<g_nmean<< std::endl<<"-----------------------"<< std::endl;*/
}
void OBJECT_LOG::Calculate_GlobalMean(float *x, float *y, float *z, int *nb, int only_selected)
{
// selected = 0 : computes for all objects inside this log object
// selected = 1 : computes only for selected objects.
// Qu'est ce qu'on fait de Mat1 et Mat2 ????
// Si c'est l'Objet basal, on s'en fiche
// Si c'est un autre, on multiplie par Mat1 et Mat2, sinon ça ne fonctionnera plus!
//std::cout<<"Calculate_GlobalMean level: "<<level<<" selected="<<selected<< std::endl;
float meanx=0,meany=0, meanz=0;
int nbverts=0;
float tmpx, tmpy, tmpz;
int nbtmp =0;
OBJECT_MESH *MyMesh;
OBJECT_LANDMARK *MyLandmark;
OBJECT_LOG *MyLog;
//Mean of the Object stack
glMatrix wc_mat2;
//this->get_world_coordinates_matrix(wc_mat2);
//getmatrix(wc_mat2);
glPushMatrix();
if (level==0){glLoadIdentity();}
else
{
glMultMatrixf((GLfloat*) this->Mat2);
if (level==1)
{
glTranslated(
this->mean[0],
this->mean[1],
this->mean[2]
);
}
glMultMatrixf((GLfloat*) this->Mat1); //Aspect
if (level==1)
{
glTranslated(
-this->mean[0],
-this->mean[1],
-this->mean[2]
);
}
}
if (this->OBJECTS !=NULL)
{
MyMesh = this->OBJECTS;