File: sardrawpm_ptt.c

package info (click to toggle)
searchandrescue 0.8.2-10
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,656 kB
  • ctags: 6,111
  • sloc: ansic: 89,072; cpp: 7,691; sh: 90; makefile: 80
file content (195 lines) | stat: -rw-r--r-- 5,762 bytes parent folder | download | duplicates (6)
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
#include <stdio.h>
#include <sys/types.h>
#include <math.h>

#ifdef __MSW__
# include <windows.h>
#endif

#include <GL/gl.h>
#include <GL/glu.h>

#include "gw.h"

#include "sarreality.h"
#include "obj.h"
#include "objutils.h"
#include "sfm.h"
#include "sar.h"
#include "sardraw.h"
#include "sardrawpm.h"
#include "sardrawdefs.h"


void SARDrawPremodeledPowerTransmissionTower(SAR_DRAW_PREMODELED_PROTOTYPE);


/*
 *      Draws a premodeled power transmission tower.
 */
void SARDrawPremodeledPowerTransmissionTower(SAR_DRAW_PREMODELED_PROTOTYPE)
{
	gw_display_struct *display = dc->display;
	state_gl_struct *state = &display->state_gl;
	GLenum shade_model_mode = state->shade_model_mode;
	int i;
	float sx, sy, sz;		/* Scale */


	/* All hard coded coordinates will produce an object of unit
	 * size (height = 1.0)
	 *
	 * So the sx, sy, and sz scale coefficients will simply multiply
	 * each point
	 */

	/* Calculate scales, all based on height */
	sx = sy = sz = obj_premodeled_ptr->height;

	/* Set up gl states */
	StateGLShadeModel(state, GL_FLAT);

	glColor4f(0.45f, 0.45f, 0.45f, 1.0f);

	/* Draw close range model? */
	if(camera_dist < 2000.0f)
	{
	  /* Draw two passes (one for the north side, the other for
	   * the south side.
	   */
	  for(i = 0; i < 2; i++)
	  {
	    glBegin(GL_LINE_STRIP);
	    {
		/* Base */
		glNormal3f(0.0f, 1.0f, 0.0f);

		glVertex3f(-0.12f * sx, 0.0f * sz, -(0.12f * sy));
		glVertex3f(-0.08f * sx, 0.2f * sz, -(0.08f * sy));
		glVertex3f(0.08f * sx, 0.2f * sz, -(0.08f * sy));
		glVertex3f(0.12f * sx, 0.0f * sz, -(0.12f * sy));
		glVertex3f(-0.08f * sx, 0.2f * sz, -(0.08f * sy));
	    }
	    glEnd();
	    glBegin(GL_LINE_STRIP);
	    {
		glVertex3f(-0.12f * sx, 0.0f * sz, -(0.12f * sy));
		glVertex3f(0.08f * sx, 0.2f * sz, -(0.08f * sy));
		glVertex3f(-0.05f * sx, 0.4f * sz, -(0.05f * sy));
		glVertex3f(0.05f * sx, 0.4f * sz, -(0.05f * sy));
		glVertex3f(-0.08f * sx, 0.2f * sz, -(0.08f * sy));
	    }
	    glEnd();
	    glBegin(GL_LINE_STRIP);
	    {
		glVertex3f(-0.08f * sx, 0.2f * sz, -(0.08f * sy));
		glVertex3f(-0.05f * sx, 0.4f * sz, -(0.05f * sy));
		glVertex3f(0.05f * sx, 0.65f * sz, -(0.05f * sy));
		glVertex3f(0.05f * sx, 0.4f * sz, -(0.05f * sy));
	    }
	    glEnd();
	    glBegin(GL_LINE_STRIP);
	    {
		glVertex3f(-0.05f * sx, 0.4f * sz, -(0.05f * sy));
		glVertex3f(-0.05f * sx, 0.65f * sz, -(0.05f * sy));
		glVertex3f(0.05f * sx, 0.4f * sz, -(0.05f * sy));
		glVertex3f(0.08f * sx, 0.2f * sz, -(0.08f * sy));
	    }
	    glEnd();
	    glBegin(GL_LINE_STRIP);
	    {
		glVertex3f(0.05f * sx, 0.65f * sz, -(0.05f * sy));
		glVertex3f(-0.05f * sx, 0.65f * sz, -(0.05f * sy));
		glVertex3f(-0.05f * sx, 0.9f * sz, -(0.05f * sy));
		glVertex3f(0.05f * sx, 0.65f * sz, -(0.05f * sy));
		glVertex3f(0.05f * sx, 0.9f * sz, -(0.05f * sy));
	    }
	    glEnd();
	    glBegin(GL_LINE_STRIP);
	    {
		glVertex3f(-0.05f * sx, 0.65f * sz, -(0.05f * sy));
		glVertex3f(0.05f * sx, 0.9f * sz, -(0.05f * sy));
		glVertex3f(0.0f * sx, 1.0f * sz, -(0.0f * sy));
		glVertex3f(-0.05f * sx, 0.9f * sz, -(0.05f * sy));
		glVertex3f(0.05f * sx, 0.9f * sz, -(0.05f * sy));
	    }
	    glEnd();
	    glBegin(GL_LINE_STRIP);
	    {
		glVertex3f(-0.05f * sx, 0.65f * sz, -(0.05f * sy));
		glVertex3f(-0.25f * sx, 0.65f * sz, -(0.05f * sy));
		glVertex3f(-0.27f * sx, 0.56f * sz, -(0.0f * sy));
		glVertex3f(-0.22f * sx, 0.62f * sz, -(0.05f * sy));
		glVertex3f(-0.05f * sx, 0.59f * sz, -(0.05f * sy));
		glVertex3f(-0.25f * sx, 0.65f * sz, -(0.05f * sy));
		glVertex3f(-0.22f * sx, 0.62f * sz, -(0.05f * sy));
		glVertex3f(-0.05f * sx, 0.65f * sz, -(0.05f * sy));
	    }
	    glEnd();
	    glBegin(GL_LINE_STRIP);
	    {
		glVertex3f(0.05f * sx, 0.65f * sz, -(0.05f * sy));
		glVertex3f(0.25f * sx, 0.65f * sz, -(0.05f * sy));
		glVertex3f(0.27f * sx, 0.56f * sz, -(0.0f * sy));
		glVertex3f(0.22f * sx, 0.62f * sz, -(0.05f * sy));
		glVertex3f(0.05f * sx, 0.59f * sz, -(0.05f * sy));
		glVertex3f(0.25f * sx, 0.65f * sz, -(0.05f * sy));
		glVertex3f(0.22f * sx, 0.62f * sz, -(0.05f * sy));
		glVertex3f(0.05f * sx, 0.65f * sz, -(0.05f * sy));
	    }
	    glEnd();
	    glBegin(GL_LINE_STRIP);
	    {
		glVertex3f(-0.05f * sx, 0.9f * sz, -(0.05f * sy));
		glVertex3f(-0.23f * sx, 0.9f * sz, -(0.05f * sy));
		glVertex3f(-0.25f * sx, 0.81f * sz, -(0.0f * sy));
		glVertex3f(-0.2f * sx, 0.87f * sz, -(0.05f * sy));
		glVertex3f(-0.05f * sx, 0.84f * sz, -(0.05f * sy));
		glVertex3f(-0.23f * sx, 0.9f * sz, -(0.05f * sy));
		glVertex3f(-0.2f * sx, 0.87f * sz, -(0.05f * sy));
		glVertex3f(-0.05f * sx, 0.9f * sz, -(0.05f * sy));
	    }
	    glEnd();
	    glBegin(GL_LINE_STRIP);
	    {
		glVertex3f(0.05f * sx, 0.9f * sz, -(0.05f * sy));
		glVertex3f(0.23f * sx, 0.9f * sz, -(0.05f * sy));
		glVertex3f(0.25f * sx, 0.81f * sz, -(0.0f * sy));
		glVertex3f(0.2f * sx, 0.87f * sz, -(0.05f * sy));
		glVertex3f(0.05f * sx, 0.84f * sz, -(0.05f * sy));
		glVertex3f(0.23f * sx, 0.9f * sz, -(0.05f * sy));
		glVertex3f(0.2f * sx, 0.87f * sz, -(0.05f * sy));
		glVertex3f(0.05f * sx, 0.9f * sz, -(0.05f * sy));
	    }
	    glEnd();

	    /* Flip the y scale value to draw the south side */
	    sy *= -1.0f;
	  }
	}
	else
	{
	    /* Draw far model */
	    glBegin(GL_LINES);
	    {
		glNormal3f(0.0f, 1.0f, 0.0f);

		glVertex3f(0.0f * sx, 0.0f * sz, -(0.0f * sy));
		glVertex3f(0.0f * sx, 1.0f * sz, -(0.0f * sy));

		glVertex3f( 0.27f * sx, 0.62f * sz, -(0.0f * sy));
		glVertex3f(-0.27f * sx, 0.62f * sz, -(0.0f * sy));

		glVertex3f( 0.26f * sx, 0.9f * sz, -(0.0f * sy));
		glVertex3f(-0.26f * sx, 0.9f * sz, -(0.0f * sy));
	    }
	    glEnd();
	}

	/* Reget y scale, since it has been modified in the above loop */
	sy = obj_premodeled_ptr->height;


	/* Restore gl states */
	StateGLShadeModel(state, shade_model_mode);
}