diff --git a/NHEngine/BootStrap.cs b/NHEngine/BootStrap.cs
index 6dec481..f9068a5 100644
--- a/NHEngine/BootStrap.cs
+++ b/NHEngine/BootStrap.cs
@@ -70,8 +70,7 @@ namespace nhengine
DumpObject dobj = new DumpObject();
dobj.Model3D = ModelManager.instance.loadModel("alfa147",0.0254f);
- Vector3 v3 = map.ground(new Vector2(40,40));
- v3.Z *= 2;
+ Vector3 v3 = map.ground(new Vector2(24,24));
dobj.Position = v3;
glWindow.Scene.RootObject.addChild( dobj );
diff --git a/NHEngine/OpenGLWindow.cs b/NHEngine/OpenGLWindow.cs
index e42f8aa..b54598b 100644
--- a/NHEngine/OpenGLWindow.cs
+++ b/NHEngine/OpenGLWindow.cs
@@ -27,12 +27,13 @@ namespace nhengine
private Cube cube,
c1, c2, c3;
+ private string titleMsg = "";
GLCamera sceneCamera;
GLScene scene;
public OpenGLWindow()
- :base(800, 600,
+ :base(600, 600,
GraphicsMode.Default,
"nhEngine",
GameWindowFlags.Default,
@@ -59,14 +60,11 @@ namespace nhengine
c2 = new Cube(new Vector3(0,150,150), 8.0f);
c3 = new Cube(new Vector3(175,175,150), 8.0f);
- lookAt = new Vector3(0,0,128.0f);
+ lookAt = new Vector3(0,0,SquaredMap.maxHeight);
lookDistance = 2048;
arcUpDown = MathHelper.PiOver6;
arcLeftRight = MathHelper.PiOver4;
-// sceneCamera.Position = new Vector3(1000,-1000,1000);
-// sceneCamera.View = new Vector3(0f,1.0f,0.0f);
- sceneCamera.Top = new Vector3(0,0,1);
sceneCamera.setFoV(MathHelper.PiOver4);
setupCamera();
@@ -95,7 +93,7 @@ namespace nhengine
SwapBuffers();
- Title = string.Format("{0:F}/s {1:F}/s [{2:F}s]", RenderFrequency,UpdateFrequency,UpdatePeriod);
+ Title = string.Format("{0:F}/s {1:F}/s [{2:F}s] {3}", RenderFrequency,UpdateFrequency,UpdatePeriod,titleMsg);
}
protected override void OnUpdateFrame(FrameEventArgs e)
@@ -129,6 +127,8 @@ namespace nhengine
Point delta = new Point(e.X - mouseCapturePosition.X, e.Y - mouseCapturePosition.Y);
onMouseCapturedMove(delta);
mouseCapturePosition = e.Position;
+ } else {
+ markMouse(e.X,e.Y);
}
}
@@ -141,6 +141,7 @@ namespace nhengine
{
switch (e.Button){
case OpenTK.Input.MouseButton.Left:
+ markMouse(e.X,e.Y);
break;
case OpenTK.Input.MouseButton.Right:
captureMouse();
@@ -148,6 +149,23 @@ namespace nhengine
}
}
+ protected void markMouse(float x,float y){
+ try {
+ Vector3 P = sceneCamera.Position;
+ Vector3 V = sceneCamera.pickRay(x,y);
+
+ Vector3 isect = SquaredMap.activeMap.intersect(P,V);
+ Vector2 tile = SquaredMap.activeMap.toTile(isect.Xy);
+
+ SquaredMap.activeMap.highlight(tile);
+
+
+ } catch (OutOfWorldException owe){
+ Console.WriteLine(owe);
+ }
+
+ }
+
protected override void OnMouseUp(OpenTK.Input.MouseButtonEventArgs e)
{
releaseMouse();
@@ -156,7 +174,7 @@ namespace nhengine
protected override void OnMouseWheel(OpenTK.Input.MouseWheelEventArgs e)
{
lookDistance *= 1.0f - ( e.DeltaPrecise / 16 );
- MathHelper.Clamp( lookDistance, 512, 8192 );
+ lookDistance = MathHelper.Clamp( lookDistance, 4, 8192 );
setupCamera();
}
@@ -186,16 +204,34 @@ namespace nhengine
walk(e.Shift ? -50.0f : -5.0f);
break;
case OpenTK.Input.Key.A:
- strafe(e.Shift ? -50.0f : -5.0f);
+ strafe(e.Shift ? 50.0f : 5.0f);
break;
case OpenTK.Input.Key.D:
- strafe(e.Shift ? 50.0f : 5.0f);
+ strafe(e.Shift ? -50.0f : -5.0f);
break;
case OpenTK.Input.Key.Space:
fireBallistic();
break;
-
+
+ case OpenTK.Input.Key.Number1:
+ lookAt = new Vector3(0,0,SquaredMap.maxHeight);
+ arcLeftRight = 0;
+ arcUpDown = MathHelper.PiOver2;
+ setupCamera();
+ break;
+ case OpenTK.Input.Key.Number2:
+ lookAt = new Vector3(0,0,SquaredMap.maxHeight);
+ arcLeftRight = MathHelper.PiOver2;
+ arcUpDown = MathHelper.PiOver2;
+ setupCamera();
+ break;
+ case OpenTK.Input.Key.Number3:
+ lookAt = new Vector3(0,0,SquaredMap.maxHeight);
+ sceneCamera.View = new Vector3(1,1,-1);
+ sceneCamera.Top = new Vector3(0,0,1);
+ break;
+
}
}
@@ -204,7 +240,7 @@ namespace nhengine
BallisticActor ba = new BallisticActor(0);
ba.Position = BootStrap.instance().SquaredMap.ground(new Vector2(10,10));
- ba.Velocity = new Vector3(1,1,1);// + (Matrix4.CreateRotationZ(arcLeftRight) * Vector4.UnitY).Xyz;
+ ba.Velocity = new Vector3(0,1,1);// + (Matrix4.CreateRotationZ(arcLeftRight) * Vector4.UnitY).Xyz;
ba.Velocity.Normalize();
ba.Velocity *= 50;
}
@@ -213,7 +249,7 @@ namespace nhengine
public void rotateUpDown(float arc)
{
arcUpDown += arc;
- arcUpDown = MathHelper.Clamp(arcUpDown,MathHelper.Pi / 8,MathHelper.PiOver2-0.00001f);
+ arcUpDown = MathHelper.Clamp(arcUpDown,MathHelper.Pi / 16,MathHelper.PiOver2);
setupCamera();
}
public void rotateLeftRight(float arc)
@@ -238,12 +274,17 @@ namespace nhengine
}
private void setupCamera(){
- Vector3 view = (Matrix4.CreateRotationZ(arcLeftRight) * Matrix4.CreateRotationX(arcUpDown) * Vector4.UnitY).Xyz;
+ Matrix4 mr = (Matrix4.CreateRotationZ(arcLeftRight) * Matrix4.CreateRotationX(arcUpDown));
+ Vector3 view = (mr * Vector4.UnitY).Xyz;
+ Vector3 top = (mr * Vector4.UnitZ).Xyz;
+
view.Normalize();
+ top.Normalize();
Vector3 pos = lookAt - (view * lookDistance);
sceneCamera.View = view;
+ sceneCamera.Top = top;
sceneCamera.Position = pos;
}
diff --git a/NHEngine/models/ballistisch.obj b/NHEngine/models/ballistisch.obj
index 6d35ef3..00ba638 100644
--- a/NHEngine/models/ballistisch.obj
+++ b/NHEngine/models/ballistisch.obj
@@ -2,70 +2,70 @@
# www.blender.org
mtllib ballistisch.mtl
o Cylinder
-v 0.000000 -1.000000 -0.250000
-v 0.000000 1.000000 -0.250000
-v 0.048773 -1.000000 -0.245196
-v 0.048773 1.000000 -0.245196
-v 0.095671 -1.000000 -0.230970
-v 0.095671 1.000000 -0.230970
-v 0.138893 -1.000000 -0.207867
-v 0.138893 1.000000 -0.207867
-v 0.176777 -1.000000 -0.176777
-v 0.176777 1.000000 -0.176777
-v 0.207867 -1.000000 -0.138893
-v 0.207867 1.000000 -0.138893
-v 0.230970 -1.000000 -0.095671
-v 0.230970 1.000000 -0.095671
-v 0.245196 -1.000000 -0.048773
-v 0.245196 1.000000 -0.048773
-v 0.250000 -1.000000 -0.000000
-v 0.250000 1.000000 -0.000000
-v 0.245196 -1.000000 0.048773
-v 0.245196 1.000000 0.048773
-v 0.230970 -1.000000 0.095671
-v 0.230970 1.000000 0.095671
-v 0.207867 -1.000000 0.138893
-v 0.207867 1.000000 0.138893
-v 0.176777 -1.000000 0.176777
-v 0.176777 1.000000 0.176777
-v 0.138893 -1.000000 0.207867
-v 0.138893 1.000000 0.207867
-v 0.095671 -1.000000 0.230970
-v 0.095671 1.000000 0.230970
-v 0.048773 -1.000000 0.245196
-v 0.048773 1.000000 0.245196
-v -0.000000 -1.000000 0.250000
-v -0.000000 1.000000 0.250000
-v -0.048773 -1.000000 0.245196
-v -0.048773 1.000000 0.245196
-v -0.095671 -1.000000 0.230970
-v -0.095671 1.000000 0.230970
-v -0.138893 -1.000000 0.207867
-v -0.138893 1.000000 0.207867
-v -0.176777 -1.000000 0.176777
-v -0.176777 1.000000 0.176777
-v -0.207868 -1.000000 0.138892
-v -0.207868 1.000000 0.138892
-v -0.230970 -1.000000 0.095671
-v -0.230970 1.000000 0.095671
-v -0.245196 -1.000000 0.048772
-v -0.245196 1.000000 0.048772
-v -0.250000 -1.000000 -0.000000
-v -0.250000 1.000000 -0.000000
-v -0.245196 -1.000000 -0.048773
-v -0.245196 1.000000 -0.048773
-v -0.230970 -1.000000 -0.095671
-v -0.230970 1.000000 -0.095671
-v -0.207867 -1.000000 -0.138893
-v -0.207867 1.000000 -0.138893
-v -0.176776 -1.000000 -0.176777
-v -0.176776 1.000000 -0.176777
-v -0.138892 -1.000000 -0.207868
-v -0.138892 1.000000 -0.207868
-v -0.095671 -1.000000 -0.230970
-v -0.095671 1.000000 -0.230970
-v -0.048772 -1.000000 -0.245196
-v -0.048772 1.000000 -0.245196
+v 0.000000 -4.000000 -0.250000
+v 0.000000 -2.000000 -0.250000
+v 0.048773 -4.000000 -0.245196
+v 0.048773 -2.000000 -0.245196
+v 0.095671 -4.000000 -0.230970
+v 0.095671 -2.000000 -0.230970
+v 0.138893 -4.000000 -0.207867
+v 0.138893 -2.000000 -0.207867
+v 0.176777 -4.000000 -0.176777
+v 0.176777 -2.000000 -0.176777
+v 0.207867 -4.000000 -0.138893
+v 0.207867 -2.000000 -0.138893
+v 0.230970 -4.000000 -0.095671
+v 0.230970 -2.000000 -0.095671
+v 0.245196 -4.000000 -0.048773
+v 0.245196 -2.000000 -0.048773
+v 0.250000 -4.000000 -0.000000
+v 0.250000 -2.000000 -0.000000
+v 0.245196 -4.000000 0.048773
+v 0.245196 -2.000000 0.048773
+v 0.230970 -4.000000 0.095671
+v 0.230970 -2.000000 0.095671
+v 0.207867 -4.000000 0.138893
+v 0.207867 -2.000000 0.138893
+v 0.176777 -4.000000 0.176777
+v 0.176777 -2.000000 0.176777
+v 0.138893 -4.000000 0.207867
+v 0.138893 -2.000000 0.207867
+v 0.095671 -4.000000 0.230970
+v 0.095671 -2.000000 0.230970
+v 0.048773 -4.000000 0.245196
+v 0.048773 -2.000000 0.245196
+v -0.000000 -4.000000 0.250000
+v -0.000000 -2.000000 0.250000
+v -0.048773 -4.000000 0.245196
+v -0.048773 -2.000000 0.245196
+v -0.095671 -4.000000 0.230970
+v -0.095671 -2.000000 0.230970
+v -0.138893 -4.000000 0.207867
+v -0.138893 -2.000000 0.207867
+v -0.176777 -4.000000 0.176777
+v -0.176777 -2.000000 0.176777
+v -0.207868 -4.000000 0.138892
+v -0.207868 -2.000000 0.138892
+v -0.230970 -4.000000 0.095671
+v -0.230970 -2.000000 0.095671
+v -0.245196 -4.000000 0.048772
+v -0.245196 -2.000000 0.048772
+v -0.250000 -4.000000 -0.000000
+v -0.250000 -2.000000 -0.000000
+v -0.245196 -4.000000 -0.048773
+v -0.245196 -2.000000 -0.048773
+v -0.230970 -4.000000 -0.095671
+v -0.230970 -2.000000 -0.095671
+v -0.207867 -4.000000 -0.138893
+v -0.207867 -2.000000 -0.138893
+v -0.176776 -4.000000 -0.176777
+v -0.176776 -2.000000 -0.176777
+v -0.138892 -4.000000 -0.207868
+v -0.138892 -2.000000 -0.207868
+v -0.095671 -4.000000 -0.230970
+v -0.095671 -2.000000 -0.230970
+v -0.048772 -4.000000 -0.245196
+v -0.048772 -2.000000 -0.245196
vn 0.0980 0.0000 -0.9952
vn 0.2903 0.0000 -0.9569
vn 0.4714 0.0000 -0.8819
@@ -96,7 +96,7 @@ vn -0.8819 0.0000 -0.4714
vn -0.7730 0.0000 -0.6344
vn -0.6344 0.0000 -0.7730
vn -0.4714 0.0000 -0.8819
-vn 0.0000 1.0000 0.0000
+vn 0.0000 1.0000 -0.0000
vn -0.2903 0.0000 -0.9569
vn -0.0980 0.0000 -0.9952
vn 0.0000 -1.0000 -0.0000
@@ -137,39 +137,39 @@ f 61//32 62//32 64//32 63//32
f 63//33 64//33 2//33 1//33
f 1//34 3//34 5//34 7//34 9//34 11//34 13//34 15//34 17//34 19//34 21//34 23//34 25//34 27//34 29//34 31//34 33//34 35//34 37//34 39//34 41//34 43//34 45//34 47//34 49//34 51//34 53//34 55//34 57//34 59//34 61//34 63//34
o Cone
-v -0.000000 0.939394 -0.250000
-v 0.048773 0.939394 -0.245196
-v 0.095671 0.939394 -0.230970
-v 0.138893 0.939394 -0.207867
-v 0.176777 0.939394 -0.176777
-v 0.207867 0.939394 -0.138892
-v 0.230970 0.939394 -0.095671
-v 0.245196 0.939394 -0.048773
-v 0.250000 0.939394 0.000000
-v -0.000000 2.939394 0.000000
-v 0.245196 0.939394 0.048773
-v 0.230970 0.939394 0.095671
-v 0.207867 0.939394 0.138893
-v 0.176777 0.939394 0.176777
-v 0.138893 0.939394 0.207867
-v 0.095671 0.939394 0.230970
-v 0.048772 0.939394 0.245196
-v -0.000000 0.939394 0.250000
-v -0.048773 0.939394 0.245196
-v -0.095671 0.939394 0.230970
-v -0.138893 0.939394 0.207867
-v -0.176777 0.939394 0.176777
-v -0.207868 0.939394 0.138892
-v -0.230970 0.939394 0.095671
-v -0.245196 0.939394 0.048772
-v -0.250000 0.939394 -0.000000
-v -0.245196 0.939394 -0.048773
-v -0.230970 0.939394 -0.095671
-v -0.207867 0.939394 -0.138893
-v -0.176776 0.939394 -0.176777
-v -0.138892 0.939394 -0.207868
-v -0.095671 0.939394 -0.230970
-v -0.048772 0.939394 -0.245196
+v -0.000000 -2.060606 -0.250000
+v 0.048773 -2.060606 -0.245196
+v 0.095671 -2.060606 -0.230970
+v 0.138893 -2.060606 -0.207867
+v 0.176777 -2.060606 -0.176777
+v 0.207867 -2.060606 -0.138892
+v 0.230970 -2.060606 -0.095671
+v 0.245196 -2.060606 -0.048773
+v 0.250000 -2.060606 0.000000
+v -0.000000 -0.060606 0.000000
+v 0.245196 -2.060606 0.048773
+v 0.230970 -2.060606 0.095671
+v 0.207867 -2.060606 0.138893
+v 0.176777 -2.060606 0.176777
+v 0.138893 -2.060606 0.207867
+v 0.095671 -2.060606 0.230970
+v 0.048772 -2.060606 0.245196
+v -0.000000 -2.060606 0.250000
+v -0.048773 -2.060606 0.245196
+v -0.095671 -2.060606 0.230970
+v -0.138893 -2.060606 0.207867
+v -0.176777 -2.060606 0.176777
+v -0.207868 -2.060606 0.138892
+v -0.230970 -2.060606 0.095671
+v -0.245196 -2.060606 0.048772
+v -0.250000 -2.060606 -0.000000
+v -0.245196 -2.060606 -0.048773
+v -0.230970 -2.060606 -0.095671
+v -0.207867 -2.060606 -0.138893
+v -0.176776 -2.060606 -0.176777
+v -0.138892 -2.060606 -0.207868
+v -0.095671 -2.060606 -0.230970
+v -0.048772 -2.060606 -0.245196
vn 0.0973 0.1234 -0.9876
vn 0.2881 0.1234 -0.9496
vn 0.4678 0.1234 -0.8752
@@ -202,7 +202,7 @@ vn -0.6295 0.1234 -0.7671
vn -0.4678 0.1234 -0.8752
vn -0.2881 0.1234 -0.9496
vn -0.0973 0.1234 -0.9876
-vn 0.0000 -1.0000 0.0000
+vn 0.0000 -1.0000 -0.0000
usemtl None
s off
f 65//35 74//35 66//35
diff --git a/NHEngine/nhengine.csproj b/NHEngine/nhengine.csproj
index d25d4b8..17c528f 100644
--- a/NHEngine/nhengine.csproj
+++ b/NHEngine/nhengine.csproj
@@ -88,6 +88,10 @@
{3E812F66-D5F3-4599-8360-97F355B6CC1B}
org.niclasundharald.engine
+
+ {56733EC1-7D97-48D0-AA4C-98EA624A5A21}
+ org.hwo.contracts
+
\ No newline at end of file
diff --git a/nhengine.sln b/nhengine.sln
index 40f32e0..4ec0ab8 100644
--- a/nhengine.sln
+++ b/nhengine.sln
@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "org.niclasundharald.engine"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nhengine.Audio", "..\nhengine.Audio\nhengine.Audio\nhengine.Audio.csproj", "{DEFC64FA-45BC-4DA2-A884-66AFA99D34B4}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "org.hwo.contracts", "org.hwo.contracts\org.hwo.contracts.csproj", "{56733EC1-7D97-48D0-AA4C-98EA624A5A21}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -27,17 +29,16 @@ Global
{3E812F66-D5F3-4599-8360-97F355B6CC1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E812F66-D5F3-4599-8360-97F355B6CC1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E812F66-D5F3-4599-8360-97F355B6CC1B}.Release|Any CPU.Build.0 = Release|Any CPU
- {3E812F66-D5F3-4599-8360-97F355B6CC1B}.Debug|x86.ActiveCfg = Debug|Any CPU
- {3E812F66-D5F3-4599-8360-97F355B6CC1B}.Debug|x86.Build.0 = Debug|Any CPU
- {3E812F66-D5F3-4599-8360-97F355B6CC1B}.Release|x86.ActiveCfg = Release|Any CPU
- {3E812F66-D5F3-4599-8360-97F355B6CC1B}.Release|x86.Build.0 = Release|Any CPU
- {DEFC64FA-45BC-4DA2-A884-66AFA99D34B4}.Debug|Any CPU.ActiveCfg = Debug|x86
- {DEFC64FA-45BC-4DA2-A884-66AFA99D34B4}.Debug|Any CPU.Build.0 = Debug|x86
- {DEFC64FA-45BC-4DA2-A884-66AFA99D34B4}.Release|Any CPU.ActiveCfg = Release|x86
- {DEFC64FA-45BC-4DA2-A884-66AFA99D34B4}.Release|Any CPU.Build.0 = Release|x86
- {DEFC64FA-45BC-4DA2-A884-66AFA99D34B4}.Debug|x86.ActiveCfg = Debug|x86
- {DEFC64FA-45BC-4DA2-A884-66AFA99D34B4}.Debug|x86.Build.0 = Debug|x86
- {DEFC64FA-45BC-4DA2-A884-66AFA99D34B4}.Release|x86.ActiveCfg = Release|x86
- {DEFC64FA-45BC-4DA2-A884-66AFA99D34B4}.Release|x86.Build.0 = Release|x86
+ {4D1A7C04-2C4E-4C74-AD81-FE0DCA9C6DF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4D1A7C04-2C4E-4C74-AD81-FE0DCA9C6DF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4D1A7C04-2C4E-4C74-AD81-FE0DCA9C6DF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4D1A7C04-2C4E-4C74-AD81-FE0DCA9C6DF0}.Release|Any CPU.Build.0 = Release|Any CPU
+ {56733EC1-7D97-48D0-AA4C-98EA624A5A21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {56733EC1-7D97-48D0-AA4C-98EA624A5A21}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {56733EC1-7D97-48D0-AA4C-98EA624A5A21}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {56733EC1-7D97-48D0-AA4C-98EA624A5A21}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {4D1A7C04-2C4E-4C74-AD81-FE0DCA9C6DF0} = {9BA2E63F-E39C-465C-AC48-45B30B532A0C}
EndGlobalSection
EndGlobal
diff --git a/org.hwo.contracts/Conditional.cs b/org.hwo.contracts/Conditional.cs
new file mode 100644
index 0000000..2d51975
--- /dev/null
+++ b/org.hwo.contracts/Conditional.cs
@@ -0,0 +1,78 @@
+using System;
+using System.Threading;
+
+namespace org.hwo.contracts
+{
+ public delegate void operDelegate();
+ public delegate T assignDelegate();
+
+ public class Conditional
+ {
+ T valSuccess,
+ valFail;
+
+ bool success;
+
+ public Conditional(T valSuccess,T valFail)
+ {
+ this.valSuccess = valSuccess;
+ this.valFail = valFail;
+ this.success = true;
+ }
+
+ public Conditional requires(bool condition){
+ if (success){
+ success = condition;
+ }
+ return this;
+ }
+
+ public Conditional sets(ref ST target,ST value){
+ if (success){
+ target = value;
+ }
+ return this;
+ }
+
+ public Conditional does(operDelegate operation){
+ if (this.success){
+ operation();
+ }
+ return this;
+ }
+
+ public Conditional assigns(ref AT target,assignDelegate assigner){
+ if (success){
+ target = assigner();
+ }
+ return this;
+ }
+
+ public bool isSuccess(){
+ return this.success;
+ }
+
+ public Conditional throws(string message) where E: Exception{
+ if (!success){
+ E ex = (E)typeof(E).GetConstructor(new Type[]{typeof(string)}).Invoke(new object[]{message});
+ throw ex;
+ }
+ return this;
+ }
+
+ public Conditional throws() where E: Exception{
+ if (!success){
+ E ex = (E)typeof(E).GetConstructor(new Type[]{}).Invoke(new object[]{});
+ throw ex;
+ }
+ return this;
+ }
+
+ }
+
+ public class BooleanConditional : Conditional{
+ public BooleanConditional()
+ :base(true,false){
+ }
+ }
+}
diff --git a/org.hwo.contracts/Properties/AssemblyInfo.cs b/org.hwo.contracts/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..f8080c1
--- /dev/null
+++ b/org.hwo.contracts/Properties/AssemblyInfo.cs
@@ -0,0 +1,26 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("org.hwo.contracts")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("${AuthorCopyright}")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
diff --git a/org.hwo.contracts/org.hwo.contracts.csproj b/org.hwo.contracts/org.hwo.contracts.csproj
new file mode 100644
index 0000000..ee3bbdc
--- /dev/null
+++ b/org.hwo.contracts/org.hwo.contracts.csproj
@@ -0,0 +1,37 @@
+
+
+
+ Debug
+ AnyCPU
+ {56733EC1-7D97-48D0-AA4C-98EA624A5A21}
+ Library
+ org.hwo.contracts
+ org.hwo.contracts
+ v4.5
+
+
+ true
+ full
+ false
+ bin\Debug
+ DEBUG;
+ prompt
+ 4
+ false
+
+
+ true
+ bin\Release
+ prompt
+ 4
+ false
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/org.niclasundharald.engine/ArrayHelper.cs b/org.niclasundharald.engine/ArrayHelper.cs
new file mode 100644
index 0000000..98fedff
--- /dev/null
+++ b/org.niclasundharald.engine/ArrayHelper.cs
@@ -0,0 +1,13 @@
+using System;
+
+
+namespace org.niclasundharald.engine
+{
+ public static class ArrayHelper
+ {
+ public static void Fill(this T[] array,T value){
+ for (int n=0;n
+ *
+ * -n * V + i * (B-A) + j * (C-A) = P-A
+ *
+ * out p : receives the cooefficients of the solved equation (n,i,j)
+ *
+ **/
+ public static bool intersectPlainCoeff(Vector3 P,Vector3 V,Vector3 A,Vector3 B,Vector3 C,out Vector3 p){
+ Vector3 BA,CA,PA;
+ Vector3 coeff = new Vector3();
+ p = coeff;
+
+ BA = B-A;
+ CA = C-A;
+ PA = P-A;
+/*
+ Console.WriteLine("Interesction:");
+ Console.WriteLine("Ray: {0} + i * {1}",P,V);
+ Console.WriteLine("A: {0}",A);
+ Console.WriteLine("B: {0}",B);
+ Console.WriteLine("C: {0}",C);
+*/
+ return new BooleanConditional()
+ .requires(Linear.Solve4x3(V,BA,CA,PA,out coeff))
+ .does(delegate { coeff.X = -coeff.X;})
+ .sets(ref p,coeff)
+ .isSuccess();
+ }
+
+ public static bool intersectPlain(Vector3 P,Vector3 V,Vector3 A,Vector3 B,Vector3 C,out Vector3 p){
+ Vector3 coeff = new Vector3();
+ p = new Vector3();
+
+ return new BooleanConditional()
+ .requires(intersectPlainCoeff(P,V,A,B,C,out coeff))
+ .assigns(ref p, delegate { return A + (coeff.Y * (B-A)) + (coeff.Z * (C-A)); })
+ .isSuccess();
+ }
+
+ public static bool intersectPlainForward(Vector3 P,Vector3 V,Vector3 A,Vector3 B,Vector3 C,out Vector3 p){
+ Vector3 coeff = new Vector3();
+ p = new Vector3();
+
+ return new BooleanConditional()
+ .requires(intersectPlainCoeff(P,V,A,B,C,out coeff))
+ .requires(coeff.X > 0)
+ .assigns(ref p, delegate { return P + (coeff.X * V); })
+ .isSuccess();
+ }
+
+ public static bool intersectPlainRect(Vector3 P,Vector3 V,Vector3 A,Vector3 B,Vector3 C,out Vector3 p){
+ Vector3 coeff = new Vector3();
+ p = new Vector3();
+
+ return new BooleanConditional()
+ .requires(intersectPlainCoeff(P,V,A,B,C,out coeff))
+ .requires(coeff.Y >= 0)
+ .requires(coeff.Z >= 0)
+ .requires(coeff.Y <= 1)
+ .requires(coeff.Z <= 1)
+ .assigns(ref p, delegate { return P + (coeff.X * V); })
+ .isSuccess();
+ }
+
+ public static bool intersectTriangle(Vector3 P,Vector3 V,Vector3 A,Vector3 B,Vector3 C,out Vector3 p){
+ Vector3 coeff = new Vector3();
+ p = new Vector3();
+
+ return new BooleanConditional()
+ .requires(intersectPlainCoeff(P,V,A,B,C,out coeff))
+ .requires(coeff.Y >= 0)
+ .requires(coeff.Z >= 0)
+ .requires(coeff.Y <= 1)
+ .requires(coeff.Z <= 1)
+ .requires(coeff.Y + coeff.Z <= 1)
+ .assigns(ref p, delegate { return A + (coeff.Y * (B-A)) + (coeff.Z * (C-A)); })
+ .isSuccess();
+ }
+
+ }
+}
diff --git a/org.niclasundharald.engine/Linear.cs b/org.niclasundharald.engine/Linear.cs
new file mode 100644
index 0000000..e044587
--- /dev/null
+++ b/org.niclasundharald.engine/Linear.cs
@@ -0,0 +1,68 @@
+using System;
+using OpenTK;
+
+namespace org.niclasundharald.engine
+{
+ public static class Linear
+ {
+ static public bool Solve4x3(Vector3 X,Vector3 Y,Vector3 Z,Vector3 W,out Vector3 c)
+ {
+ Vector4[] rows = new Vector4[3];
+ rows[0] = new Vector4(X.X,Y.X,Z.X,W.X);
+ rows[1] = new Vector4(X.Y,Y.Y,Z.Y,W.Y);
+ rows[2] = new Vector4(X.Z,Y.Z,Z.Z,W.Z);
+ c = new Vector3();
+
+ /*
+ Console.WriteLine("Solver Unsolved:");
+ Console.WriteLine("X: {0}",rows[0]);
+ Console.WriteLine("Y: {0}",rows[1]);
+ Console.WriteLine("Z: {0}",rows[2]);
+*/
+
+ if (rows[0].Z == 0){
+ Vector4 t = rows[0];
+ rows[0] = rows[2];
+ rows[2] = t;
+ }
+ if (rows[0].Z == 0){
+ Vector4 t = rows[0];
+ rows[0] = rows[1];
+ rows[1] = t;
+ }
+
+ if (rows[0].Z == 0){
+ return false;
+ } else {
+ rows[1] -= rows[0] * (rows[1].Z / rows[0].Z);
+ rows[2] -= rows[0] * (rows[2].Z / rows[0].Z);
+ }
+
+ if (rows[1].Y == 0){
+ Vector4 t = rows[1];
+ rows[1] = rows[2];
+ rows[2] = t;
+ }
+
+ if (rows[1].Y == 0){
+ return false;
+ } else {
+ rows[2] -= rows[1] * (rows[2].Y / rows[1].Y);
+ }
+
+ rows[2] /= rows[2].X;
+
+ c.X = rows[2].W;
+ c.Y = (rows[1].W - (rows[1].X * c.X)) / rows[1].Y;
+ c.Z = (rows[0].W - (rows[0].X * c.X) - (rows[0].Y * c.Y)) / rows[0].Z;
+ /*
+ Console.WriteLine("Solver Solved:");
+ Console.WriteLine("X: {0}",rows[0]);
+ Console.WriteLine("Y: {0}",rows[1]);
+ Console.WriteLine("Z: {0}",rows[2]);
+ Console.WriteLine("P: {0}",c);
+ */
+ return true;
+ }
+ }
+}
diff --git a/org.niclasundharald.engine/graphics/GLCamera.cs b/org.niclasundharald.engine/graphics/GLCamera.cs
index bb3ff44..60d999e 100644
--- a/org.niclasundharald.engine/graphics/GLCamera.cs
+++ b/org.niclasundharald.engine/graphics/GLCamera.cs
@@ -10,6 +10,7 @@ namespace org.niclasundharald.engine.graphics
{
float fov;
float width, height;
+ float aspect;
Vector3 vPosition,
vView,
@@ -20,6 +21,7 @@ namespace org.niclasundharald.engine.graphics
fov = MathHelper.PiOver2;
width = 100;
height = 100;
+ aspect = 1;
vPosition = new Vector3(0,0,1000);
vView = new Vector3(0,0,-1);
@@ -42,12 +44,14 @@ namespace org.niclasundharald.engine.graphics
}
private void buildProjection(){
+ aspect = width / height;
+
_mProjection = Matrix4.CreatePerspectiveFieldOfView(
fov,
- width / height,
+ aspect,
1.0f,
100000.0f
- );
+ );
}
public Vector3 Position
@@ -87,6 +91,46 @@ namespace org.niclasundharald.engine.graphics
_mCamera = mTranslation * mRotation;
}
+ public Vector3 pickRay(float x,float y){
+ float y_arc,x_arc;
+
+ x_arc = (( (2*x) ) - width) * aspect;
+ y_arc = height - ( (2*y) );
+
+ x_arc /= width;
+ y_arc /= height;
+
+ Vector4 ray = new Vector4(x_arc,y_arc,1,1);
+
+ Console.WriteLine("Pick Ray: {0}",ray);
+ Matrix4 mpi = _mProjection.Inverted();
+ mpi.Transpose();
+ ray = mpi * ray;
+ ray.Normalize();
+ Console.WriteLine("Pick Ray (PROJ): {0}",ray);
+
+// ray.Z = -1;
+// ray.W = 0;
+
+ //Console.WriteLine("Pick Ray (CAM): {0}",ray);
+ Matrix4 mci = _mCamera.Inverted();
+ mci.Transpose();
+ ray = mci * ray;
+
+ Console.WriteLine("Pick Ray (CAM): {0}",ray);
+
+ //Console.WriteLine("Pick Ray Angles: x:{0} / y:{1}",x_arc,y_arc);
+ //ray = Matrix4.CreateRotationY(-y_arc) * Matrix4.CreateRotationX( x_arc ) * ray;
+
+ Vector3 pr = ray.Xyz.Normalized();
+ if (pr.Z > 0){
+ pr *= -1;
+ }
+
+ Console.WriteLine("Pick Ray (World): {0}",pr);
+ Console.WriteLine("--------------------------------------------------");
+ return pr;
+ }
}
}
diff --git a/org.niclasundharald.engine/graphics/GlobalDefaults.cs b/org.niclasundharald.engine/graphics/GlobalDefaults.cs
index 860405c..8342630 100644
--- a/org.niclasundharald.engine/graphics/GlobalDefaults.cs
+++ b/org.niclasundharald.engine/graphics/GlobalDefaults.cs
@@ -52,10 +52,11 @@ namespace org.niclasundharald.engine.graphics
private string defVertexShaderSource = @"#version 330
-in vec3 iv_position;
-in vec4 iv_color;
-in vec3 iv_normal;
-in vec2 iv_uv;
+layout(location = 0) in vec3 iv_position;
+layout(location = 1) in vec4 iv_color;
+layout(location = 2) in vec3 iv_normal;
+layout(location = 3) in vec4 iv_col2;
+layout(location = 4) in vec2 iv_uv;
uniform mat4 mObject;
uniform mat4 mCamera;
@@ -87,7 +88,7 @@ void main()
float sight = clamp( idist * idist * idist, 0.1, 1.0);
shading = clamp(0.3 + (cosTheta * 0.7), 0.1, 0.9) * sight;
- color = clamp( vec4( iv_color.xyz, fading ), 0, 1);
+ color = clamp( vec4( iv_color.xyz, fading ) * iv_col2, 0, 1);
coord = camray;
}
diff --git a/org.niclasundharald.engine/graphics/LoadedModel.cs b/org.niclasundharald.engine/graphics/LoadedModel.cs
index 98190e8..9f43618 100644
--- a/org.niclasundharald.engine/graphics/LoadedModel.cs
+++ b/org.niclasundharald.engine/graphics/LoadedModel.cs
@@ -27,7 +27,6 @@ namespace org.niclasundharald.engine.graphics
}
private void load(TextReader reader,float scale){
List vertexes,normals;
- List colors;
List triangles;
string line;
@@ -36,7 +35,6 @@ namespace org.niclasundharald.engine.graphics
vertexes = new List();
normals = new List();
- colors = new List();
triangles = new List();
vertexes.Add(new Vector3());
@@ -66,7 +64,7 @@ namespace org.niclasundharald.engine.graphics
max[2] = max[2] < z ? z : max[2];
break;
case "vn":
- normals.Add( -(new Vector3(
+ normals.Add( (new Vector3(
float.Parse(fields[1],CultureInfo.InvariantCulture),
float.Parse(fields[2],CultureInfo.InvariantCulture),
float.Parse(fields[3],CultureInfo.InvariantCulture)
@@ -102,13 +100,15 @@ namespace org.niclasundharald.engine.graphics
vertexes.Add( t.a );
vertexes.Add( t.b );
vertexes.Add( t.c );
- normals.Add( t.na );
- normals.Add( t.nb );
- normals.Add( t.nc );
+ normals.Add( -t.na );
+ normals.Add( -t.nb );
+ normals.Add( -t.nc );
}
- // bind(vertexes.ToArray(),null,normals.ToArray());
- bind(vertexes.ToArray(),null,normals.ToArray());
+ this.vertexes = vertexes.ToArray();
+ this.normals = normals.ToArray();
+
+ bind();
}
diff --git a/org.niclasundharald.engine/graphics/Model3D.cs b/org.niclasundharald.engine/graphics/Model3D.cs
index ff3fadd..8e3d738 100644
--- a/org.niclasundharald.engine/graphics/Model3D.cs
+++ b/org.niclasundharald.engine/graphics/Model3D.cs
@@ -3,6 +3,8 @@ using System;
using OpenTK.Graphics.OpenGL;
using OpenTK;
+using org.niclasundharald.engine;
+
namespace org.niclasundharald.engine.graphics {
public class Model3D {
@@ -10,13 +12,17 @@ namespace org.niclasundharald.engine.graphics {
protected int vao,
vbo, // Vertex Buffer
cbo, // Color Buffer
+ cbo2, // Second Color Buffer
nbo; // Normals Buffer
protected int nTriangles;
- Vector3[] vertexes;
- Vector4[] colors;
- Vector3[] normals;
+ public Vector3[] vertexes = null;
+ public Vector4[] colors = null;
+ public Vector4[] colors2 = null;
+ public Vector3[] normals = null;
+
+ public Triangle[] triangles = new Triangle[0];
protected Model3D(){
@@ -29,6 +35,7 @@ namespace org.niclasundharald.engine.graphics {
protected void prepare(){
vbo = GL.GenBuffer();
cbo = GL.GenBuffer();
+ cbo2 = GL.GenBuffer();
nbo = GL.GenBuffer();
GL.BindVertexArray(vao);
@@ -57,68 +64,125 @@ namespace org.niclasundharald.engine.graphics {
0,
0);
+ GL.BindBuffer(BufferTarget.ArrayBuffer, cbo);
+ GL.VertexAttribPointer(3,
+ 4,
+ VertexAttribPointerType.Float,
+ false,
+ 0,
+ 0);
+
GL.BindVertexArray(0);
}
- protected void rebind(){
-
+ public void prepareBuffers(int nTriangles){
+ this.vertexes = new Vector3[nTriangles * 3];
+ this.normals = new Vector3[nTriangles * 3];
+ this.colors = new Vector4[nTriangles * 3];
+ this.colors2 = new Vector4[nTriangles * 3];
+
+ this.vertexes.Fill(new Vector3(0,0,0));
+ this.colors.Fill(new Vector4(0.5f,0.5f,0.5f,1.0f));
+ this.colors2.Fill(new Vector4(0.0f,2.0f,0.0f,1.0f));
+
+ this.nTriangles = nTriangles;
+ rebind();
}
- protected void bind(Vector3[] vertexes){
- bind( vertexes, null, null, null );
- }
-
- protected void bind(Vector3[] vertexes,Vector4[] colors){
- bind( vertexes, colors, null, null );
- }
-
- protected void bind(Vector3[] vertexes,Vector4[] colors,Vector3[] normals){
- bind( vertexes, colors, normals, null );
- }
-
- protected void bind(Vector3[] vertexes,Vector4[] colors,Vector3[] normals,Vector2[] uvs){
-/* float[] fv = new float[vertexes.Length * 3];
-
- for (int n=0;n(ref this.triangles,nTriangles);
- for (int n=0;n=width)||(xy.Y>=height)){
throw new OutOfWorldException();
}
- float h = heightMap[i1] +
- heightMap[i1 + 1] +
- heightMap[i2] +
- heightMap[i2 + 1];
+ int i1 = tileIndex((int)xy.X,(int)xy.Y);
- h /= 4;
+ for (int n=0;n<4;n++){
+ Vector3 A,B,C,P,V;
+ Vector3 p = new Vector3();
- Vector3 v3 = new Vector3(_xy.X,_xy.Y,h);
- Console.WriteLine("Grounding: {0}",v3);
+ A = model.triangles[i1+n].VertexA;
+ B = model.triangles[i1+n].VertexB;
+ C = model.triangles[i1+n].VertexC;
- return v3;
+ P = new Vector3(_xy);
+ V = Vector3.UnitZ;
+
+ if (Geometry.intersectTriangle(P,V,A,B,C,out p)){
+ Console.WriteLine("Grounded to: {0}",p);
+ return p;
+ } else {
+ Console.WriteLine("No Ground at triangle {0}",n);
+ }
+
+ }
+
+ throw new OutOfWorldException();
}
+ public Vector2 toTileBorderless(Vector2 world){
+ Vector2 tile = world / edge;
+ return tile;
+ }
+
+ public Vector2 toTile(Vector2 world){
+ Vector2 tile = new Vector2();
+
+ new BooleanConditional()
+ .does(delegate { tile = world / edge; })
+ .requires(tile.X >= 0)
+ .requires(tile.Y >= 0)
+ .requires(tile.X < width)
+ .requires(tile.Y < height)
+ .throws();
+
+ return tile;
+ }
+
+ public Vector2 intersectTile(Vector3 P,Vector3 V){
+ return toTile( intersect(P,V).Xy );
+ }
+
+ public Vector3 intersect(Vector3 P,Vector3 V){
+ Vector3
+ A = new Vector3(), // Lower plane intersection
+ B = new Vector3(); // Upper plane intersection
+
+ Console.WriteLine("P: {0} V: {1}",P,V);
+
+ if (!Geometry.intersectPlain(P,V,corners[0],corners[1],corners[3],out A)){
+ throw new OutOfWorldException();
+ }
+
+ if (!Geometry.intersectPlain(P,V,corners[4],corners[5],corners[7],out B)){
+ throw new OutOfWorldException();
+ }
+
+ Console.WriteLine("Lower Plane Intersection (LIN): {0}",A);
+ A = P + ( V * ( -P.Z / V.Z) );
+ Console.WriteLine("Lower Plane Intersection: {0}",A);
+
+ Console.WriteLine("Higher Plane Intersection (LIN): {0}",B);
+ B = P + ( V * ( (SquaredMap.maxHeight-P.Z) / V.Z) );
+ Console.WriteLine("Higher Plane Intersection: {0}",B);
+
+ Vector2 a,b,min,max;
+
+ a = toTileBorderless(A.Xy);
+ b = toTileBorderless(B.Xy);
+
+ min = Vector2.ComponentMax(Vector2.ComponentMin(a,b)-new Vector2(1,1),new Vector2());
+ max = Vector2.ComponentMin(Vector2.ComponentMax(a,b)+new Vector2(1,1),new Vector2(width,height));
+
+ Console.WriteLine("Checking Intersections: {0} -> {1}",min,max);
+
+ for (int nx = (int)min.X; nx < max.X; nx++){
+ for (int ny = (int)min.Y; ny < max.Y; ny++){
+ Vector3 isect = new Vector3();
+ //Console.WriteLine("Check Intersection: {0}/{1}",nx,ny);
+
+ for (int n=0;n<4;n++){
+ try {
+ Model3D.Triangle t = model.triangles[tileIndex(nx,ny)];
+ if (Geometry.intersectTriangle(
+ P,
+ V,
+ t.VertexA,
+ t.VertexB,
+ t.VertexC,
+ out isect
+ )){
+ return isect;
+ }
+
+ } catch (OutOfWorldException owe){
+ }
+ }
+ }
+ }
+
+ throw new OutOfWorldException();
+ }
+
+ public void highlight(Vector2 tile){
+ new BooleanConditional()
+ .requires(tile.X >= 0)
+ .requires(tile.Y >= 0)
+ .requires(tile.X < width)
+ .requires(tile.Y < height)
+ .does(delegate {
+
+ for (int n=0;n<4;n++){
+ Model3D.Triangle t = model.triangles[tileIndex((int)tile.X,(int)tile.Y)+n];
+ t.ColorA *= 2;
+ t.ColorB *= 2;
+ t.ColorC *= 2;
+ }
+
+ model.rebind();
+ });
+ }
+
+
}
class MapModel3D : Model3D {
- int nDraw;
- public MapModel3D(Vector3[] vertexes){
+ SquaredMap map;
- Vector4[] colors = new Vector4[ vertexes.Length ];
-
- for (int n=0; n< vertexes.Length; n++){
-
- if (vertexes[n].Z >= 256 ){
- Console.WriteLine("Max. Height : {0}",vertexes[n].Z / 256);
- }
+ public MapModel3D(SquaredMap map,int width,int height){
+ this.map = map;
+ prepareBuffers(width * height * 4);
+ colorMap();
+ }
+ public void colorMap(){
+ for (int n=0; n < vertexes.Length; n++){
colors[n] = new Vector4(
- 0.50f + (0.2f * vertexes[n].Z / 256),
- 0.25f + (0.50f * vertexes[n].Z / 256),
- 0.10f + (0.80f * vertexes[n].Z / 256),
- 1.0f
- );
+ 0.50f + (0.2f * vertexes[n].Z / SquaredMap.maxHeight),
+ 0.25f + (0.50f * vertexes[n].Z / SquaredMap.maxHeight),
+ 0.10f + (0.80f * vertexes[n].Z / SquaredMap.maxHeight),
+ 1.0f
+ );
}
-
- Vector3[] normals = Model3D.computeNormals(vertexes);
-
- Dictionary> dNormals = new Dictionary>();
-
- foreach (Vector3 v in vertexes){
- if (!dNormals.ContainsKey(v)){
- dNormals.Add(v,new List());
- }
- }
-
- for (int n=0;n> 8;
- if (nDraw > nTriangles){
- nDraw = 0;
- }
-
- nDraw = nTriangles;
-
- GL.BindVertexArray(this.vao);
- GL.DrawArrays(PrimitiveType.Triangles, 0, nDraw * 3);
- GL.BindVertexArray(0);
- }
-
}
diff --git a/org.niclasundharald.engine/graphics/primitives/Cube.cs b/org.niclasundharald.engine/graphics/primitives/Cube.cs
index 754bc82..a3b9df7 100644
--- a/org.niclasundharald.engine/graphics/primitives/Cube.cs
+++ b/org.niclasundharald.engine/graphics/primitives/Cube.cs
@@ -21,7 +21,7 @@ namespace org.niclasundharald.engine.graphics.primitives
class CubeModel : Model3D {
- public static Vector4[] colors = new Vector4[]{
+ public static Vector4[] ccolors = new Vector4[]{
new Vector4(1.0f,0.0f,0.0f,1.0f),
new Vector4(1.0f,0.0f,0.0f,1.0f),
new Vector4(1.0f,0.0f,0.0f,1.0f),
@@ -55,30 +55,30 @@ namespace org.niclasundharald.engine.graphics.primitives
g = dx + dy + dz;
h = - dx + dy + dz;
- Vector3[] vertexes = new Vector3[36];
+ prepareBuffers(12);
- Model3D.setTriangle(vertexes, 0, a, b, c);
- Model3D.setTriangle(vertexes, 1, c, d, a);
- Model3D.setTriangle(vertexes, 2, f, e, h);
- Model3D.setTriangle(vertexes, 3, h, g, f);
+ Model3D.setTriangle(vertexes, 0, c, b, a);
+ Model3D.setTriangle(vertexes, 1, a, d, c);
+ Model3D.setTriangle(vertexes, 2, h, e, f);
+ Model3D.setTriangle(vertexes, 3, f, g, h);
- Model3D.setTriangle(vertexes, 4, e, a, d);
- Model3D.setTriangle(vertexes, 5, d, h, e);
- Model3D.setTriangle(vertexes, 6, b, f, g);
- Model3D.setTriangle(vertexes, 7, g, c, b);
+ Model3D.setTriangle(vertexes, 4, d, a, e);
+ Model3D.setTriangle(vertexes, 5, e, h, d);
+ Model3D.setTriangle(vertexes, 6, g, f, b);
+ Model3D.setTriangle(vertexes, 7, b, c, g);
- Model3D.setTriangle(vertexes, 8, a, e, f);
- Model3D.setTriangle(vertexes, 9, f, b, a);
- Model3D.setTriangle(vertexes, 10, g, h, d);
- Model3D.setTriangle(vertexes, 11, d, c, g);
-
- Vector4[] colors = new Vector4[ vertexes.Length ];
+ Model3D.setTriangle(vertexes, 8, f, e, a);
+ Model3D.setTriangle(vertexes, 9, a, b, f);
+ Model3D.setTriangle(vertexes, 10, d, h, g);
+ Model3D.setTriangle(vertexes, 11, g, c, d);
for (int n=0;n
+
+
+
+
+
+
+
+
+
+
+
@@ -62,5 +73,11 @@
+
+
+ {56733EC1-7D97-48D0-AA4C-98EA624A5A21}
+ org.hwo.contracts
+
+
-
\ No newline at end of file
+