Josh Engebretson преди 10 години
родител
ревизия
59ec6d3bb2
променени са 28 файла, в които са добавени 229 реда и са изтрити 158 реда
  1. 0 92
      RenderToTexture/Resources/Components/RenderBox.js
  2. 1 0
      UISceneView2D/.gitignore
  3. 5 0
      UISceneView2D/Resources.asset
  4. 5 0
      UISceneView2D/Resources/Components.asset
  5. 20 47
      UISceneView2D/Resources/Components/UI.js
  6. 7 0
      UISceneView2D/Resources/Components/UI.js.asset
  7. 5 0
      UISceneView2D/Resources/Scenes.asset
  8. 59 0
      UISceneView2D/Resources/Scenes/2DScene.scene
  9. 5 0
      UISceneView2D/Resources/Scenes/2DScene.scene.asset
  10. 42 0
      UISceneView2D/Resources/Scenes/MainScene.scene
  11. 5 0
      UISceneView2D/Resources/Scenes/MainScene.scene.asset
  12. 5 0
      UISceneView2D/Resources/Scripts.asset
  13. 4 17
      UISceneView2D/Resources/Scripts/main.js
  14. 1 1
      UISceneView2D/Resources/Scripts/main.js.asset
  15. 0 1
      UISceneView2D/Resources/Skin/skin.ui.txt
  16. 5 0
      UISceneView2D/Resources/Sprites.asset
  17. 5 0
      UISceneView2D/Resources/Sprites/imp.scml.asset
  18. 5 0
      UISceneView2D/Resources/Sprites/imp_all.png.asset
  19. 5 0
      UISceneView2D/Resources/Sprites/imp_blood.png.asset
  20. 5 0
      UISceneView2D/Resources/Sprites/imp_body.png.asset
  21. 5 0
      UISceneView2D/Resources/Sprites/imp_footbig.png.asset
  22. 5 0
      UISceneView2D/Resources/Sprites/imp_footsmall.png.asset
  23. 5 0
      UISceneView2D/Resources/Sprites/imp_handbig.png.asset
  24. 5 0
      UISceneView2D/Resources/Sprites/imp_handsmall.png.asset
  25. 5 0
      UISceneView2D/Resources/Sprites/imp_handthrow.png.asset
  26. 5 0
      UISceneView2D/Resources/Sprites/imp_head.png.asset
  27. 5 0
      UISceneView2D/Resources/Sprites/imp_headangry.png.asset
  28. 5 0
      UISceneView2D/Resources/Sprites/imp_headblink.png.asset

+ 0 - 92
RenderToTexture/Resources/Components/RenderBox.js

