2 #include "goom_plugin_info.h"
8 grid3d_new (int sizex, int defx, int sizez, int defz, v3d center)
12 grid3d *g = malloc (sizeof (grid3d));
13 surf3d *s = &(g->surf);
16 s->vertex = malloc (x * y * sizeof (v3d));
17 s->svertex = malloc (x * y * sizeof (v3d));
31 s->vertex[x + defx * y].x = (float) (x - defx / 2) * sizex / defx;
32 s->vertex[x + defx * y].y = 0;
33 s->vertex[x + defx * y].z = (float) (y - defz / 2) * sizez / defz;
40 grid3d_draw (PluginInfo * plug, grid3d * g, int color, int colorlow,
41 int dist, Pixel * buf, Pixel * back, int W, int H)
47 v2d *v2_array = malloc (g->surf.nbvertex * sizeof (v2d));
49 v3d_to_v2d (g->surf.svertex, g->surf.nbvertex, W, H, dist, v2_array);
51 for (x = 0; x < g->defx; x++) {
56 for (z = 1; z < g->defz; z++) {
57 v2 = v2_array[z * g->defx + x];
58 if (((v2.x != -666) || (v2.y != -666))
59 && ((v2x.x != -666) || (v2x.y != -666))) {
60 plug->methods.draw_line (buf, v2x.x, v2x.y, v2.x, v2.y, colorlow, W, H);
61 plug->methods.draw_line (back, v2x.x, v2x.y, v2.x, v2.y, color, W, H);
71 surf3d_rotate (surf3d * s, float angle)
77 SINCOS (angle, sina, cosa);
78 for (i = 0; i < s->nbvertex; i++) {
79 Y_ROTATE_V3D (s->vertex[i], s->svertex[i], cosa, sina);
84 surf3d_translate (surf3d * s)
88 for (i = 0; i < s->nbvertex; i++) {
89 TRANSLATE_V3D (s->center, s->svertex[i]);
94 grid3d_update (grid3d * g, float angle, float *vals, float dist)
99 surf3d *s = &(g->surf);
104 SINCOS ((angle / 4.3f), sina, cosa);
105 cam.y += sina * 2.0f;
106 SINCOS (angle, sina, cosa);
110 for (i = 0; i < g->defx; i++)
111 s->vertex[i].y = s->vertex[i].y * 0.2 + vals[i] * 0.8;
113 for (i = g->defx; i < s->nbvertex; i++) {
114 s->vertex[i].y *= 0.255f;
115 s->vertex[i].y += (s->vertex[i - g->defx].y * 0.777f);
119 for (i = 0; i < s->nbvertex; i++) {
120 Y_ROTATE_V3D (s->vertex[i], s->svertex[i], cosa, sina);
121 TRANSLATE_V3D (cam, s->svertex[i]);