diff dmmodel.h @ 25:2403030a0352

"Finish" implementing multiple lights support in scene files. If scene defines no lights, a default light will be used. Light objects will have default values and can redefine only color, position etc.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 22 Nov 2019 06:47:13 +0200
parents 03b86b9c2f29
children 1215fdd0a8ab
line wrap: on
line diff
--- a/dmmodel.h	Fri Nov 22 05:49:14 2019 +0200
+++ b/dmmodel.h	Fri Nov 22 06:47:13 2019 +0200
@@ -133,9 +133,10 @@
 };
 
 
-struct DMVector4
+union DMVector4
 {
-    float x, y, z, w;
+    struct { float x, y, z, w; } p;
+    float values[4];
 };
 
 
@@ -183,14 +184,26 @@
 
 struct DMLight
 {
-    DMVector3 pos, pointAt;
-    DMVector4 ambient, diffuse, specular;
+    DMVector4
+        ambient, diffuse, specular,
+        position, pointAt;
+
+    DMLight()
+    {
+        ambient.p.x  = ambient.p.y  = ambient.p.z  = 0.2f; ambient.p.w  = 1.0f;
+        diffuse.p.x  = diffuse.p.y  = diffuse.p.z  = 0.8f; diffuse.p.w  = 1.0f;
+        specular.p.x = specular.p.y = specular.p.z = 0.5f; specular.p.w = 1.0f;
+
+        position.p.x = 10.0f;
+        position.p.y = 10.0f;
+        position.p.z =  0.0f;
+    }
 };
 
 
 struct DMCamera
 {
-    DMVector3 pos, pointAt;
+    DMVector4 position, pointAt;
 };