Pascal/Turbo Pascal - AYUDA CON LA UNIDAD GRAFICA

 
Vista:

AYUDA CON LA UNIDAD GRAFICA

Publicado por . (1 intervención) el 10/03/2020 08:34:51
La idea es hacer que un cubo gire al rededor del punto de fuga de forma inclinada (las lineas son para guiarme), pero no logro hacerlo, pienso que es algo que tiene que ver con los radios y me estoy desesperando. Si pudieran aconcejarme o ayudarme en que esta mal se los agradecería.


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
program perspectiva;
uses crt,graph;
 
const
color_horizonte=15;
color_figuras=9;
color_lineas=14;
color_figura2=10;
color_figura3=lightred;
color_figura4=15;
color_borrar=0;
a=3;
centro_x=320;
centro_y=240;
radio=60;
 
var
driver,modo,x,y,xx,yy,x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,x7,y7,x8,y8,i,tita:integer;
r1,r2:real;
tecla:char;
 
procedure horizonte;
begin
        setcolor(color_horizonte);
        circle(centro_x,centro_y,3);  (*punto de fuga*)
 
 
end;
 
procedure cuadrado;
begin
         x1:= x+50;
         y1:= y+50;
         x2:= x+50;
         y2:= y-50;
         x3:= x-50;
         y3:= y-50;
         x4:= x-50;
         y4:= y+50;
end;
 
procedure dibujar_cuadrado; (*dibuja un cuadrado, perfecto para no escribir lo mismo 40 veces :)*)
begin
         line(x1,y1,x2,y2);
         line(x2,y2,x3,y3);
         line(x3,y3,x4,y4);
 
 
 
end;
 
procedure dibujar_cuadrado3;
begin
          line(x4,y4,x1,y1);
 
 
end;
 
procedure dibujar_cuadrado4;
begin
         line(x6,y6,x7,y7);
end;
 
procedure dibujar_cuadrado2;
begin
 
         line(x5,y5,x6,y6);
 
         line(x7,y7,x8,y8);
         line(x8,y8,x5,y5);
 
end;
 
procedure lineas_centro;
begin
        setlinestyle(1,1,1);
        line(centro_x,centro_y,x1,y1);
        line(centro_x,centro_y,x2,y2);
        line(centro_x,centro_y,x3,y3);
        line(centro_x,centro_y,x4,y4);
        line(centro_x,centro_y,x5,y5);
        line(centro_x,centro_y,x6,y6);
        line(centro_x,centro_y,x7,y7);
        line(centro_x,centro_y,x8,y8);
        setlinestyle(0,0,0);
end;
 
 
 
procedure transform_cuadrado;
begin
         x1:= x + trunc( r1*cos( (i+tita)*pi/180 ));
         y1:= y - trunc( r1*sin( (i+tita)*pi/180 ));
         x2:= x + trunc( r1*cos( (i-tita)*pi/180 ));
         y2:= y - trunc( r1*sin( (i-tita)*pi/180 ));
         x3:= x + trunc( r1*cos( (i+tita*5)*pi/180 ));
         y3:= y - trunc( r1*sin( (i+tita*5)*pi/180 ));
         x4:= x + trunc( r1*cos( (i+tita*3)*pi/180 ));
         y4:= y - trunc( r1*sin( (i+tita*3)*pi/180 ));
 
         x5:= xx + trunc( r2*cos( (i+tita)*pi/180 ));
         y5:= yy - trunc( r2*sin( (i+tita)*pi/180 ));
         x6:= xx + trunc( r2*cos( (i-tita)*pi/180 ));
         y6:= yy - trunc( r2*sin( (i-tita)*pi/180 ));
         x7:= xx + trunc( r2*cos( (i+tita*5)*pi/180 ));
         y7:= yy - trunc( r2*sin( (i+tita*5)*pi/180 ));
         x8:= xx + trunc( r2*cos( (i+tita*3)*pi/180 ));
         y8:= yy - trunc( r2*sin( (i+tita*3)*pi/180 ));
 
 
end;
 
 
 
 
 
procedure mov_izdr;
begin
        x:= x + round(3 * cos(i*Pi/180 ));
        y:= y - round(2 * sin(i*Pi/180 + Pi/2));
 
        xx:= xx + round(3 * cos(i*Pi/180 ) );
        yy:= yy - round(2 * sin(i*Pi/180 + Pi/2) );
 
        r1:= radio + 40 * sin((i+tita*2)*Pi/180) ;
        r2:= radio - 30  * sin((i+tita*2)*Pi/180) ;
end;
 
procedure animacion_cubo;
begin
        horizonte;
        tita:=45;
        r1:=radio;
        r2:=radio-30;
        transform_cuadrado;
        dibujar_cuadrado;
        readkey;
        while not keypressed do begin
 
              for i:=0 to 360 do begin
                  horizonte;
                  delay(10);
                  setcolor(color_borrar);
                  lineas_centro;
                  dibujar_cuadrado;
                  dibujar_cuadrado2;
                  dibujar_cuadrado3;
                  dibujar_cuadrado4;
                  mov_izdr;
                  transform_cuadrado;
 
                  setcolor(color_lineas);
                  lineas_centro;
 
                  setcolor(color_figura3);
                  dibujar_cuadrado3;
                  setcolor(color_figura2);
                  dibujar_cuadrado2;
                  setcolor(color_figura4);
                  dibujar_cuadrado4;
                  setcolor(color_figuras);
                  dibujar_cuadrado;
 
 
              end;
 
        end;
end;
 
begin
     driver:=detect;
     initgraph(driver,modo,'');
     x:= getmaxx div 2;
     y:= getmaxy div 2;
     xx:=x;
     yy:=y;
     i:=0;
 
     animacion_cubo;
 
     readkey;
end.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder