Selaa lähdekoodia

Adding 3d particle emitter example

Josh Engebretson 10 vuotta sitten
vanhempi
sitoutus
f5fb7779df
37 muutettua tiedostoa jossa 412 lisäystä ja 0 poistoa
  1. 1 0
      ParticleEmitter3D/.gitignore
  2. 0 0
      ParticleEmitter3D/ParticleEmitter3D.atomic
  3. 5 0
      ParticleEmitter3D/Resources.asset
  4. 5 0
      ParticleEmitter3D/Resources/Components.asset
  5. 52 0
      ParticleEmitter3D/Resources/Components/UI.js
  6. 7 0
      ParticleEmitter3D/Resources/Components/UI.js.asset
  7. 5 0
      ParticleEmitter3D/Resources/Materials.asset
  8. 4 0
      ParticleEmitter3D/Resources/Materials/Particle.material
  9. 5 0
      ParticleEmitter3D/Resources/Materials/Particle.material.asset
  10. 4 0
      ParticleEmitter3D/Resources/Materials/Smoke.material
  11. 5 0
      ParticleEmitter3D/Resources/Materials/Smoke.material.asset
  12. 5 0
      ParticleEmitter3D/Resources/Particles.asset
  13. 28 0
      ParticleEmitter3D/Resources/Particles/Disco.peffect
  14. 5 0
      ParticleEmitter3D/Resources/Particles/Disco.peffect.asset
  15. 27 0
      ParticleEmitter3D/Resources/Particles/Fire.peffect
  16. 5 0
      ParticleEmitter3D/Resources/Particles/Fire.peffect.asset
  17. 20 0
      ParticleEmitter3D/Resources/Particles/Smoke.peffect
  18. 5 0
      ParticleEmitter3D/Resources/Particles/Smoke.peffect.asset
  19. 28 0
      ParticleEmitter3D/Resources/Particles/SmokeStack.peffect
  20. 5 0
      ParticleEmitter3D/Resources/Particles/SmokeStack.peffect.asset
  21. 16 0
      ParticleEmitter3D/Resources/Particles/SnowExplosion.peffect
  22. 5 0
      ParticleEmitter3D/Resources/Particles/SnowExplosion.peffect.asset
  23. 18 0
      ParticleEmitter3D/Resources/Particles/SnowExplosionBig.peffect
  24. 5 0
      ParticleEmitter3D/Resources/Particles/SnowExplosionBig.peffect.asset
  25. 16 0
      ParticleEmitter3D/Resources/Particles/SnowExplosionFade.peffect
  26. 5 0
      ParticleEmitter3D/Resources/Particles/SnowExplosionFade.peffect.asset
  27. 5 0
      ParticleEmitter3D/Resources/Scenes.asset
  28. 79 0
      ParticleEmitter3D/Resources/Scenes/Scene.scene
  29. 5 0
      ParticleEmitter3D/Resources/Scenes/Scene.scene.asset
  30. 5 0
      ParticleEmitter3D/Resources/Scripts.asset
  31. 10 0
      ParticleEmitter3D/Resources/Scripts/main.js
  32. 7 0
      ParticleEmitter3D/Resources/Scripts/main.js.asset
  33. 5 0
      ParticleEmitter3D/Resources/Textures.asset
  34. BIN
      ParticleEmitter3D/Resources/Textures/Flare.dds
  35. 5 0
      ParticleEmitter3D/Resources/Textures/Flare.dds.asset
  36. BIN
      ParticleEmitter3D/Resources/Textures/Smoke.dds
  37. 5 0
      ParticleEmitter3D/Resources/Textures/Smoke.dds.asset

+ 1 - 0
ParticleEmitter3D/.gitignore

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

+ 0 - 0
ParticleEmitter3D/ParticleEmitter3D.atomic


+ 5 - 0
ParticleEmitter3D/Resources.asset

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

+ 5 - 0
ParticleEmitter3D/Resources/Components.asset

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

+ 52 - 0
ParticleEmitter3D/Resources/Components/UI.js

