Browse Source

Added example with using CustomGeometry component

rsredsq 10 years ago
parent
commit
5493fb9624

+ 0 - 0
CustomGeometry/CustomGeometry.atomic


+ 5 - 0
CustomGeometry/Resources.asset

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

+ 5 - 0
CustomGeometry/Resources/Components.asset

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

+ 9 - 0
CustomGeometry/Resources/Components/Spinner.js

@@ -0,0 +1,9 @@
+'atomic component';
+
+//Spinner component
+exports.component = function(self) {
+    self.update = function(timeStep) {
+        //Roll the node
+        self.node.roll(timeStep * 75);
+  }
+}

+ 7 - 0
CustomGeometry/Resources/Components/Spinner.js.asset

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

+ 4 - 0
CustomGeometry/Resources/README.TXT

@@ -0,0 +1,4 @@
+Atomic CustomGeometry component example
+------------------
+
+An example which shows using a CustomGeometry component on example of creating a Triangle with defining vertices and color manually

+ 5 - 0
CustomGeometry/Resources/README.TXT.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "839564583ae4a2b7aa55fdd8644fb664",
+	"TextImporter": {}
+}

+ 5 - 0
CustomGeometry/Resources/Scenes.asset

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

+ 28 - 0
CustomGeometry/Resources/Scenes/Scene.scene

@@ -0,0 +1,28 @@
+<?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="367" />
+	<attribute name="Next Replicated Component ID" value="1982" />
+	<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="Octree" id="2" />
+	<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="1" />
+		</component>
+	</node>
+</scene>

+ 5 - 0
CustomGeometry/Resources/Scenes/Scene.scene.asset

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

+ 5 - 0
CustomGeometry/Resources/Scripts.asset

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

+ 21 - 0
CustomGeometry/Resources/Scripts/main.js

@@ -0,0 +1,21 @@
+//Create a new scene
+var scene = Atomic.player.loadScene("Scenes/Scene.scene");
+//Create a Triangle node
+var triangle = scene.createChild("Triangle");
+//Create CustomGeometry component
+var customGeometry = triangle.createComponent("CustomGeometry");
+//Set its material VColUnlit
+customGeometry.setMaterial(Atomic.cache.getResource("Material", "Materials/VColUnlit.xml"));
+//Begin geometry, set index to 0, and TRIANGLE_LIST mode
+customGeometry.beginGeometry(0, Atomic.TRIANGLE_LIST);
+//Define a vertex and a color for that
+customGeometry.defineVertex([0.0, 0.5, 0.0]); //Vertex 1
+customGeometry.defineColor([1.0, 0.0, 0.0]);
+customGeometry.defineVertex([0.5, -0.5, 0.0]); //Vertex 2
+customGeometry.defineColor([0.0, 1.0, 0.0]);
+customGeometry.defineVertex([-0.5, -0.5, 0.0]);//Vertex 3
+customGeometry.defineColor([0.0, 0.0, 1.0]);
+//Save changes
+customGeometry.commit();
+//Create spinner component
+triangle.createJSComponent("Components/Spinner.js");

+ 7 - 0
CustomGeometry/Resources/Scripts/main.js.asset

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