浏览代码

Adding a simple example for how to use UIOffscreenView

Jay Sistar 9 年之前
父节点
当前提交
8307c4add1
共有 26 个文件被更改,包括 312 次插入0 次删除
  1. 4 0
      UITexture/AtomicExample.json
  2. 5 0
      UITexture/JavaScript/Resources.asset
  3. 5 0
      UITexture/JavaScript/Resources/Components.asset
  4. 17 0
      UITexture/JavaScript/Resources/Components/Spinner.js
  5. 7 0
      UITexture/JavaScript/Resources/Components/Spinner.js.asset
  6. 27 0
      UITexture/JavaScript/Resources/Components/UI.js
  7. 7 0
      UITexture/JavaScript/Resources/Components/UI.js.asset
  8. 5 0
      UITexture/JavaScript/Resources/Models.asset
  9. 二进制
      UITexture/JavaScript/Resources/Models/Ground.fbx
  10. 10 0
      UITexture/JavaScript/Resources/Models/Ground.fbx.asset
  11. 5 0
      UITexture/JavaScript/Resources/Models/Materials.asset
  12. 7 0
      UITexture/JavaScript/Resources/Models/Materials/DefaultMaterial.material
  13. 5 0
      UITexture/JavaScript/Resources/Models/Materials/DefaultMaterial.material.asset
  14. 5 0
      UITexture/JavaScript/Resources/Scenes.asset
  15. 86 0
      UITexture/JavaScript/Resources/Scenes/Scene.scene
  16. 8 0
      UITexture/JavaScript/Resources/Scenes/Scene.scene.asset
  17. 5 0
      UITexture/JavaScript/Resources/Scripts.asset
  18. 10 0
      UITexture/JavaScript/Resources/Scripts/main.js
  19. 7 0
      UITexture/JavaScript/Resources/Scripts/main.js.asset
  20. 5 0
      UITexture/JavaScript/Resources/UI.asset
  21. 22 0
      UITexture/JavaScript/Resources/UI/stuff.tb.txt
  22. 5 0
      UITexture/JavaScript/Resources/UI/stuff.tb.txt.asset
  23. 49 0
      UITexture/JavaScript/Settings/Engine.json
  24. 6 0
      UITexture/JavaScript/Settings/Project.json
  25. 0 0
      UITexture/JavaScript/UITexture.atomic
  26. 二进制
      UITexture/Screenshot.png

+ 4 - 0
UITexture/AtomicExample.json

@@ -0,0 +1,4 @@
+{
+    "name": "UITexture",
+    "desc" : "Example rendering a UI on a 3D surface"
+}

+ 5 - 0
UITexture/JavaScript/Resources.asset

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

+ 5 - 0
UITexture/JavaScript/Resources/Components.asset

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

+ 17 - 0
UITexture/JavaScript/Resources/Components/Spinner.js

@@ -0,0 +1,17 @@
+
+"atomic component";
+
+var inspectorFields = {
+  speed: 1.0
+};
+
+exports.component = function(self) {
+
+  self.update = function(timeStep) {
+
+    self.node.yaw(timeStep * 15 * self.speed);
+    //self.node.roll(timeStep * 5 * self.speed);
+
+  };
+
+};

+ 7 - 0
UITexture/JavaScript/Resources/Components/Spinner.js.asset

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

+ 27 - 0
UITexture/JavaScript/Resources/Components/UI.js

@@ -0,0 +1,27 @@
+"atomic component";
+
+exports.component  = function(self) {
+
+    var camera     = self.node.scene.getComponent("Camera", true);
+    var octree     = self.node.scene.getComponent("Octree", true);
+    var model      = self.node.getComponent("StaticModel");
+
+    self.uiOsView  = new Atomic.UIOffscreenView();
+    model.material = self.uiOsView.material;
+    self.uiOsView.registerInput(camera, octree, model);
+
+    // The material property above creates a default material
+    // that uses the UIOffscreenView's texture2D. Using the
+    // texture2D in a custom material is also possible.
+
+    var widget     = new Atomic.UIWidget();
+    widget.load("UI/stuff.tb.txt");
+    widget.width   = self.uiOsView.width;
+    widget.height  = self.uiOsView.height;
+    widget.getWidget("stuff").onClick = function() {
+        // Save a PNG of the UI to use as the texture in
+        // a geometry editor to give depth to your UI!
+        self.uiOsView.savePNG("stuff.png");
+    };
+    self.uiOsView.addChild(widget);
+};

+ 7 - 0
UITexture/JavaScript/Resources/Components/UI.js.asset

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

+ 5 - 0
UITexture/JavaScript/Resources/Models.asset

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

二进制
UITexture/JavaScript/Resources/Models/Ground.fbx


+ 10 - 0
UITexture/JavaScript/Resources/Models/Ground.fbx.asset

@@ -0,0 +1,10 @@
+{
+	"version": 1,
+	"guid": "b1fc206e3887f146e471a34b31989538",
+	"ModelImporter": {
+		"scale": 0.5,
+		"importAnimations": false,
+		"importMaterials": true,
+		"animInfo": []
+	}
+}

+ 5 - 0
UITexture/JavaScript/Resources/Models/Materials.asset

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

+ 7 - 0
UITexture/JavaScript/Resources/Models/Materials/DefaultMaterial.material

@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<material>
+	<technique name="Techniques/NoTexture.xml" />
+	<parameter name="MatDiffColor" value="0.8 0.8 0.8 1" />
+	<parameter name="MatSpecColor" value="1 1 1 1" />
+	<parameter name="MatEmissiveColor" value="0 0 0 1" />
+</material>

+ 5 - 0
UITexture/JavaScript/Resources/Models/Materials/DefaultMaterial.material.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "17f96620b26bb0bfd082023ac68ee355",
+	"MaterialImporter": {}
+}