@@ -0,0 +1,52 @@
+'atomic component';
+
+//define font description style
+var fd = new Atomic.UIFontDescription();
+fd.id = "Vera";
+fd.size = 22;
+
+var particleEmitter;
+
+function createButton(self, text, peffectName, layout) {
+    //create UIButton element
+    var button = new Atomic.UIButton();
+    //set its text and font description style
+    button.text = text;
+    button.fontDescription = fd;
+    //laying on the right side
+    button.gravity = Atomic.UI_GRAVITY_RIGHT;
+    //this event will be called when buttons is clicked
+    button.onClick = function() {
+
+        particleEmitter.effect = Atomic.cache.getResource("ParticleEffect", "Particles/" + peffectName + ".peffect");
+
+    }
+    //add button
+    layout.addChild(button);
+
+}
+//UI component
+exports.component = function(self) {
+
+    particleEmitter = self.getComponent("ParticleEmitter")
+
+    // root view
+    self.uiView = new Atomic.UIView();
+    // Create a layout, otherwise child widgets won't know how to size themselves
+    // and would manually need to be sized
+    var layout = new Atomic.UILayout();
+    layout.rect = self.uiView.rect;
+
+    layout.axis = Atomic.UI_AXIS_Y;
+
+    layout.layoutPosition = Atomic.UI_LAYOUT_POSITION_GRAVITY;
+    //add our layout
+    self.uiView.addChild(layout);
+    //create buttons
+    createButton(self, "Disco", "Disco", layout);
+    createButton(self, "Fire", "Fire", layout);
+    createButton(self, "Smoke", "Smoke", layout);
+    createButton(self, "SmokeStack", "SmokeStack", layout);
+    createButton(self, "SnowExplosion", "SnowExplosion", layout);
+
+}

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

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

+ 5 - 0
ParticleEmitter3D/Resources/Materials.asset

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

+ 4 - 0
ParticleEmitter3D/Resources/Materials/Particle.material

@@ -0,0 +1,4 @@
+<material>
+    <technique name="Techniques/DiffVColAdd.xml" />
+    <texture unit="diffuse" name="Textures/Flare.dds" />
+</material>

+ 5 - 0
ParticleEmitter3D/Resources/Materials/Particle.material.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "66c8f245d879e9d08b496674cca9d257",
+	"MaterialImporter": {}
+}

+ 4 - 0
ParticleEmitter3D/Resources/Materials/Smoke.material

@@ -0,0 +1,4 @@
+<material>
+    <technique name="Techniques/DiffVColUnlitAlpha.xml" />
+    <texture unit="diffuse" name="Textures/Smoke.dds" />
+</material>

+ 5 - 0
ParticleEmitter3D/Resources/Materials/Smoke.material.asset

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

+ 5 - 0
ParticleEmitter3D/Resources/Particles.asset

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

+ 28 - 0
ParticleEmitter3D/Resources/Particles/Disco.peffect

@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<particleeffect>
+	<material name="Materials/Particle.material" />
+	<numparticles value="10" />
+	<updateinvisible enable="true" />
+	<relative enable="true" />
+	<scaled enable="true" />
+	<sorted enable="true" />
+	<animlodbias value="0" />
+	<emittertype value="Sphere" />
+	<emittersize value="0 0 0" />
+	<direction min="-1 0 -1" max="1 1 1" />
+	<constantforce value="0 -2 0" />
+	<dampingforce value="0" />
+	<activetime value="0" />
+	<inactivetime value="0" />
+	<emissionrate min="50" max="50" />
+	<particlesize min="0.25 0.25" max="0.25 0.25" />
+	<timetolive min="2.01" max="2.41" />
+	<velocity min="2" max="3" />
+	<rotation min="0" max="0" />
+	<rotationspeed min="0" max="0" />
+	<sizedelta add="0" mul="1" />
+	<colorfade color="0.35 0.35 0.5 1" time="0" />
+	<colorfade color="0 0 0 1" time="0.5" />
+	<colorfade color="1 0 0 1" time="1" />
+	<colorfade color="0 1 0 1" time="2" />
+</particleeffect>

+ 5 - 0
ParticleEmitter3D/Resources/Particles/Disco.peffect.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "c3e130ceb23cafb4da2d8c87feeafed8",
+	"ParticleEffectImporter": {}
+}

+ 27 - 0
ParticleEmitter3D/Resources/Particles/Fire.peffect

