Browse Source

Updating Roboman3DNew

Josh Engebretson 10 years ago
parent
commit
6393045124
27 changed files with 75 additions and 66 deletions
  1. 0 1
      Roboman3DNew/Resources/Components.asset
  2. 17 7
      Roboman3DNew/Resources/Components/AvatarController.js
  3. 1 1
      Roboman3DNew/Resources/Components/AvatarController.js.asset
  4. 10 6
      Roboman3DNew/Resources/Components/RoboMan.js
  5. 1 1
      Roboman3DNew/Resources/Components/RoboMan.js.asset
  6. 2 0
      Roboman3DNew/Resources/Components/Water.js
  7. 1 1
      Roboman3DNew/Resources/Components/Water.js.asset
  8. 0 1
      Roboman3DNew/Resources/Models.asset
  9. 0 1
      Roboman3DNew/Resources/Models/Materials.asset
  10. 0 1
      Roboman3DNew/Resources/Models/Materials/Crate.Basic.material.asset
  11. 0 1
      Roboman3DNew/Resources/Models/Materials/DefaultMaterial.material.asset
  12. 0 1
      Roboman3DNew/Resources/Models/Materials/Pallet.material.asset
  13. 0 1
      Roboman3DNew/Resources/Models/Materials/Robot_01_mat.material.asset
  14. 0 1
      Roboman3DNew/Resources/Modules.asset
  15. 0 1
      Roboman3DNew/Resources/Prefabs.asset
  16. 5 5
      Roboman3DNew/Resources/Prefabs/Crate.prefab
  17. 1 1
      Roboman3DNew/Resources/Prefabs/Crate.prefab.asset
  18. 8 2
      Roboman3DNew/Resources/Prefabs/Robo_01.prefab
  19. 1 1
      Roboman3DNew/Resources/Prefabs/Robo_01.prefab.asset
  20. 0 1
      Roboman3DNew/Resources/Scenes.asset
  21. 0 1
      Roboman3DNew/Resources/Scenes/EmptyScene.scene.asset
  22. 23 3
      Roboman3DNew/Resources/Scenes/Test.scene
  23. 0 1
      Roboman3DNew/Resources/Scenes/Test.scene.asset
  24. 0 1
      Roboman3DNew/Resources/Scripts.asset
  25. 4 23
      Roboman3DNew/Resources/Scripts/main.js
  26. 1 1
      Roboman3DNew/Resources/Scripts/main.js.asset
  27. 0 1
      Roboman3DNew/Resources/Textures.asset

+ 0 - 1
Roboman3DNew/Resources/Components.asset

@@ -1,6 +1,5 @@
 {
 	"version": 1,
 	"guid": "cfa4a6ce6d3f1dc2b188471e5c110c30",
-	"timestamp": 1436891165,
 	"FolderImporter": {}
 }

+ 17 - 7
Roboman3DNew/Resources/Components/AvatarController.js

@@ -1,15 +1,20 @@
 // designate component
 "atomic component";
 
