changeset 2:a40d066ebbd1

implemented zoom
author Zzzzrrr <mason.green@gmail.com>
date Fri, 20 Mar 2009 11:03:51 -0400
parents 8ee020a019e0
children bb77461e0f9f
files boundaryListener.d build-dmd-win.bat contactListener.d main.d melee.d orz.d render.d ship.d steer.d urQuan.d
diffstat 10 files changed, 46 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/boundaryListener.d	Fri Mar 20 09:24:54 2009 -0400
+++ b/boundaryListener.d	Fri Mar 20 11:03:51 2009 -0400
@@ -28,9 +28,9 @@
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-module melee.boundaryListener;
+module openmelee.boundaryListener;
 
-import melee.melee;
+import openmelee.melee;
 
 // bzWorld boundary callback
 class BoundaryListener : bzBoundaryListener
--- a/build-dmd-win.bat	Fri Mar 20 09:24:54 2009 -0400
+++ b/build-dmd-win.bat	Fri Mar 20 11:03:51 2009 -0400
@@ -1,4 +1,3 @@
-::jake -I.. -I../blaze -I../xf/ext zlib.lib -inline -release -O main.d
-rebuild -I.. -I../blaze -I../xf/ext zlib.lib -inline -release -O main.d
-pause
+jake -I.. -I../blaze -I../xf/ext zlib.lib -inline -release -O main.d
+::rebuild -I.. -I../blaze -I../xf/ext zlib.lib -inline -release -O main.d
 
--- a/contactListener.d	Fri Mar 20 09:24:54 2009 -0400
+++ b/contactListener.d	Fri Mar 20 11:03:51 2009 -0400
@@ -28,9 +28,9 @@
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-module melee.contactListener;
+module openmelee.contactListener;
 
-import melee.melee;
+import openmelee.melee;
 
 // bzWorld contact callback
 class ContactListener : bzContactListener
--- a/main.d	Fri Mar 20 09:24:54 2009 -0400
+++ b/main.d	Fri Mar 20 11:03:51 2009 -0400
@@ -27,7 +27,7 @@
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-module melee.main;
+module openmelee.main;
 
 import tango.io.Stdout : Stdout;
 
@@ -42,8 +42,8 @@
 import xf.hybrid.backend.GL;
 import xf.omg.core.LinearAlgebra;
 
-import melee.melee;
-import melee.render;
+import openmelee.melee;
+import openmelee.render;
 
 const ITERS_PER_SECOND = 60;
 
@@ -80,10 +80,10 @@
 
     jobHub.addPreFrameJob( {
         // Clean out the kill list
-        uint[] key = whut.killList.keys;
+        uint[] key = whut.wrapList.keys;
         foreach(k; key) {
-            whut.world.destroyBody(whut.killList[k]);
-            whut.killList.remove(k);
+            //bzVec2 p = whut.wrapList[key].position;            
+            whut.wrapList.remove(k);
         }
     });
 
@@ -93,6 +93,7 @@
         if (gui().getProperty!(bool)("frame.closeClicked")) {
             running = false;
         }
+
 
         if(whut.thrust) {
             whut.ship1.thrust();
@@ -107,6 +108,8 @@
             vec2 p1 = vec2.from(whut.ship1.rBody.position);
             vec2 p2 = vec2.from(whut.ship2.rBody.position);
             vec2 distance = p1 - p2;
+            float d = distance.length;
+            whut.zoom = bzClamp(1/d*1000, 10, 50);
             whut.viewCenter = p1 - (distance * 0.5f);
         }
         
--- a/melee.d	Fri Mar 20 09:24:54 2009 -0400
+++ b/melee.d	Fri Mar 20 11:03:51 2009 -0400
@@ -27,7 +27,7 @@
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-module melee.melee;
+module openmelee.melee;
 
 import Integer = tango.text.convert.Integer;
 import tango.math.Math;
@@ -39,11 +39,11 @@
 
 public import blaze.all;
 
-import melee.boundaryListener;
-import melee.contactListener;
-import melee.ship;
-import melee.urQuan;
-import melee.orz;
+import openmelee.boundaryListener;
+import openmelee.contactListener;
+import openmelee.ship;
+import openmelee.urQuan;
+import openmelee.orz;
 
 // Cursor scale factor
 const CURSORSIZE = 0.05f;