@@ -1,92 +0,0 @@
-
-// Render to texture example component
-
-var game = Atomic.game;
-var cache = game.cache;
-var node = self.node;
-
-// we're be setting up our render texture with a chest scene
-var chestScene;
-var chestNode;
-var chestCamera;
-
-// Create a scene which get's rendered to texture
-function createChestScene() {
-
-  chestScene = new Atomic.Scene();
-
-  chestScene.createComponent("Octree");
-
-  // create a zone
-  var zoneNode = chestScene.createChild("Zone")
-  var zone = zoneNode.createComponent("Zone");
-
-  zone.ambientColor = [0.0, 0.0, 0.0];
-  zone.fogColor = [.2, .2, .2, 1.0];
-  zone.fogStart = 10;
-  zone.fogEnd = 100;
-
-  // chest node where we will attach the model
-  chestNode = chestScene.createChild("Chest");
-  chestNode.pitch(-90);
-
-  var model = chestNode.createComponent("StaticModel");
-  model.setModel(cache.getResource("Model", "Models/Chest.mdl"));
-  model.setMaterial(cache.getResource("Material", "Materials/Chest.xml"));
-
-  // Create a camera for the render-to-texture scene. Simply leave it at the world origin and let it observe the scene
-  var cameraNode = chestScene.createChild("Camera");
-  chestCamera = cameraNode.createComponent("Camera");
-
-  cameraNode.position = [0, .5, -4];
-  chestCamera.farClip = 100;
-
-  // Create a point light to the camera scene node
-  var light = cameraNode.createComponent("Light");
-  light.lightType = Atomic.LIGHT_POINT;
-  light.range = 30;
-
-}
-
-
-function start() {
-
-    // create the chest render to texture scene
-    createChestScene();
-
-    //  add a box which will have the chest scene rendered on it
-    var model = node.createComponent("StaticModel");
-    model.setModel(cache.getResource("Model", "Models/Box.mdl"));
-
-    // Create a renderable texture (1024x1024, RGB format), enable bilinear filtering on it
-    var renderTexture = new Atomic.Texture2D();
-    renderTexture.setSize(1024, 1024, game.graphics.getRGBFormat(), Atomic.TEXTURE_RENDERTARGET);
-    renderTexture.filterMode = Atomic.FILTER_BILINEAR;
-
-    // Create a new material from scratch, use the diffuse unlit technique, assign the render texture
-    // as its diffuse texture, then assign the material box object
-    var renderMaterial = new Atomic.Material();
-    renderMaterial.setTechnique(0, cache.getResource("Technique", "Techniques/Diff.xml"));
-    renderMaterial.setTexture(Atomic.TU_DIFFUSE, renderTexture);
-    model.setMaterial(renderMaterial);
-
-    // Get the texture's RenderSurface object (exists when the texture has been created in rendertarget mode)
-    // and define the viewport for rendering the second scene, similarly as how backbuffer viewports are defined
-    // to the Renderer subsystem. By default the texture viewport will be updated when the texture is visible
-    // in the main view
-    var surface = renderTexture.getRenderSurface();
-    var rttViewport = new Atomic.Viewport(chestScene, chestCamera);
-    surface.setViewport(0, rttViewport);
-
-    node.pitch(-90);
-
-}
-
-
-function update(timeStep) {
-
-   // Let's roll
-   node.roll(timeStep * 15);
-   chestNode.roll(timeStep * 75);
-
-}

+ 1 - 0
UISceneView2D/.gitignore

