2 * Copyright (C) <2003> iOS-Software
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #include "goom_plugin_info.h"
26 grid3d_new (int sizex, int defx, int sizez, int defz, v3d center)
30 grid3d *g = malloc (sizeof (grid3d));
31 surf3d *s = &(g->surf);
34 s->vertex = malloc (x * y * sizeof (v3d));
35 s->svertex = malloc (x * y * sizeof (v3d));
49 s->vertex[x + defx * y].x = (float) (x - defx / 2) * sizex / defx;
50 s->vertex[x + defx * y].y = 0;
51 s->vertex[x + defx * y].z = (float) (y - defz / 2) * sizez / defz;
58 grid3d_free (grid3d * g)
60 surf3d *s = &(g->surf);
69 grid3d_draw (PluginInfo * plug, grid3d * g, int color, int colorlow,
70 int dist, Pixel * buf, Pixel * back, int W, int H)
76 v2d *v2_array = malloc (g->surf.nbvertex * sizeof (v2d));
78 v3d_to_v2d (g->surf.svertex, g->surf.nbvertex, W, H, dist, v2_array);
80 for (x = 0; x < g->defx; x++) {
85 for (z = 1; z < g->defz; z++) {
86 v2 = v2_array[z * g->defx + x];
87 if (((v2.x != -666) || (v2.y != -666))
88 && ((v2x.x != -666) || (v2x.y != -666))) {
89 plug->methods.draw_line (buf, v2x.x, v2x.y, v2.x, v2.y, colorlow, W, H);
90 plug->methods.draw_line (back, v2x.x, v2x.y, v2.x, v2.y, color, W, H);
100 surf3d_rotate (surf3d * s, float angle)
106 SINCOS (angle, sina, cosa);
107 for (i = 0; i < s->nbvertex; i++) {
108 Y_ROTATE_V3D (s->vertex[i], s->svertex[i], cosa, sina);
113 surf3d_translate (surf3d * s)
117 for (i = 0; i < s->nbvertex; i++) {
118 TRANSLATE_V3D (s->center, s->svertex[i]);
123 grid3d_update (grid3d * g, float angle, float *vals, float dist)
128 surf3d *s = &(g->surf);
133 SINCOS ((angle / 4.3f), sina, cosa);
134 cam.y += sina * 2.0f;
135 SINCOS (angle, sina, cosa);
139 for (i = 0; i < g->defx; i++)
140 s->vertex[i].y = s->vertex[i].y * 0.2 + vals[i] * 0.8;
142 for (i = g->defx; i < s->nbvertex; i++) {
143 s->vertex[i].y *= 0.255f;
144 s->vertex[i].y += (s->vertex[i - g->defx].y * 0.777f);
148 for (i = 0; i < s->nbvertex; i++) {
149 Y_ROTATE_V3D (s->vertex[i], s->svertex[i], cosa, sina);
150 TRANSLATE_V3D (cam, s->svertex[i]);