@@ -88,14 +88,14 @@
 
 // Melee settings. Some can be controlled in the GUI.
 struct Settings {
-    float hz                 = 60;
+    float hz = 120;
     int velocityIterations = 8;
     int positionIterations = 2;
     bool drawShapes = true;
     bool drawJoints = true;
     bool drawControllers;
     bool drawCoreShapes;
-    bool drawAABBs;
+    bool drawAABBs = true;
     bool drawOBBs;
     bool drawPairs;
     bool drawContactPoints;
@@ -168,9 +168,8 @@
 
 	void init() {
 	    // Define world boundaries
-		bzAABB worldAABB;
-		worldAABB.lowerBound.set(-200.0f, -100.0f);
-		worldAABB.upperBound.set(200.0f, 200.0f);
+		worldAABB.lowerBound.set(-75.0f, -75.0f);
+		worldAABB.upperBound.set(75.0f, 75.0f);
 		world = new bzWorld(worldAABB, gravity, allowSleep);
 		world.boundaryListener = m_boundaryListener;
 		world.contactListener = m_contactListener;
@@ -268,7 +267,7 @@
 	void boundaryViolated(bzBody rBody)
 	{
         uint key = rBody.toHash();
-        killList[key] = rBody;
+        wrapList[key] = rBody;
 	}
 
 	bool quit;
@@ -277,7 +276,7 @@
 	float zoom = 40;
 	int pointCount;
 	vec2 viewCenter;
-    bzBody[uint] killList;
+    bzBody[uint] wrapList;
 
 	bzWorld world;
 	Settings *settings;
@@ -289,7 +288,8 @@
 
 	ConfigChange!(vec2) editChange;
     bool thrust;
-
+    bzAABB worldAABB;
+    
 	Ship ship1;
 	Ship ship2;
 }
--- a/orz.d	Fri Mar 20 09:24:54 2009 -0400
+++ b/orz.d	Fri Mar 20 11:03:51 2009 -0400
@@ -27,7 +27,7 @@
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-module melee.orz;
+module openmelee.orz;
 
 import tango.io.Stdout;
 
@@ -37,7 +37,7 @@
 import blaze.collision.shapes.bzPolygon : bzPolyDef;
 import blaze.common.bzMath: bzVec2, PI;
 
-import melee.ship;
+import openmelee.ship;
 
 // UrQuan Dreadnought
 class Orz : Ship
--- a/render.d	Fri Mar 20 09:24:54 2009 -0400
+++ b/render.d	Fri Mar 20 11:03:51 2009 -0400
@@ -28,14 +28,14 @@
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-module melee.render;
+module openmelee.render;
 
 import xf.dog.Dog;
 import xf.omg.core.LinearAlgebra;
 import xf.hybrid.Event;
 import xf.hybrid.Font;
 
-import melee.melee;
+import openmelee.melee;
 
 /// Color for drawing. Each value has the range [0,1].
 struct Color {
@@ -317,8 +317,13 @@
     gl.LoadIdentity();
     gl.MatrixMode(GL_PROJECTION);
     gl.LoadIdentity();
-    // Left, right, bottom, top
-    gl.gluOrtho2D(-screenSize.x / zoom, screenSize.x / zoom, -screenSize.y / zoom, screenSize.y / zoom);
+    
+    float left = -screenSize.x / zoom;
+    float right = screenSize.x / zoom;
+    float bottom = -screenSize.y / zoom;
+    float top = screenSize.y / zoom;
+
+    gl.gluOrtho2D(left, right, bottom, top);
     gl.Translatef(-viewCenter.x, -viewCenter.y, 0);
     gl.MatrixMode(GL_MODELVIEW);
     gl.Disable(GL_DEPTH_TEST);
@@ -530,7 +535,7 @@
         bzVec2 invQ;
         invQ.set(1.0f / bp.m_quantizationFactor.x, 1.0f / bp.m_quantizationFactor.y);
         color = Color(1.0f, 1.0f, 1.0f);
-
+        /*
         for (int i = 0; i < k_maxProxies; ++i) {
             bzProxy p = bp.m_proxyPool[i];
             if (!p.isValid) {
@@ -551,7 +556,7 @@
 
             drawPolygon(gl, vs, color);
         }
-
+        */
         vec2 vs[4];
         vs[0] = vec2(worldLower.x, worldLower.y);
         vs[1] = vec2(worldUpper.x, worldLower.y);
--- a/ship.d	Fri Mar 20 09:24:54 2009 -0400
+++ b/ship.d	Fri Mar 20 11:03:51 2009 -0400
@@ -27,7 +27,7 @@
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-module melee.ship;
+module openmelee.ship;
 
 import tango.io.Stdout: Stdout;
 
--- a/steer.d	Fri Mar 20 09:24:54 2009 -0400
+++ b/steer.d	Fri Mar 20 11:03:51 2009 -0400
@@ -41,7 +41,7 @@
 //
 //
 // ----------------------------------------------------------------------------
-module melee.steer;
+module openmelee.steer;
 
     class Steer
     {
--- a/urQuan.d	Fri Mar 20 09:24:54 2009 -0400
+++ b/urQuan.d	Fri Mar 20 11:03:51 2009 -0400
@@ -27,7 +27,7 @@
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-module melee.urQuan;
+module openmelee.urQuan;
 
 import blaze.dynamics.bzBody : bzBody;
 import blaze.bzWorld: bzWorld;
@@ -35,7 +35,7 @@
 import blaze.collision.shapes.bzPolygon : bzPolyDef;
 import blaze.common.bzMath: bzVec2;
 
-import melee.ship;
+import openmelee.ship;
 
 // UrQuan Dreadnought
 class UrQuan : Ship