File: sardrawpm_tower.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 (133 lines) | stat: -rw-r--r-- 4,113 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
#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 SARDrawPremodeledTower(SAR_DRAW_PREMODELED_PROTOTYPE);


/*
 *      Draws a premodeled tower.
 */
void SARDrawPremodeledTower(SAR_DRAW_PREMODELED_PROTOTYPE)
{
	gw_display_struct *display = dc->display;
	GLenum shade_model_mode = display->state_gl.shade_model_mode;
	float sx, sy, sz;		/* Scale. */


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

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

	/* Set up gl states. */
	StateGLShadeModel(&display->state_gl, GL_FLAT);

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

	/* Draw close range model? */
	if(camera_dist < 2000.0f)
	{
	    /* Guy wires. */
	    glBegin(GL_LINES);
	    {
		glNormal3f(0.0f, 1.0f, 0.0f);

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

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

		glVertex3f(  0.0f * sx,  0.0f * sz, -( 40.0f * sy));
		glVertex3f(  0.0f * sx, 75.0f * sz, -(  0.0f * sy));
	    }
	    glEnd();

	    sx = sy = 1.0f;
	    glBegin(GL_LINE_STRIP);
	    {
		glNormal3f(0.0f, 1.0f, 0.0f);

		glVertex3f(  3.0f * sx,   0.0f * sz, -( 0.0f * sy));
		glVertex3f( -3.0f * sx,   0.0f * sz, -( 0.0f * sy));
		glVertex3f( -3.0f * sx, 100.0f * sz, -( 0.0f * sy));
		glVertex3f(  3.0f * sx,  90.0f * sz, -( 0.0f * sy));
		glVertex3f( -3.0f * sx,  80.0f * sz, -( 0.0f * sy));
		glVertex3f(  3.0f * sx,  70.0f * sz, -( 0.0f * sy));
		glVertex3f( -3.0f * sx,  60.0f * sz, -( 0.0f * sy));
		glVertex3f(  3.0f * sx,  50.0f * sz, -( 0.0f * sy));
		glVertex3f( -3.0f * sx,  40.0f * sz, -( 0.0f * sy));
		glVertex3f(  3.0f * sx,  30.0f * sz, -( 0.0f * sy));
		glVertex3f( -3.0f * sx,  20.0f * sz, -( 0.0f * sy));
		glVertex3f(  3.0f * sx,  10.0f * sz, -( 0.0f * sy));
		glVertex3f( -3.0f * sx,   0.0f * sz, -( 0.0f * sy));

		glVertex3f( -3.0f * sx,   0.0f * sz, -(-0.2f * sy));
		glVertex3f(  0.0f * sx,   0.0f * sz, -( 5.0f * sy));
		glVertex3f(  0.0f * sx, 100.0f * sz, -( 5.0f * sy));
		glVertex3f( -3.0f * sx,  90.0f * sz, -(-0.2f * sy));
		glVertex3f(  0.0f * sx,  80.0f * sz, -( 5.0f * sy));
		glVertex3f( -3.0f * sx,  70.0f * sz, -(-0.2f * sy));
		glVertex3f(  0.0f * sx,  60.0f * sz, -( 5.0f * sy));
		glVertex3f( -3.0f * sx,  50.0f * sz, -(-0.2f * sy));
		glVertex3f(  0.0f * sx,  40.0f * sz, -( 5.0f * sy));
		glVertex3f( -3.0f * sx,  30.0f * sz, -(-0.2f * sy));
		glVertex3f(  0.0f * sx,  20.0f * sz, -( 5.0f * sy));
		glVertex3f( -3.0f * sx,  10.0f * sz, -(-0.2f * sy));
		glVertex3f(  0.0f * sx,   0.0f * sz, -( 5.0f * sy));

		glVertex3f(  0.0f * sx,   0.0f * sz, -( 5.2f * sy));
		glVertex3f(  3.0f * sx,   0.0f * sz, -( 0.0f * sy));
		glVertex3f(  3.0f * sx, 100.0f * sz, -( 0.0f * sy));
		glVertex3f(  0.0f * sx,  90.0f * sz, -( 5.2f * sy));
		glVertex3f(  3.0f * sx,  80.0f * sz, -( 0.0f * sy));
		glVertex3f(  0.0f * sx,  70.0f * sz, -( 5.2f * sy));
		glVertex3f(  3.0f * sx,  60.0f * sz, -( 0.0f * sy));
		glVertex3f(  0.0f * sx,  50.0f * sz, -( 5.2f * sy));
		glVertex3f(  3.0f * sx,  40.0f * sz, -( 0.0f * sy));
		glVertex3f(  0.0f * sx,  30.0f * sz, -( 5.2f * sy));
		glVertex3f(  3.0f * sx,  20.0f * sz, -( 0.0f * sy));
		glVertex3f(  0.0f * sx,  10.0f * sz, -( 5.2f * sy));
		glVertex3f(  3.0f * sx,   0.0f * sz, -( 0.0f * sy));
	    }
	    glEnd();
	}
	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, 100.0f * sz, -(0.0f * sy));
	    }
	    glEnd();
	}

	/* Restore gl states. */
	StateGLShadeModel(&display->state_gl, shade_model_mode);
}