+var inspectorFields = {
+  speed: 1.0
+}
+
 var glmatrix = require("gl-matrix");
 var quat = glmatrix.quat;
 var vec3 = glmatrix.vec3;
 
 module.exports = function(self) {
 
-  var game = Atomic.game;
   var node = self.node;
 
+  var cameraNode;
+
   var onGround = true;
   var okToJump = true;
   var inAirTime = 0;
@@ -42,6 +47,9 @@ module.exports = function(self) {
 
   self.start = function() {
 
+    var camera = node.scene.getMainCamera();
+    cameraNode = camera.node;
+
     // Create rigidbody, and set non-zero mass so that the body becomes dynamic
     var body = node.createComponent("RigidBody");
     body.mass = 1.0;
@@ -55,7 +63,7 @@ module.exports = function(self) {
 
     // Set a capsule shape for collision
     var shape = node.createComponent("CollisionShape");
-    shape.setCapsule(2, 4, [0, 2, 0]);
+    shape.setCapsule(2, 2, [0, .45, 0]);
 
   }
 
@@ -102,6 +110,10 @@ module.exports = function(self) {
 
     vec3.transformQuat(moveDir, moveDir, [rot[1], rot[2], rot[3], rot[0]]);
     vec3.scale(moveDir, moveDir, (softGrounded ? MOVE_FORCE : INAIR_MOVE_FORCE));
+
+    if (softGrounded)
+      vec3.scale(moveDir, moveDir, self.speed);
+
     body.applyImpulse(moveDir);
 
     if (softGrounded) {
@@ -153,7 +165,6 @@ module.exports = function(self) {
     pitch = 90;
 
     // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
-    var cameraNode = game.cameraNode;
     cameraNode.rotation = QuatFromEuler(pitch, yaw, 0.0);
 
     var speed = MOVE_SPEED * timeStep;
@@ -171,7 +182,7 @@ module.exports = function(self) {
 
   function UpdateControls() {
 
-    var input = game.input;
+    var input = Atomic.input;
 
     moveForward = false;
     moveBackwards = false;
@@ -241,7 +252,6 @@ module.exports = function(self) {
     quat.multiply(dir, [rot[1], rot[2], rot[3], rot[0]], dir);
 
     var headNode = node.getChild("Head_Tip", true);
-    var cameraNode = game.cameraNode;
 
     if (cameraMode == 1) {
 
@@ -256,14 +266,14 @@ module.exports = function(self) {
     }
     if (cameraMode == 0) {
 
-      var aimPoint = node.getPosition();
+      var aimPoint = node.getWorldPosition();
       var aimOffset = [0, 1.7, 0];
       vec3.transformQuat(aimOffset, aimOffset, dir);
       vec3.add(aimPoint, aimPoint, aimOffset);
 
       var rayDir = vec3.create();
       vec3.transformQuat(rayDir, [0, 0, -1], dir);
-      vec3.scale(rayDir, rayDir, 12);
+      vec3.scale(rayDir, rayDir, 8);
 
       vec3.add(aimPoint, aimPoint, rayDir);
 

+ 1 - 1
Roboman3DNew/Resources/Components/AvatarController.js.asset

@@ -1,7 +1,7 @@
 {
 	"version": 1,
 	"guid": "2e6873b92066707b72678a95c1e3d516",
-	"timestamp": 1436891398,
+	"timestamp": 1437770629,
 	"JavascriptImporter": {
 		"IsComponentFile": true
 	}

+ 10 - 6
Roboman3DNew/Resources/Components/RoboMan.js

@@ -3,20 +3,24 @@
 
 module.exports = function(self) {
 
-  var game = Atomic.game;
   var node = self.node;
 
-  RoboMan = self;
-
   var animCtrl = node.getComponent("AnimationController");
-  var controller = node.createJSComponent("Components/AvatarController.js");
+  var controller = node.getJSComponent("AvatarController");
 
   var idle = true;
 
   self.start = function() {
 
-    game.cameraNode.position = [0, 5.5, -10];
-    game.cameraNode.pitch(20);
+    var camera = node.scene.getMainCamera();
+
+    if (camera) {
+
+      camera.node.position = [0, 0, -10];
+      camera.node.pitch(20);
+
+    }
+
     animCtrl.playExclusive("Idle", 0, true, 0.0);
 
     node.yaw(180);

+ 1 - 1
Roboman3DNew/Resources/Components/RoboMan.js.asset

@@ -1,7 +1,7 @@
 {
 	"version": 1,
 	"guid": "440791dfcea47d853282a4d18c03d7e2",
-	"timestamp": 1436891404,
+	"timestamp": 1437770435,
 	"JavascriptImporter": {
 		"IsComponentFile": true
 	}

+ 2 - 0
Roboman3DNew/Resources/Components/Water.js

@@ -11,6 +11,7 @@ exports.fields = {
 
 module.exports = function(self) {
 
+/*
   var game = Atomic.game;
   var node = self.node;
 
@@ -29,5 +30,6 @@ module.exports = function(self) {
   self.update = function(timeStep) {
 
   }
+  */
 
 }

+ 1 - 1
Roboman3DNew/Resources/Components/Water.js.asset

@@ -1,7 +1,7 @@
 {
 	"version": 1,
 	"guid": "ade2d2eee893df6b25df33f9961145d3",
-	"timestamp": 1436891411,
+	"timestamp": 1437768347,
 	"JavascriptImporter": {
 		"IsComponentFile": true
 	}

+ 0 - 1
Roboman3DNew/Resources/Models.asset

@@ -1,6 +1,5 @@
 {
 	"version": 1,
 	"guid": "348ac79570d9570be777b71a3b1b35a4",
-	"timestamp": 1436890665,
 	"FolderImporter": {}
 }

+ 0 - 1
Roboman3DNew/Resources/Models/Materials.asset

@@ -1,6 +1,5 @@
 {
 	"version": 1,
 	"guid": "6624ccbe132ffe065388f0f017b88628",
-	"timestamp": 1436890665,
 	"FolderImporter": {}
 }

+ 0 - 1
Roboman3DNew/Resources/Models/Materials/Crate.Basic.material.asset

@@ -1,6 +1,5 @@
 {
 	"version": 1,
 	"guid": "153f6788464b746c4e34407a27fc2696",
-	"timestamp": 1436890665,
 	"MaterialImporter": {}
 }

+ 0 - 1
Roboman3DNew/Resources/Models/Materials/DefaultMaterial.material.asset

@@ -1,6 +1,5 @@
 {
 	"version": 1,
 	"guid": "b5d7107a4d4aa450e70ca23d82c47141",
-	"timestamp": 1436890665,
 	"MaterialImporter": {}
 }

+ 0 - 1
Roboman3DNew/Resources/Models/Materials/Pallet.material.asset

@@ -1,6 +1,5 @@
 {
 	"version": 1,
 	"guid": "05ba50117cf320362b848bd9c648e2be",
-	"timestamp": 1436890665,
 	"MaterialImporter": {}
 }

+ 0 - 1
Roboman3DNew/Resources/Models/Materials/Robot_01_mat.material.asset

@@ -1,6 +1,5 @@
 {
 	"version": 1,
 	"guid": "75252c6d50e5b9694e30345c8aae1952",
-	"timestamp": 1436890665,
 	"MaterialImporter": {}
 }

+ 0 - 1
Roboman3DNew/Resources/Modules.asset

@@ -1,6 +1,5 @@
 {
 	"version": 1,
 	"guid": "2d68f589bf60bf7dd429f660f25ca57d",
-	"timestamp": 1436891165,
 	"FolderImporter": {}
 }

+ 0 - 1
Roboman3DNew/Resources/Prefabs.asset

@@ -1,6 +1,5 @@
 {
 	"version": 1,
 	"guid": "1795b1cc596f4b279f781c9461680c45",
-	"timestamp": 1436890665,
 	"FolderImporter": {}
 }

+ 5 - 5
Roboman3DNew/Resources/Prefabs/Crate.prefab

@@ -1,21 +1,21 @@
 <?xml version="1.0"?>
-<node id="4240">
+<node id="412">
 	<attribute name="Is Enabled" value="true" />
 	<attribute name="Name" value="Crate_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab_Prefab" />
 	<attribute name="Position" value="0 0 0" />
 	<attribute name="Rotation" value="1 0 0 0" />
 	<attribute name="Scale" value="1 1 1" />
 	<attribute name="Variables" />
-	<component type="StaticModel" id="3575">
+	<component type="StaticModel" id="2010">
 		<attribute name="Model" value="Model;Cache/36ba46e851eaa3896f434f50d34cbda6.mdl" />
 		<attribute name="Material" value="Material;Models/Materials/Crate.Basic.material" />
 		<attribute name="Cast Shadows" value="true" />
 	</component>
-	<component type="CollisionShape" id="3576">
+	<component type="CollisionShape" id="2011">
 		<attribute name="Size" value="2 2 2" />
 	</component>
-	<component type="RigidBody" id="3577">
-		<attribute name="Physics Position" value="-11.9868 11.3833 -31.8202" />
+	<component type="RigidBody" id="2012">
+		<attribute name="Physics Position" value="9.04023 -4.79428 3.41399" />
 		<attribute name="Mass" value="1" />
 		<attribute name="Friction" value="1" />
 	</component>

+ 1 - 1
Roboman3DNew/Resources/Prefabs/Crate.prefab.asset

@@ -1,6 +1,6 @@
 {
 	"version": 1,
 	"guid": "072bfd07fa9aa112119abb43bb133c47",
-	"timestamp": 1436890665,
+	"timestamp": 1437259468,
 	"PrefabImporter": {}
 }

+ 8 - 2
Roboman3DNew/Resources/Prefabs/Robo_01.prefab

@@ -1,8 +1,8 @@
 <?xml version="1.0"?>
-<node id="3691">
+<node id="414">
 	<attribute name="Is Enabled" value="true" />
 	<attribute name="Name" value="Robo_01" />
-	<attribute name="Position" value="0.277899 0.610095 -4.34694" />
+	<attribute name="Position" value="0 0 0" />
 	<attribute name="Rotation" value="1 0 0 0" />
 	<attribute name="Scale" value="1 1 1" />
 	<attribute name="Variables" />
@@ -192,4 +192,10 @@
 	<component type="JSComponent" id="2246">
 		<attribute name="ComponentFile" value="JSComponentFile;Components/RoboMan.js" />
 	</component>
+	<component type="JSComponent" id="2008">
+		<attribute name="FieldValues">
+			<variant hash="273365031" type="Float" value="4" />
+		</attribute>
+		<attribute name="ComponentFile" value="JSComponentFile;Components/AvatarController.js" />
+	</component>
 </node>

+ 1 - 1
Roboman3DNew/Resources/Prefabs/Robo_01.prefab.asset

@@ -1,6 +1,6 @@
 {
 	"version": 1,
 	"guid": "fd7bc91efd0b91d949c35435539dcbc8",
-	"timestamp": 1436890665,
+	"timestamp": 1437770282,
 	"PrefabImporter": {}
 }

+ 0 - 1
Roboman3DNew/Resources/Scenes.asset

@@ -1,6 +1,5 @@
 {
 	"version": 1,
 	"guid": "39542c62040785a46f37e07e6b6f99ce",
-	"timestamp": 1436890665,
 	"FolderImporter": {}
 }

+ 0 - 1
Roboman3DNew/Resources/Scenes/EmptyScene.scene.asset

@@ -1,6 +1,5 @@
 {
 	"version": 1,
 	"guid": "937d43f30dd15e2581bac7095b19f77d",
-	"timestamp": 1436890665,
 	"SceneImporter": {}
 }

+ 23 - 3
Roboman3DNew/Resources/Scenes/Test.scene

@@ -5,8 +5,8 @@
 	<attribute name="Smoothing Constant" value="50" />
 	<attribute name="Snap Threshold" value="5" />
 	<attribute name="Elapsed Time" value="0" />
-	<attribute name="Next Replicated Node ID" value="405" />
-	<attribute name="Next Replicated Component ID" value="2003" />
+	<attribute name="Next Replicated Node ID" value="418" />
+	<attribute name="Next Replicated Component ID" value="2015" />
 	<attribute name="Next Local Node ID" value="16778496" />
 	<attribute name="Next Local Component ID" value="16777216" />
 	<attribute name="Variables" />
@@ -81,7 +81,7 @@
 	<node id="386">
 		<attribute name="Is Enabled" value="true" />
 		<attribute name="Name" value="Robo_01" />
-		<attribute name="Position" value="0 -6.43349 0" />
+		<attribute name="Position" value="0 -5.87418 0" />
 		<attribute name="Rotation" value="1 0 0 0" />
 		<attribute name="Scale" value="1 1 1" />
 		<attribute name="Variables" />
@@ -89,4 +89,24 @@
 			<attribute name="PrefabGUID" value="fd7bc91efd0b91d949c35435539dcbc8" />
 		</component>
 	</node>
+	<node id="407">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="MainCamera" />
+		<attribute name="Position" value="0 0 0" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Camera" id="2004" />
+	</node>
+	<node id="416">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Robo_01" />
+		<attribute name="Position" value="2.57669 -5.76029 0.145561" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="PrefabComponent" id="2010">
+			<attribute name="PrefabGUID" value="fd7bc91efd0b91d949c35435539dcbc8" />
+		</component>
+	</node>
 </scene>

+ 0 - 1
Roboman3DNew/Resources/Scenes/Test.scene.asset

@@ -1,6 +1,5 @@
 {
 	"version": 1,
 	"guid": "627532ce83065783581852967b660c15",
-	"timestamp": 1436890665,
 	"SceneImporter": {}
 }

+ 0 - 1
Roboman3DNew/Resources/Scripts.asset

@@ -1,6 +1,5 @@
 {
 	"version": 1,
 	"guid": "4d56b7fa12e72b41428c6e3f38124ea9",
-	"timestamp": 1436891165,
 	"FolderImporter": {}
 }

+ 4 - 23
Roboman3DNew/Resources/Scripts/main.js

@@ -1,29 +1,10 @@
-
 // This script is the main entry point of the game
 
-require("AtomicGame");
-
-Atomic.game.init(start, update);
-
-// called at the start of play
-function start() {
-
-	var game = Atomic.game;
-
-	// create a 2D scene
-	game.createScene3D("Scenes/Test.scene");
-
-	game.camera.position = [0, 0, -10];
-
-  game.renderer.shadowMapSize = 2048;
+var scene = Atomic.player.loadScene("Scenes/Test.scene");
 
-	game.input.setMouseVisible(false);
-
-
-}
-
-// called per frame
+// called per frame, optional
 function update(timeStep) {
 
-
 }
+
+exports.update = update;

+ 1 - 1
Roboman3DNew/Resources/Scripts/main.js.asset

@@ -1,7 +1,7 @@
 {
 	"version": 1,
 	"guid": "32a79f4468a7351975f6a1fad7e85306",
-	"timestamp": 1436890665,
+	"timestamp": 1437768286,
 	"JavascriptImporter": {
 		"IsComponentFile": false
 	}

+ 0 - 1
Roboman3DNew/Resources/Textures.asset

@@ -1,6 +1,5 @@
 {
 	"version": 1,
 	"guid": "dcf414f72523abe9a89f2dd9685a42bd",
-	"timestamp": 1436890665,
 	"FolderImporter": {}
 }