@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<particleeffect>
+	<material name="Materials/Particle.material" />
+	<numparticles value="1000" />
+	<updateinvisible enable="false" />
+	<relative enable="false" />
+	<scaled enable="true" />
+	<sorted enable="false" />
+	<animlodbias value="0" />
+	<emittertype value="Sphere" />
+	<emittersize value="0 0 0" />
+	<direction min="-0.1 0.1 -0.1" max="0.1 1 0.1" />
+	<constantforce value="0 2 0" />
+	<dampingforce value="2" />
+	<activetime value="0" />
+	<inactivetime value="0" />
+	<emissionrate min="40" max="50" />
+	<particlesize min="0.1 0.1" max="0.4 0.4" />
+	<timetolive min="1" max="1" />
+	<velocity min="1" max="2" />
+	<rotation min="0" max="0" />
+	<rotationspeed min="0" max="0" />
+	<sizedelta add="0" mul="0.5" />
+	<colorfade color="0.1 0.5 1 1" time="0" />
+	<colorfade color="1 0.63 0.45 1" time="0.5" />
+	<colorfade color="0 0 0 0" time="1" />
+</particleeffect>

+ 5 - 0
ParticleEmitter3D/Resources/Particles/Fire.peffect.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "d4f3c6e5f465a2818b77f9f544e15e1b",
+	"ParticleEffectImporter": {}
+}

+ 20 - 0
ParticleEmitter3D/Resources/Particles/Smoke.peffect

@@ -0,0 +1,20 @@
+<particleemitter>
+    <material name="Materials/Smoke.material" />
+    <updateinvisible enable="true" />
+    <relative enable="false" />
+    <numparticles value="10" />
+    <activetime value="0" />
+    <inactivetime value="0" />
+    <emissionrate value="13.333" />
+    <sorted enable="true" />
+    <rotationspeed min="-60" max="60" />
+    <direction min="-0.15 1 -0.15" max="0.15 1 0.15" />
+    <velocity min="1" max="1.3" />
+    <particlesize min="0.2 0.2" max="0.3 0.3" />
+    <sizedelta add="0" mul="1.3" />
+    <timetolive value="4" />
+    <constantforce value="0 -0.2 0" />
+    <colorfade color="0.2 0.2 0.2 0" time="0.0" />
+    <colorfade color="0.2 0.2 0.2 1" time="0.25" />
+    <colorfade color="0.6 0.6 0.6 0" time="4.0" />
+</particleemitter>

+ 5 - 0
ParticleEmitter3D/Resources/Particles/Smoke.peffect.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "2ced42420e5d17e147e2d8ea9146144d",
+	"ParticleEffectImporter": {}
+}

+ 28 - 0
ParticleEmitter3D/Resources/Particles/SmokeStack.peffect

@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<particleeffect>
+	<material name="Materials/Smoke.material" />
+	<numparticles value="1000" />
+	<updateinvisible enable="true" />
+	<relative enable="false" />
+	<scaled enable="true" />
+	<sorted enable="true" />
+	<animlodbias value="0" />
+	<emittertype value="Box" />
+	<emittersize value="1 1 1" />
+	<direction min="-0.15 1 -0.15" max="0.15 1 0.15" />
+	<constantforce value="0 2 0" />
+	<dampingforce value="2" />
+	<activetime value="0" />
+	<inactivetime value="0" />
+	<emissionrate min="100" max="200" />
+	<particlesize min="0.1 0.2" max="0.6 0.7" />
+	<timetolive min="4" max="4" />
+	<velocity min="0.5" max="3" />
+	<rotation min="0" max="0" />
+	<rotationspeed min="60" max="60" />
+	<sizedelta add="0" mul="1.3" />
+	<colorfade color="1 1 1 0" time="0" />
+	<colorfade color="0.69 0.33 0.2 0.5" time="0.64" />
+	<colorfade color="0 0 0 0" time="1.98" />
+	<colorfade color="0 0 0 0" time="4" />
+</particleeffect>

+ 5 - 0
ParticleEmitter3D/Resources/Particles/SmokeStack.peffect.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "0617ef4a50531f06971bfafe09dd05ee",
+	"ParticleEffectImporter": {}
+}

+ 16 - 0
ParticleEmitter3D/Resources/Particles/SnowExplosion.peffect

@@ -0,0 +1,16 @@
+<particleemitter>
+    <material name="Materials/Particle.material" />
+    <updateinvisible enable="true" />
+    <numparticles value="10" />
+    <activetime value="0" />
+    <inactivetime value="0" />
+    <emissionrate value="50" />
+    <sorted enable="true" />
+    <direction min="-1 0 -1" max="1 1 1" />
+    <velocity min="0.5" max="1" />
+    <particlesize value="0.25 0.25" />
+    <timetolive value="0.5" />
+    <constantforce value="0 -2 0" />
+    <colorfade color="0.35 0.35 0.5 1" time="0.0" />
+    <colorfade color="0 0 0 1" time="0.5" />
+</particleemitter>

