Beispiel #1
0
        public static JsonObject serialize(EmitterFeature feature)
        {
            JsonObject obj = new JsonObject(JsonObject.JsonType.OBJECT);

            switch (feature.emitterType)
            {
            case EmitterFeature.EmitterType.POINT: obj["emitterType"] = "point"; break;

            case EmitterFeature.EmitterType.LINE: obj["emitterType"] = "line"; break;

            case EmitterFeature.EmitterType.PLANE: obj["emitterType"] = "plane"; break;

            case EmitterFeature.EmitterType.CIRCLE: obj["emitterType"] = "circle"; break;
            }
            obj["continuous"]       = feature.continuous;
            obj["emissionRate"]     = feature.emisionRate;
            obj["p1"]               = feature.p1;
            obj["P1Variance"]       = feature.p1Var;
            obj["p2"]               = feature.p2;
            obj["p2Variance"]       = feature.P2Var;
            obj["velocity"]         = feature.velocity;
            obj["velocityVariance"] = feature.velocityVar;
            obj["size"]             = feature.size;
            obj["sizeVariance"]     = feature.sizeVar;
            obj["color"]            = feature.color;
            obj["colorVariance"]    = feature.colorVar;
            obj["rotation"]         = feature.rotation;
            obj["rotationVariance"] = feature.rotationVar;
            obj["mass"]             = feature.mass;
            obj["massVariance"]     = feature.massVar;
            obj["lifetime"]         = feature.lifetime;
            obj["lifetimeVariance"] = feature.lifetimeVar;
            return(obj);
        }
Beispiel #2
0
        public override ParticleFeature create(JsonObject initData)
        {
            ParticleInitializationData init = new ParticleInitializationData();
            String emmitType = (String)initData["emitterType"];

            switch (emmitType)
            {
            case "point": init.myEmitterType = EmitterFeature.EmitterType.POINT; break;

            case "line": init.myEmitterType = EmitterFeature.EmitterType.LINE; break;

            case "plane": init.myEmitterType = EmitterFeature.EmitterType.PLANE; break;

            case "circle": init.myEmitterType = EmitterFeature.EmitterType.CIRCLE; break;
            }

            init.myContinous        = (bool)initData["continuous"];
            init.myEmissionRate     = (float)initData["emissionRate"];
            init.myP1               = (Vector3)initData["p1"];
            init.myP1Variance       = (Vector3)initData["p1Variance"];
            init.myP2               = (Vector3)initData["p2"];
            init.myP2Variance       = (Vector3)initData["p2Variance"];
            init.myVelocity         = (Vector3)initData["velocity"];
            init.myVelocityVariance = (Vector3)initData["velocityVariance"];
            init.mySize             = (Vector3)initData["size"];
            init.mySizeVariance     = (Vector3)initData["sizeVariance"];
            init.myColor            = (Color4)initData["color"];
            init.myColorVariance    = (Color4)initData["colorVariance"];
            init.myRotation         = (float)initData["rotation"];
            init.myRotationVariance = (float)initData["rotationVariance"];
            init.myMass             = (float)initData["mass"];
            init.myMassVariance     = (float)initData["massVariance"];
            init.myLifetime         = (float)initData["lifetime"];
            init.myLifetimeVariance = (float)initData["lifetimeVariance"];

            EmitterFeature lf = new EmitterFeature(init);

            return(lf);
        }