+ 5 - 0
UITexture/JavaScript/Resources/Scenes.asset

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

+ 86 - 0
UITexture/JavaScript/Resources/Scenes/Scene.scene

@@ -0,0 +1,86 @@
+<?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="375" />
+	<attribute name="Next Replicated Component ID" value="1991" />
+	<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="Tags" />
+		<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="3">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="GlobalLight" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="0 0 0" />
+		<attribute name="Rotation" value="0.888074 0.325058 -0.325058 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Light" id="5">
+			<attribute name="Light Type" value="Directional" />
+			<attribute name="Specular Intensity" value="0.1" />
+			<attribute name="Brightness Multiplier" value="0.9" />
+			<attribute name="Cast Shadows" value="true" />
+			<attribute name="CSM Splits" value="10 20 50 0" />
+			<attribute name="View Size Quantize" value="1" />
+			<attribute name="View Size Minimum" value="5" />
+			<attribute name="Depth Constant Bias" value="0.00025" />
+			<attribute name="Depth Slope Bias" value="0.001" />
+		</component>
+	</node>
+	<node id="361">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Camera" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="0 0 -1" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Camera" id="1973" />
+	</node>
+	<node id="366">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="UICube" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="0 0 0.0370512" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="JSComponent" id="1980">
+			<attribute name="ComponentFile" value="JSComponentFile;Components/Spinner.js" />
+			<attribute name="FieldValues">
+				<variant hash="273365031" type="Float" value="0.5" />
+			</attribute>
+		</component>
+		<component type="JSComponent" id="1981">
+			<attribute name="ComponentFile" value="JSComponentFile;Components/UI.js" />
+		</component>
+		<component type="StaticModel" id="1986">
+			<attribute name="Model" value="Model;b1fc206e3887f146e471a34b31989538.mdl" />
+			<attribute name="Material" value="Material;" />
+			<attribute name="Geometry Enabled">
+				<variant type="Bool" value="true" />
+			</attribute>
+		</component>
+	</node>
+</scene>

+ 8 - 0
UITexture/JavaScript/Resources/Scenes/Scene.scene.asset

@@ -0,0 +1,8 @@
+{
+	"version": 1,
+	"guid": "96e0026c47f63560efaca6c670c62b49",
+	"SceneImporter": {
+		"sceneCamRotation": "0.989271 0.0224497 -0.144319 0.00327506",
+		"sceneCamPosition": "0.73743 0.0468832 -2.08912"
+	}
+}

+ 5 - 0
UITexture/JavaScript/Resources/Scripts.asset

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

+ 10 - 0
UITexture/JavaScript/Resources/Scripts/main.js

@@ -0,0 +1,10 @@
+// This script is the main entry point of the game
+
+var scene = Atomic.player.loadScene("Scenes/Scene.scene");
+
+// called per frame, optional
+function update(timeStep) {
+
+}
+
+exports.update = update;

+ 7 - 0
UITexture/JavaScript/Resources/Scripts/main.js.asset

@@ -0,0 +1,7 @@
+{
+	"version": 1,
+	"guid": "012152b6b4724b6dc03ac4e4ecb6d1df",
+	"JavascriptImporter": {
+		"IsComponentFile": false
+	}
+}

+ 5 - 0
UITexture/JavaScript/Resources/UI.asset

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

+ 22 - 0
UITexture/JavaScript/Resources/UI/stuff.tb.txt

@@ -0,0 +1,22 @@
+TBLayout
+	distribution available
+	axis y
+	TBLayout
+		TBButton
+			id stuff
+			text Stuff
+		TBRadioButton
+		TBCheckBox
+	@if 1
+		TBContainer
+			TBLayout
+				TBSlider
+					value 0.5
+				TBScrollBar
+	TBEditField
+		multiline 1
+	TBEditField
+		text Hello world\nHello world
+		adapt-to-content 1
+		multiline 1
+

+ 5 - 0
UITexture/JavaScript/Resources/UI/stuff.tb.txt.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "23870a1b680ea335d5ff82b0302b2003",
+	"TextImporter": {}
+}

+ 49 - 0
UITexture/JavaScript/Settings/Engine.json

@@ -0,0 +1,49 @@
+{
+  "desktop": {
+
+    "engine" : {
+      "workerThreads" : true,
+      "logQuiet" : false,
+      "logLevel" : 1
+    },
+
+    "graphics": {
+      "headless": false,
+      "frameLimiter" : true,
+      "flushGPU" : false,
+      "forceGL2" : false,
+      "orientations" : "LandscapeLeft LandscapeRight",
+      "vsync" : true,
+      "tripleBuffer" : false,
+      "multiSample" : 8,
+      "renderPath" : "forward",
+      "shadows" : true,
+      "lowQualityShadows" : false,
+      "materialQuality" : "high",
+      "textureQuality" : "high",
+      "textureFilterMode" : "trilinear",
+      "textureAnisotropy" : 4
+    },
+
+    "window" : {
+      "title" : "WebTexture3D",
+      "fullscreen" : false,
+      "borderless" : false,
+      "resizable" : false
+    },
+
+    "sound": {
+      "enabled" : true,
+      "interpolation" : true,
+      "stereo" : true,
+      "bufferMS": 100,
+      "mixRate" : 44100
+    },
+
+    "input" : {
+      "touchEmulation" : false
+    }
+
+  }
+
+}

+ 6 - 0
UITexture/JavaScript/Settings/Project.json

@@ -0,0 +1,6 @@
+{
+  "name": "UITexture",
+  "platforms": [
+    "desktop"
+  ]
+}

+ 0 - 0
UITexture/JavaScript/UITexture.atomic


二进制
UITexture/Screenshot.png