Jump to content

[SOLVED] - Deserialized particle system to NOT initially start


MackeyK24
 Share

Recommended Posts

I have the following particle system serialized into the scene... works great except for that fact that they always auto start the particles... What if i don't want some to start at scene load, but ill start them later... Is there some kinda of 'autoStart' flag we can add to deserialization that will only start a deserialized particle system if autostart is set to true, other you will have to call particles.start() in code.

Here is the following son i have for the particle system but see any kind of 'started' flags that be set:

		{
			"emitterId" : "1d03dbd4-f86a-4ee3-b11a-1e99606bf25a",
			"gravity" : [
				0,
				-9.81,
				0
			],
			"direction1" : [
				-7,
				8,
				3
			],
			"direction2" : [
				7,
				8,
				-3
			],
			"minEmitBox" : [
				-1,
				0,
				0
			],
			"maxEmitBox" : [
				1,
				0,
				0
			],
			"color1" : [
				0.8161765,
				0.390084326,
				0.390084326,
				1
			],
			"color2" : [
				0.06893382,
				0.375,
				0.134368643,
				1
			],
			"colorDead" : [
				0.350237876,
				0.399548054,
				0.5808823,
				1
			],
			"deadAlpha" : 0,
			"emitRate" : 1000,
			"updateSpeed" : 0.01,
			"targetStopFrame" : 5,
			"minEmitPower" : 1,
			"maxEmitPower" : 3,
			"minLifeTime" : 0.3,
			"maxLifeTime" : 1.5,
			"minSize" : 0.1,
			"maxSize" : 0.5,
			"minAngularSpeed" : 0,
			"maxAngularSpeed" : 3.14,
			"textureName" : "Flare.png",
			"blendMode" : 0,
			"capacity" : 500,
			"textureMask" : [
				0,
				0,
				0,
				0
			],
			"linkToEmitter" : true,
			"name" : "solo1"
		}

 

Link to comment
Share on other sites

I found it... But it is NOT in the BabylonExporter.Entities assembly... Neither is Name or id (it looks like it default name to id though)... Si i had to subclass it like so:

	[DataContract]
	public class UnityParticleSystem : BabylonExport.Entities.BabylonParticleSystem
	{
		[DataMember]
		public string name;

		[DataMember]
		public bool preventAutoStart;
	}

 

Link to comment
Share on other sites

just dont emitter.start() ?

Ok I reread...

how are you creating it?

I would create a blank emitter never ;start it set it to isVisible = false;
then when you wanna unseralize your settings just iterate through your object keys and set the matching values on the cloned particle system, with a flag to turn it on as you spoke of or not.

Link to comment
Share on other sites

is there a tag in blender to stop that? I do nothing with .babylon files i wont even touch them... o_O OBJ and FBX all day all day.... or my own 3d file type for what ever project so I don't think I will be much help with this topic then if its about a bjs file... now if its a JSON object and (which a bjs file is i think) its the approach I described above.

Link to comment
Share on other sites

Hey Delta... I actually have a few missing entities ... I will PR them.. But There is no BabylonShaderMaterial.cs

So i created one that i am using in my BabylonJS Toolkit for unity. But i use Dictionaries some some of ht floats and colors and vectors... I could see anywhere else

you have something structured like that so i just made one... It works great. I have build in Babylon.ShaderMaterial support direct from unity WITH NO CLIENT CODE necessary, all thru de-serialization or Parsing.

Anyways, take a look and tell me if you want this Babylon.ShaderMaterial class added to the PR for 3ds max entities project:


using System.Collections.Generic;
using System.Runtime.Serialization;

namespace BabylonExport.Entities
{
	[DataContract]
	public class BabylonShaderMaterial : BabylonMaterial
	{
		[DataMember]
		public string customType { get; private set; }

		[DataMember]
		public object shaderPath { get; set; }

		[DataMember]
		public BabylonShaderOptions options { get; set; }

		[DataMember]
		public Dictionary<string, object> textures { get; set; }

		[DataMember]
		public Dictionary<string, object[]> textureArrays { get; set; }

		[DataMember]
		public Dictionary<string, object> floats { get; set; }

