Fix accidental switch/teleporter behavior changes
[neverball] / share / solid_gl.c
index 720b05f..82e3bb6 100644 (file)
@@ -25,7 +25,9 @@
 #include "image.h"
 #include "base_image.h"
 #include "solid_gl.h"
+#include "solid_all.h"
 #include "base_config.h"
+#include "lang.h"
 
 /*---------------------------------------------------------------------------*/
 
@@ -71,6 +73,19 @@ static int sol_enum_body(const struct s_file *fp,
 
 /*---------------------------------------------------------------------------*/
 
+int sol_reflective(const struct s_file *fp)
+{
+    int bi;
+
+    for (bi = 0; bi < fp->bc; bi++)
+        if (fp->bv[bi].rl)
+            return 1;
+
+    return 0;
+}
+
+/*---------------------------------------------------------------------------*/
+
 #define tobyte(f) ((GLubyte) (f * 255.0f))
 
 #define color_cmp(a, b) (tobyte((a)[0]) == tobyte((b)[0]) && \
@@ -208,10 +223,10 @@ static const struct s_mtrl *sol_back_bill(const struct s_file *fp,
 
             glBegin(GL_QUADS);
             {
-                glTexCoord2f(0.0f, 1.0f); glVertex2f(-w / 2, y0);
-                glTexCoord2f(1.0f, 1.0f); glVertex2f(+w / 2, y0);
-                glTexCoord2f(1.0f, 0.0f); glVertex2f(+w / 2, y1);
-                glTexCoord2f(0.0f, 0.0f); glVertex2f(-w / 2, y1);
+                glTexCoord2f(0.0f, 0.0f); glVertex2f(-w / 2, y0);
+                glTexCoord2f(1.0f, 0.0f); glVertex2f(+w / 2, y0);
+                glTexCoord2f(1.0f, 1.0f); glVertex2f(+w / 2, y1);
+                glTexCoord2f(0.0f, 1.0f); glVertex2f(-w / 2, y1);
             }
             glEnd();
         }
@@ -333,15 +348,20 @@ static const struct s_mtrl *sol_draw_body(const struct s_file *fp,
 static void sol_draw_list(const struct s_file *fp,
                           const struct s_body *bp, GLuint list)
 {
-    float p[3];
+    float p[3], e[4], u[3], a;
+
+    sol_body_p(p, fp, bp->pi, bp->t);
+    sol_body_e(e, fp, bp, 0);
 
-    sol_body_p(p, fp, bp);
+    q_as_axisangle(e, u, &a);
+    a = V_DEG(a);
 
     glPushMatrix();
     {
-        /* Translate a moving body. */
+        /* Translate and rotate a moving body. */
 
         glTranslatef(p[0], p[1], p[2]);
+        glRotatef(a, u[0], u[1], u[2]);
 
         /* Draw the body. */
 
@@ -373,9 +393,8 @@ void sol_draw(const struct s_file *fp, int depthmask, int depthtest)
     if (depthtest == 0) glEnable(GL_DEPTH_TEST);
 }
 
-void sol_bill(const struct s_file *fp, const float *M)
+void sol_bill(const struct s_file *fp, const float *M, float t)
 {
-    float t = SDL_GetTicks() / 1000.f + 120.0f;
     const struct s_mtrl *mp = &default_mtrl;
 
     int ri;
@@ -407,10 +426,10 @@ void sol_bill(const struct s_file *fp, const float *M)
 
             glBegin(GL_QUADS);
             {
-                glTexCoord2f(0.0f, 1.0f); glVertex2f(-w / 2, -h / 2);
-                glTexCoord2f(1.0f, 1.0f); glVertex2f(+w / 2, -h / 2);
-                glTexCoord2f(1.0f, 0.0f); glVertex2f(+w / 2, +h / 2);
-                glTexCoord2f(0.0f, 0.0f); glVertex2f(-w / 2, +h / 2);
+                glTexCoord2f(0.0f, 0.0f); glVertex2f(-w / 2, -h / 2);
+                glTexCoord2f(1.0f, 0.0f); glVertex2f(+w / 2, -h / 2);
+                glTexCoord2f(1.0f, 1.0f); glVertex2f(+w / 2, +h / 2);
+                glTexCoord2f(0.0f, 1.0f); glVertex2f(-w / 2, +h / 2);
             }
             glEnd();
         }
@@ -494,15 +513,20 @@ static void sol_shad_body(const struct s_file *fp,
 static void sol_shad_list(const struct s_file *fp,
                           const struct s_body *bp, GLuint list)
 {
-    float p[3];
+    float p[3], e[4], u[3], a;
+
+    sol_body_p(p, fp, bp->pi, bp->t);
+    sol_body_e(e, fp, bp, 0);
 
-    sol_body_p(p, fp, bp);
+    q_as_axisangle(e, u, &a);
+    a = V_DEG(a);
 
     glPushMatrix();
     {
-        /* Translate a moving body. */
+        /* Translate and rotate a moving body. */
 
         glTranslatef(p[0], p[1], p[2]);
+        glRotatef(a, u[0], u[1], u[2]);
 
         /* Translate the shadow on a moving body. */
 
@@ -510,6 +534,7 @@ static void sol_shad_list(const struct s_file *fp,
         {
             glPushMatrix();
             glTranslatef(p[0], p[2], 0.0f);
+            glRotatef(-a, u[0], u[2], u[1]);
         }
         glMatrixMode(GL_MODELVIEW);
 
@@ -656,14 +681,14 @@ static GLuint sol_find_texture(const char *name)
     return 0;
 }
 
-static void sol_load_textures(struct s_file *fp, int k)
+static void sol_load_textures(struct s_file *fp)
 {
     int i;
 
     /* Load the image referenced by each material. */
 
     for (i = 0; i < fp->mc; i++)
-        if ((fp->mv[i].o = sol_find_texture(fp->mv[i].f)))
+        if ((fp->mv[i].o = sol_find_texture(_(fp->mv[i].f))))
         {
             /* Set the texture to clamp or repeat based on material type. */
 
@@ -682,11 +707,11 @@ static void sol_load_textures(struct s_file *fp, int k)
 
 /*---------------------------------------------------------------------------*/
 
-int sol_load_gl(struct s_file *fp, const char *filename, int k, int s)
+int sol_load_gl(struct s_file *fp, const char *filename, int s)
 {
     if (sol_load_only_file(fp, filename))
     {
-        sol_load_textures(fp, k);
+        sol_load_textures(fp);
         sol_load_objects (fp, s);
         return 1;
     }