@@ -0,0 +1 @@
+Cache/*

+ 5 - 0
UISceneView2D/Resources.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "9689ba6097b16dd7faee3a0cc9fcf2ef",
+	"FolderImporter": {}
+}

+ 5 - 0
UISceneView2D/Resources/Components.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "05c7f305f2519f578c04c4a01670021b",
+	"FolderImporter": {}
+}

+ 20 - 47
UISceneView2D/Resources/Components/UI.js

@@ -1,57 +1,30 @@
-// Atomic Component
-
-var game = Atomic.game;
-var view = game.uiView;
-var UI = Atomic.UI;
+'atomic component';
 
 var WIDTH = 512;
 var HEIGHT = 512;
 
-// Create the render scene
-var scene = new Atomic.Scene();
-scene.createComponent("Octree");
-
-// Create the camera node
-var cameraNode = scene.createChild("Camera");
-cameraNode.position = [0.0, 0.0, -10.0];
-
-// 2D orthographic camera
-var camera = cameraNode.createComponent("Camera");
-camera.orthographic = true;
-camera.orthoSize = HEIGHT * Atomic.PIXEL_SIZE;
-
-// background color
-var zone = cameraNode.createComponent("Zone");
-zone.fogColor = [0, 0.2, 0.3];
-
-// 2D animated Imp
-var node = scene.createChild("Imp");
-var animationSet = game.cache.getResource("AnimationSet2D", "Sprites/imp.scml");
-var sprite2D = node.createComponent("AnimatedSprite2D");
-sprite2D.setAnimation(animationSet, "idle", Atomic.LM_FORCE_LOOPED);
-
-function start() {
-
-  // Create a UIWindow
-  var window = new Atomic.UIWindow();
-  // It will only have a title bar and won't be resizeable or have a close button
-  window.settings = Atomic.UI.WINDOW_SETTINGS_TITLEBAR;
-  window.text = "UISceneView2D";
-  window.setSize(WIDTH, HEIGHT);
+exports.component = function(self) {
 
-  // The Scene View
-  var sceneView = new Atomic.UISceneView();
-  sceneView.setView(scene, camera);
-  sceneView.autoUpdate = true;
-  window.addChild(sceneView);
+    var scene = Atomic.player.loadScene("Scenes/2DScene.scene");
+    var cameras = scene.getComponents("Camera", true);
 
-  // Add to main UI view and center
-  view.addChild(window);
-  window.center();
+    var view = new Atomic.UIView();
 
-}
+    // Create a UIWindow
+    var window = new Atomic.UIWindow();
+    // It will only have a title bar and won't be resizeable or have a close button
+    window.settings = Atomic.UI_WINDOW_SETTINGS_TITLEBAR;
+    window.text = "UISceneView2D";
+    window.setSize(WIDTH, HEIGHT);
 
-function update(timeStep) {
+    // The Scene View
+    var sceneView = new Atomic.UISceneView();
+    sceneView.setView(scene, cameras[0]);
+    sceneView.autoUpdate = true;
+    window.addChild(sceneView);
 
+    // Add to main UI view and center
+    view.addChild(window);
+    window.center();
 
-}
+}

+ 7 - 0
UISceneView2D/Resources/Components/UI.js.asset

@@ -0,0 +1,7 @@
+{
+	"version": 1,
+	"guid": "75754b2360d716fbe3e9360c86fd9e1c",
+	"JavascriptImporter": {
+		"IsComponentFile": true
+	}
+}

+ 5 - 0
UISceneView2D/Resources/Scenes.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "0d9d775addbb302c8a1c06203eecc23c",
+	"FolderImporter": {}
+}

+ 59 - 0
UISceneView2D/Resources/Scenes/2DScene.scene

@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<scene id="1">
+	<attribute name="Name" value="" />
+	<attribute name="Time Scale" value="1" />
+	<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="366" />
+	<attribute name="Next Replicated Component ID" value="1979" />
+	<attribute name="Next Local Node ID" value="16778510" />
+	<attribute name="Next Local Component ID" value="16777228" />
+	<attribute name="Variables" />
+	<attribute name="Variable Names" value="" />
+	<component type="PhysicsWorld" id="1" />
+	<component type="Octree" id="2" />
+	<component type="DebugRenderer" id="3" />
+	<component type="Renderer2D" id="1977" />
+	<node id="2">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Zone" />
+		<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="Zone" id="4">
+			<attribute name="Bounding Box Min" value="-10000 -10000 -10000" />
+			<attribute name="Bounding Box Max" value="10000 10000 10000" />
+			<attribute name="Ambient Color" value="0.4 0.4 0.4 1" />
+			<attribute name="Fog Color" value="0 0.2 0.3 1" />
+			<attribute name="Fog Start" value="10" />
+			<attribute name="Fog End" value="100" />
+		</component>
+	</node>
+	<node id="361">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Camera" />
+		<attribute name="Position" value="0 0 -5" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Camera" id="1973">
+			<attribute name="Near Clip" value="0" />
+			<attribute name="Orthographic" value="true" />
+			<attribute name="Orthographic Size" value="5" />
+		</component>
+	</node>
+	<node id="364">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="imp" />
+		<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="AnimatedSprite2D" id="1976">
+			<attribute name="Animation Set" value="AnimationSet2D;Sprites/imp.scml" />
+			<attribute name="Animation" value="idle" />
+		</component>
+	</node>
+</scene>

+ 5 - 0
UISceneView2D/Resources/Scenes/2DScene.scene.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "8a03721898006982d9010d2d7ac69ac3",
+	"SceneImporter": {}
+}

+ 42 - 0
UISceneView2D/Resources/Scenes/MainScene.scene

@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<scene id="1">
+	<attribute name="Name" value="" />
+	<attribute name="Time Scale" value="1" />
+	<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="363" />
+	<attribute name="Next Replicated Component ID" value="1976" />
+	<attribute name="Next Local Node ID" value="16778496" />
+	<attribute name="Next Local Component ID" value="16777216" />
+	<attribute name="Variables" />
+	<attribute name="Variable Names" value="" />
+	<component type="PhysicsWorld" id="1" />
+	<component type="Octree" id="2" />
+	<component type="DebugRenderer" id="3" />
+	<node id="2">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Zone" />
+		<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="Zone" id="4">
+			<attribute name="Bounding Box Min" value="-10000 -10000 -10000" />
+			<attribute name="Bounding Box Max" value="10000 10000 10000" />
+			<attribute name="Ambient Color" value="0.4 0.4 0.4 1" />
+		</component>
+	</node>
+	<node id="361">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Camera" />
+		<attribute name="Position" value="0 0 -5" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Camera" id="1973" />
+		<component type="JSComponent" id="1975">
+			<attribute name="ComponentFile" value="JSComponentFile;Components/UI.js" />
+		</component>
+	</node>
+</scene>

+ 5 - 0
UISceneView2D/Resources/Scenes/MainScene.scene.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "a33ad47962d755192bc36b9a14feb515",
+	"SceneImporter": {}
+}

+ 5 - 0
UISceneView2D/Resources/Scripts.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "85160d78f2e0bfd313175f4d300cffc6",
+	"FolderImporter": {}
+}

+ 4 - 17
UISceneView2D/Resources/Scripts/main.js

@@ -1,24 +1,11 @@
 // This script is the main entry point of the game
-require("AtomicGame");
 
-Atomic.game.init(start, update);
+var scene = Atomic.player.loadScene("Scenes/MainScene.scene");
 
-
-// called at the start of play
-function start() {
-
-    var game = Atomic.game;
-
-    // create a 2D scene
-    game.createScene2D();
-
-    var uiNode = game.scene.createChild("UI");
-    uiNode.createJSComponent("UI");
-
-}
-
-// called per frame
+// called per frame, optional
 function update(timeStep) {
 
 
 }
+
+exports.update = update;

+ 1 - 1
RenderToTexture/Resources/Components/RenderBox.js.asset → UISceneView2D/Resources/Scripts/main.js.asset

@@ -1,6 +1,6 @@
 {
 	"version": 1,
-	"guid": "d35726803eba8b2f1f4043b824bca479",
+	"guid": "cfd9cc41dacc7508de8f7aeb959ad371",
 	"JavascriptImporter": {
 		"IsComponentFile": false
 	}

+ 0 - 1
UISceneView2D/Resources/Skin/skin.ui.txt

@@ -1 +0,0 @@
-elements

+ 5 - 0
UISceneView2D/Resources/Sprites.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "31189dfcc177d6336691c55a00a7ea15",
+	"FolderImporter": {}
+}

+ 5 - 0
UISceneView2D/Resources/Sprites/imp.scml.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "23a79bb36a7ef0e62942ddb754f392d8",
+	"SpriterImporter": {}
+}

+ 5 - 0
UISceneView2D/Resources/Sprites/imp_all.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "40e8e2b2774386ad1472be62653c4466",
+	"TextureImporter": {}
+}

+ 5 - 0
UISceneView2D/Resources/Sprites/imp_blood.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "c7fee7b5258b2fd6ef443f5c17249f3b",
+	"TextureImporter": {}
+}

+ 5 - 0
UISceneView2D/Resources/Sprites/imp_body.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "5de5cc40139ff79e333f2f839e617394",
+	"TextureImporter": {}
+}

+ 5 - 0
UISceneView2D/Resources/Sprites/imp_footbig.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "64cf0791823b21c3d797604ed5d61fa6",
+	"TextureImporter": {}
+}

+ 5 - 0
UISceneView2D/Resources/Sprites/imp_footsmall.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "63b990e467d7319b7b326f0ffda87364",
+	"TextureImporter": {}
+}

+ 5 - 0
UISceneView2D/Resources/Sprites/imp_handbig.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "16f577cab5bc1583880e7fcbaa8d8c7e",
+	"TextureImporter": {}
+}

+ 5 - 0
UISceneView2D/Resources/Sprites/imp_handsmall.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "c5f338072e8ef7f6d4f1b93c71c89957",
+	"TextureImporter": {}
+}

+ 5 - 0
UISceneView2D/Resources/Sprites/imp_handthrow.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "4f4b49ff4cefd97f362a77b7f76f80c4",
+	"TextureImporter": {}
+}

+ 5 - 0
UISceneView2D/Resources/Sprites/imp_head.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "34dd31cf9b4198df4e55888fedb140e8",
+	"TextureImporter": {}
+}

+ 5 - 0
UISceneView2D/Resources/Sprites/imp_headangry.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "00535365d36f14a54ee78132ec49d914",
+	"TextureImporter": {}
+}

+ 5 - 0
UISceneView2D/Resources/Sprites/imp_headblink.png.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "1abac9419a269396774820e03d11a66b",
+	"TextureImporter": {}
+}