Waitrud Weber’s blog

things and reminders for memories

3D: Print symbol

The program can display symbol.

//

//

//

 91 :int display_threeD_initialize () {
 92 : vPoint eye;
 93 : char *p_cc;
 94 :
 95 : if ( call_once_display_threeD_initialize == 0 ) {
 96 :  call_once_display_threeD_initialize = 1;
 97 : } else {
 98 :  exit(-1);
 99 : }
100 :
101 : printf("display_threeD_initialize\r\n");
102 :
103 : eye.setPoint( 500.0f, 500.0f, -500.0f);
104 :
105 : atri.p1.setPoint( 100.0f,   0.0f, 100.0f );
106 : atri.p2.setPoint( 200.0f, 200.0f, 200.0f );
107 : atri.p3.setPoint( 300.0f,   0.0f, 100.0f );
108 :
109 : screen = new vScreen ();
110 : vPoint* U= new vPoint ( 160.0f, 0.0f, 0.0f );
111 : vPoint* V= new vPoint ( 0, 90.0f, 0 );
112 : screen->put_U ( *U );
113 : screen->put_V ( *V );
114 :
115 : screen->put_Up ( *( new vPoint(0.0f, 1.0f, 0.0f) ) );
116 : screen->put_C ( *( new vPoint( 0.0f, 0.0f, -50.0f) ));
117 : screen->setWidth ( 640 );
118 : screen->setHeight ( 480 );
119 : screen->setEye ( eye );
120 : screen->LookAt ( *(new vPoint( 0.0f, 0.0f, 0.0f )) );
121 : screen->HowFarFromEve = 320.0f;
122 : screen->calculation_up_UV();
123 : screen->OntheScreen( &g_x, &g_y );
124 :
125 : display_3d = 1;
126 :
127 : printf("display_threeD_initialize=000\r\n");
128 :
129 : lines = new vLine[3];
130 : lines[0].setLine( (new vPoint( -50.0f, 0.0f, 0.0f)), (new vPoint(300.0f,   0.0f, 0.0f)) );
131 : lines[1].setLine( (new vPoint( 0.0f, -50.0f, 0.0f)), (new vPoint(  0.0f, 300.0f, 0.0f)) );
132 : lines[2].setLine( (new vPoint( 0.0f, 0.0f, -50.0f)), (new vPoint(  0.0f, 0.0f, 300.0f)) );
133 :
134 : lines[0].c1 = (char*) "x1";
135 : lines[0].c2 = (char*) "x2";
136 :
137 : printf("display_threeD_initialize=001\r\n");
138 :
139 : lines_2D = new vLine[3];
140 : lines_2D[0].setLine( (new vPoint( 0.0f, 0.0f, 0.0f)), (new vPoint( 300.0f,   0.0f, 0.0f)) );
141 : lines_2D[1].setLine( (new vPoint( 0.0f, 0.0f, 0.0f)), (new vPoint(   0.0f, 300.0f, 0.0f)) );
142 : lines_2D[2].setLine( (new vPoint( 0.0f, 0.0f, 0.0f)), (new vPoint(   0.0f,   0.0f, 300.0f)) );
143 :
144 : printf("display_threeD_initialize=002\r\n");
145 :
146 : lines_patches = (vLine**) malloc ( sizeof(vLine*) * 3 );
147 : lines_patches_2D = (vLine**) malloc ( sizeof(vLine*) * 3 );
148 :
149 : printf("display_threeD_initialize=0021\r\n");
150 :
151 : for( int i=0; i<3; i++ ) {
152 :  lines_patches[i] = new vLine();
153 :  lines_patches_2D[i] = new vLine();
154 : }
155 :
156 : // commented out at 20190518
157 : lines_patches[0]->p1 = new vPoint( 0.0f, 0.0f, 0.0f);
158 : lines_patches[0]->p2 = new vPoint( 0.0f, 0.0f, 0.0f);
159 : lines_patches[1]->p1 = new vPoint( 0.0f, 0.0f, 0.0f);
160 : lines_patches[1]->p2 = new vPoint( 0.0f, 0.0f, 0.0f);
161 : lines_patches[2]->p1 = new vPoint( 0.0f, 0.0f, 0.0f);
162 : lines_patches[2]->p2 = new vPoint( 0.0f, 0.0f, 0.0f);
163 :
164 : printf("display_threeD_initialize=0022\r\n");
165 :
166 : // x lines_patches[0]->setLine( new vPoint( 0.0f, 0.0f, 0.0f), new vPoint( 0.0f, 0.0f, 0.0f) );
167 : // x lines_patches[0]->setLine( new vPoint( 0.0f, 0.0f, 0.0f), new vPoint( 0.0f, 0.0f, 0.0f) );
168 : printf("lines_patches[2]->p2->x %f\r\n", lines_patches[2]->p2->x );
169 :
170 :    printf("display_threeD_initialize=0023\r\n");
171 :
172 : // commented out at 20190518
173 : lines_patches_2D[0]->p1 = new vPoint( 0.0f, 0.0f, 0.0f);
174 : lines_patches_2D[0]->p2 = new vPoint( 0.0f, 0.0f, 0.0f);
175 : lines_patches_2D[1]->p1 = new vPoint( 0.0f, 0.0f, 0.0f);
176 : lines_patches_2D[1]->p2 = new vPoint( 0.0f, 0.0f, 0.0f);
177 : lines_patches_2D[2]->p1 = new vPoint( 0.0f, 0.0f, 0.0f);
178 : lines_patches_2D[2]->p2 = new vPoint( 0.0f, 0.0f, 0.0f);
179 :
180 : lines_patches_2D[0]->c1 = (char *) p_cc;
181 : lines_patches_2D[0]->c1 = (char *) copyof( "x1" );
182 :
183 : vIntersection* intersection = nullptr;
184 : intersection = new vIntersection ();
185 :
186 : //point_intersection = intersection->Intersect( atri, eye, ray );
187 :
188 : printf("display_threeD_initialize=003\r\n");
189 :
190 : // Book a triangle patch
191 : num_patches = 1;
192 : patch_num = (int**) malloc( sizeof(int*) * 1 ) ;
193 : vertexes = (vPoint*) malloc( sizeof(vPoint) * 8 ) ;
194 :
195 : vertexes = new vPoint ( 0.0f, 0.0f, 0.0f );
196 : // scope put a vertex
197 : put_vertex( vertexes + 1, new vPoint ( 5.0f, 10.0f, 0.0f ));
198 : put_vertex( vertexes + 2, new vPoint ( 10.0f, 0.0f, 0.0f ));
199 :
200 : base_num_patches = 3;
201 : printf("display_threeD_initialize=001");
202 : Print_Global_Vertexes ( vertexes, patch_num, num_patches, base_num_patches );
203 : //exit(-1);
204 :
205 :
206 : int* p_tri_patch = (int*) malloc( sizeof(int) * base_num_patches ) ;
207 : p_tri_patch[0] = 0;
208 : p_tri_patch[1] = 1;
209 : p_tri_patch[2] = 2;
210 :
211 : patch_num[0] = p_tri_patch;
212 :
213 : num_patch_lines = 0;
214 : num_patch_lines = base_num_patches*num_patches;
215 :
216 : printf("display_threeD_initialize will return 0.\r\n");
217 : return 0;
218 :}

//

//

//

f:id:Waitrud_Weber:20190519183744p:plain