		[DataMember]
		public Dictionary<string, object[]> floatArrays { get; set; }

		[DataMember]
		public Dictionary<string, object> colors3 { get; set; }

		[DataMember]
		public Dictionary<string, object> colors4 { get; set; }

		[DataMember]
		public Dictionary<string, object> vectors2 { get; set; }

		[DataMember]
		public Dictionary<string, object> vectors3 { get; set; }

		[DataMember]
		public Dictionary<string, object> vectors4 { get; set; }

		[DataMember]
		public Dictionary<string, object> matrices { get; set; }

		[DataMember]
		public Dictionary<string, object> matrices2x2 { get; set; }

		[DataMember]
		public Dictionary<string, object> matrices3x3 { get; set; }

		[DataMember]
		public Dictionary<string, object[]> vectors3Arrays { get; set; }

		public BabylonShaderMaterial()
		{
			this.customType = "BABYLON.ShaderMaterial";
			this.shaderPath = null;
			this.options = new BabylonShaderOptions();
			this.textures = new Dictionary<string, object>();
			this.textureArrays = new Dictionary<string, object[]>();
			this.floats = new Dictionary<string, object>();
			this.floatArrays = new Dictionary<string, object[]>();
			this.colors3 = new Dictionary<string, object>();
			this.colors4 = new Dictionary<string, object>();
			this.vectors2 = new Dictionary<string, object>();
			this.vectors3 = new Dictionary<string, object>();
			this.vectors4 = new Dictionary<string, object>();
			this.matrices = new Dictionary<string, object>();
			this.matrices2x2 = new Dictionary<string, object>();
			this.matrices3x3 = new Dictionary<string, object>();
			this.vectors3Arrays = new Dictionary<string, object[]>();
		}
	}

	[DataContract]
	public class BabylonShaderOptions
	{
		[DataMember]
		public string[] attributes { get; set; }

		[DataMember]
		public string[] uniforms { get; set; }

		[DataMember]
		public bool needAlphaBlending { get; set; }

		[DataMember]
		public bool needAlphaTesting { get; set; }

		[DataMember]
		public string[] samplers { get; set; }

		[DataMember]
		public string[] defines { get; set; }

		public BabylonShaderOptions()
		{
			this.attributes = null;
			this.uniforms = null;
			this.needAlphaBlending = false;
			this.needAlphaTesting = false;
			this.samplers = null;
			this.defines = null;
		}
	}
}

 

Link to comment
Share on other sites

Also... I made this HDRCubeTexture... Do want this PR as well:

using System.Runtime.Serialization;
namespace BabylonExport.Entities
{
	[DataContract]
	public class BabylonHDRCubeTexture : BabylonTexture
	{
		[DataMember]
		public string customType { get; private set; }

		[DataMember]
		public int size { get; set; }

		[DataMember]
		public bool useInGammaSpace { get; set; }

		[DataMember]
		public bool generateHarmonics { get; set; }

		[DataMember]
		public bool usePMREMGenerator { get; set; }

		[DataMember]
		public bool isBABYLONPreprocessed { get; set; }

		public BabylonHDRCubeTexture()
		{
			this.customType = "BABYLON.HDRCubeTexture";
			this.size = 0;
			this.isCube = true;
			this.useInGammaSpace = false;
			this.generateHarmonics = true;
			this.usePMREMGenerator = false;
			this.isBABYLONPreprocessed = false;
		}
	}
}

 

Link to comment
Share on other sites

No... Typescript is basically a strong type like language (a lot like the old Adobe ActionScript AS3)... It uses Es6 style syntax...

var mystring:String = "Hello"

and many other language syntax features... This ES6 style script is 'transpiled' or 'compiled' to ES5 regular Javascript.

The main advantage is that you can write your web application (Especially Larger Web Applications) using a strong type language and all its language features... 

But at its heart... It ultimately ends up as regulate javascript.

Link to comment
Share on other sites

So truly, if you know how to do all the constructors and prototypes wrapping and timeouts then there is really no point?  I was kinda interested because at face value it looks like less work but then again to have to compile my script every time I save it.. yeah but no.  I think ill just keep powerleveling in plain old js.

AS2 and AS3 ahhh man I remember those days RIP flash...

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...