author | Don Pellegrino <don@drexel.edu> | 2009-06-16 23:25:49 (GMT) |
---|---|---|
committer | Don Pellegrino <don@drexel.edu> | 2009-06-16 23:25:49 (GMT) |
commit | a3cd765827764ec1f8789cc12946d56b1c52416f (patch) (unidiff) | |
tree | 17d1a9fa694beb0503af8f273428db2ff7c0411a | |
parent | 8c98d940aaca2191815a32ed7818f207468e4ac7 (diff) | |
download | exp005-a3cd765827764ec1f8789cc12946d56b1c52416f.zip exp005-a3cd765827764ec1f8789cc12946d56b1c52416f.tar.gz exp005-a3cd765827764ec1f8789cc12946d56b1c52416f.tar.bz2 |
Added use of alpha. Moved origin to the center to make use of
orthographic projection commands easier.
-rw-r--r-- | src/model/exp004base.sqc | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/src/model/exp004base.sqc b/src/model/exp004base.sqc index 6189b72..cbf2291 100644 --- a/src/model/exp004base.sqc +++ b/src/model/exp004base.sqc | |||
@@ -38,12 +38,6 @@ exp004base (void) | |||
38 | 38 | ||
39 | EXEC SQL OPEN c2; | 39 | EXEC SQL OPEN c2; |
40 | 40 | ||
41 | /* | ||
42 | FILE* coords = | ||
43 | fopen ("/home/don/exp004/test/run20090514/run20090514.coords", "r"); | ||
44 | int i = 0; | ||
45 | */ | ||
46 | |||
47 | /* | 41 | /* |
48 | * Initialize the bounding box of the points. | 42 | * Initialize the bounding box of the points. |
49 | */ | 43 | */ |
@@ -52,18 +46,9 @@ exp004base (void) | |||
52 | S.bb.min_y = 0.0; | 46 | S.bb.min_y = 0.0; |
53 | S.bb.max_y = 0.0; | 47 | S.bb.max_y = 0.0; |
54 | 48 | ||
55 | // for (i = 0; i < ROWS; i++) | ||
56 | |||
57 | EXEC SQL FETCH c2 INTO :coordinates; | 49 | EXEC SQL FETCH c2 INTO :coordinates; |
58 | while (sqlca.sqlcode != 100) | 50 | while (sqlca.sqlcode != 100) |
59 | { | 51 | { |
60 | /* | ||
61 | fscanf (coords, "%s %f %f\n", | ||
62 | S.gi_data[i], | ||
63 | &S.base_vertices_data[i][0], | ||
64 | &S.base_vertices_data[i][1]); | ||
65 | */ | ||
66 | |||
67 | int i = coordinates.coord_id; | 52 | int i = coordinates.coord_id; |
68 | 53 | ||
69 | strncpy(S.gi_data[i], | 54 | strncpy(S.gi_data[i], |
@@ -90,15 +75,14 @@ exp004base (void) | |||
90 | S.base_colors_data[i][0] = DEFAULT_COLOR_R; | 75 | S.base_colors_data[i][0] = DEFAULT_COLOR_R; |
91 | S.base_colors_data[i][1] = DEFAULT_COLOR_G; | 76 | S.base_colors_data[i][1] = DEFAULT_COLOR_G; |
92 | S.base_colors_data[i][2] = DEFAULT_COLOR_B; | 77 | S.base_colors_data[i][2] = DEFAULT_COLOR_B; |
78 | S.base_colors_data[i][3] = DEFAULT_COLOR_A; | ||
93 | 79 | ||
94 | EXEC SQL FETCH c2 INTO :coordinates; | 80 | EXEC SQL FETCH c2 INTO :coordinates; |
95 | } | 81 | } |
96 | 82 | ||
97 | EXEC SQL CLOSE c2; | 83 | EXEC SQL CLOSE c2; |
98 | 84 | ||
99 | /* | 85 | EXEC SQL COMMIT; |
100 | fclose (coords); | ||
101 | */ | ||
102 | 86 | ||
103 | /* | 87 | /* |
104 | * Find the largest axis and use it to setup the projection. This | 88 | * Find the largest axis and use it to setup the projection. This |
@@ -126,6 +110,33 @@ exp004base (void) | |||
126 | S.base_vertices_data[i][1] = | 110 | S.base_vertices_data[i][1] = |
127 | S.ortho_max - S.base_vertices_data[i][1]; | 111 | S.ortho_max - S.base_vertices_data[i][1]; |
128 | 112 | ||
113 | // Move the origin (0,0) to the center of the data. | ||
114 | S.ortho_min = 0.0; | ||
115 | S.ortho_max = 0.0; | ||
116 | |||
117 | for (int i = 0; i < ROWS; i++) | ||
118 | { | ||
119 | S.base_vertices_data[i][0] = | ||
120 | S.base_vertices_data[i][0] - | ||
121 | (0.5 * (S.bb.max_x - S.bb.min_x)); | ||
122 | |||
123 | if (S.ortho_min > S.base_vertices_data[i][0]) | ||
124 | S.ortho_min = S.base_vertices_data[i][0]; | ||
125 | |||
126 | if (S.ortho_max < S.base_vertices_data[i][0]) | ||
127 | S.ortho_max = S.base_vertices_data[i][0]; | ||
128 | |||
129 | S.base_vertices_data[i][1] = | ||
130 | S.base_vertices_data[i][1] - | ||
131 | (0.5 * (S.bb.max_y - S.bb.min_y)); | ||
132 | |||
133 | if (S.ortho_min > S.base_vertices_data[i][1]) | ||
134 | S.ortho_min = S.base_vertices_data[i][1]; | ||
135 | |||
136 | if (S.ortho_max < S.base_vertices_data[i][1]) | ||
137 | S.ortho_max = S.base_vertices_data[i][1]; | ||
138 | } | ||
139 | |||
129 | glGenBuffers (2, S.buffers); | 140 | glGenBuffers (2, S.buffers); |
130 | 141 | ||
131 | glBindBuffer (GL_ARRAY_BUFFER, S.buffers[BASE_VERTICES]); | 142 | glBindBuffer (GL_ARRAY_BUFFER, S.buffers[BASE_VERTICES]); |
@@ -135,7 +146,7 @@ exp004base (void) | |||
135 | GL_STATIC_DRAW); | 146 | GL_STATIC_DRAW); |
136 | 147 | ||
137 | glBindBuffer (GL_ARRAY_BUFFER, S.buffers[BASE_COLORS]); | 148 | glBindBuffer (GL_ARRAY_BUFFER, S.buffers[BASE_COLORS]); |
138 | glColorPointer (3, GL_FLOAT, 0, 0); | 149 | glColorPointer (4, GL_FLOAT, 0, 0); |
139 | glBufferData (GL_ARRAY_BUFFER, | 150 | glBufferData (GL_ARRAY_BUFFER, |
140 | sizeof (S.base_colors_data), S.base_colors_data, | 151 | sizeof (S.base_colors_data), S.base_colors_data, |
141 | GL_STATIC_DRAW); | 152 | GL_STATIC_DRAW); |