+ 5 - 0
ParticleEmitter3D/Resources/Particles/SnowExplosion.peffect.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "78dbc4441837540c9080ec23a03325d7",
+	"ParticleEffectImporter": {}
+}

+ 18 - 0
ParticleEmitter3D/Resources/Particles/SnowExplosionBig.peffect

@@ -0,0 +1,18 @@
+<particleemitter>
+    <material name="Materials/Particle.material" />
+    <updateinvisible enable="true" />
+    <numparticles value="10" />
+    <emittertype value="box" />
+    <emittersize value="0.3 0.3 0.3" />
+    <activetime value="0" />
+    <inactivetime value="0" />
+    <emissionrate value="50" />
+    <sorted enable="true" />
+    <direction min="-1 0.5 -1" max="1 1 1" />
+    <velocity min="2" max="3" />
+    <particlesize value="0.6 0.6" />
+    <timetolive value="0.5" />
+    <constantforce value="0.0 -4 0.0" />
+    <colorfade color="0.35 0.35 0.5 1" time="0.0" />
+    <colorfade color="0 0 0 1" time="0.5" />
+</particleemitter>

+ 5 - 0
ParticleEmitter3D/Resources/Particles/SnowExplosionBig.peffect.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "3e81901bf08203dcb0c5ff0257b9d508",
+	"ParticleEffectImporter": {}
+}

+ 16 - 0
ParticleEmitter3D/Resources/Particles/SnowExplosionFade.peffect

@@ -0,0 +1,16 @@
+<particleemitter>
+    <material name="Materials/Particle.material" />
+    <updateinvisible enable="true" />
+    <numparticles value="5" />
+    <activetime value="0" />
+    <inactivetime value="0" />
+    <emissionrate value="50" />
+    <sorted enable="true" />
+    <direction min="-1 0 -1" max="1 1 1" />
+    <velocity min="0.5" max="1" />
+    <particlesize value="0.25 0.25" />
+    <timetolive value="0.5" />
+    <constantforce value="0 -2 0" />
+    <colorfade color="0.1 0.1 0.2 1" time="0.0" />
+    <colorfade color="0 0 0 1" time="0.5" />
+</particleemitter>

+ 5 - 0
ParticleEmitter3D/Resources/Particles/SnowExplosionFade.peffect.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "2954c09bd657a541ae6b05fb85e6b29e",
+	"ParticleEffectImporter": {}
+}

+ 5 - 0
ParticleEmitter3D/Resources/Scenes.asset

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

+ 79 - 0
ParticleEmitter3D/Resources/Scenes/Scene.scene

@@ -0,0 +1,79 @@
+<?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="370" />
+	<attribute name="Next Replicated Component ID" value="1984" />
+	<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="3">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="GlobalLight" />
+		<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="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="Position" value="0 0.54151 -3.4536" />
+		<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="365">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Particles" />
+		<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="ParticleEmitter" id="1978">
+			<attribute name="Effect" value="ParticleEffect;Particles/Fire.peffect" />
+			<attribute name="Face Camera Mode" value="LookAt XYZ" />
+			<attribute name="Animation LOD Bias" value="0" />
+			<attribute name="Particles">
+				<variant type="Int" value="1000" />
+			</attribute>
+			<attribute name="Billboards">
+				<variant type="Int" value="1000" />
+			</attribute>
+			<attribute name="Serialize Particles" value="false" />
+		</component>
+		<component type="JSComponent" id="1982">
+			<attribute name="ComponentFile" value="JSComponentFile;Components/UI.js" />
+		</component>
+	</node>
+</scene>

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

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

+ 5 - 0
ParticleEmitter3D/Resources/Scripts.asset

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

+ 10 - 0
ParticleEmitter3D/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
ParticleEmitter3D/Resources/Scripts/main.js.asset

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

+ 5 - 0
ParticleEmitter3D/Resources/Textures.asset

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

BIN
ParticleEmitter3D/Resources/Textures/Flare.dds


+ 5 - 0
ParticleEmitter3D/Resources/Textures/Flare.dds.asset

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

BIN
ParticleEmitter3D/Resources/Textures/Smoke.dds


+ 5 - 0
ParticleEmitter3D/Resources/Textures/Smoke.dds.asset

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