particles testing

This commit is contained in:
Vladislav Khorev Dev 2017-12-25 05:44:14 +05:00
parent cbb3ffb008
commit c55b8694e7
14 changed files with 614 additions and 100 deletions

View File

@ -1,3 +1,3 @@
{ {
"effect": "effects/sparkler.json" "effect": "effects/magic-stars.json"
} }

100
assets/effects/O-func.json Executable file
View File

@ -0,0 +1,100 @@
{
"name": "Sparkler - бенгальский огонь",
"emitters":
[
{
"name": "Spark",
"maxParticles": 300,
"preloading": 100,
"texturePath": "textures/spark.png",
"hasInertion": "false",
"gravity": [0, 0, 0],
"spawnRange_system": "PARTICLE_EFFECT",
"spawnTotal":
{
"interpolation": "LINEAR_SPLINE",
"timeline":
[
{
"t": 0,
"value": 0
},
{
"t": 1,
"value": 5
}
]
},
"spawnRange":
{
"value": [ 0, 0, 0, 0 ]
},
"lifeTime":
{
"value": 2
},
"coords_system": "PARTICLE_BIRTH",
"coords_axis_system": "PARTICLE_BIRTH",
"rotation_system": "PARTICLE_EFFECT",
"coords":
{
"interpolation": "CUBIC_SPLINE",
"timeline":
[
{
"t": 0.000,
"value": [ 100, 0, 0]
},
{
"t": 0.1,
"value": [ 95, 30, 0]
},
{
"t": 0.5,
"value": [ 0, 100, 0]
},
{
"t": 1.0,
"value": [ -100, 0, 0]
},
{
"t": 1.5,
"value": [ 0, -100, 0]
},
{
"t": 1.9,
"value": [ 95, -30, 0]
},
{
"t": 2.000,
"value": [ 100, 0, 0]
}
]
},
"rotation":
{
"value": [ 0, 0, 0 ]
},
"scale":
{
"value": [ 10, 10 ]
},
"color":
{
"value": [ 1, 1, 0, 1 ]
}
}
]
}

View File

@ -38,8 +38,7 @@
"lifeTime": "lifeTime":
{ {
"min": 2, "value": 2
"max": 2
}, },
"coords_system": "PARTICLE_EFFECT", "coords_system": "PARTICLE_EFFECT",
@ -56,20 +55,20 @@
"value": [ 0, 0, 0] "value": [ 0, 0, 0]
}, },
{ {
"t": 0.500, "t": 0.5,
"value": [ 50, 20, 0] "value": [ 50, 20, 0]
}, },
{ {
"t": 1.000, "t": 1.0,
"value": [ 100, 150, 0] "value": [ 100, 100, 0]
}, },
{ {
"t": 1.500, "t": 1.5,
"value": [ 150, 280, 0] "value": [ 150, 180, 0]
}, },
{ {
"t": 2, "t": 2.000,
"value": [ 200, 300, 0] "value": [ 200, 200, 0]
} }
] ]
}, },
@ -80,14 +79,8 @@
}, },
"scale": "scale":
{
"interpolation": "DISCRETE",
"timeline":
[
{ {
"value": [ 10, 10 ] "value": [ 10, 10 ]
}
]
}, },
"color": "color":

View File

@ -4,10 +4,9 @@
"emitters": "emitters":
[ [
{ {
"name": "Spark", "name": "Magic Star",
"maxParticles": 300, "preloading": 20,
"preloading": 100,
"texturePath": "textures/magic-star.png", "texturePath": "textures/magic-star.png",
"hasInertion": "false", "hasInertion": "false",
@ -26,20 +25,20 @@
}, },
{ {
"t": 1, "t": 1,
"value": 1 "value": 2
} }
] ]
}, },
"spawnRange": "spawnRange":
{ {
"value": [ 0, 45, 0, 45 ] "value": [ 0, 30, 0, 45 ]
}, },
"lifeTime": "lifeTime":
{ {
"min": 1.5, "min": 1.5,
"max": 2.5 "max": 3
}, },
"coords_system": "PARTICLE_BIRTH", "coords_system": "PARTICLE_BIRTH",
@ -56,9 +55,9 @@
"value": [ 0, 0, 0 ] "value": [ 0, 0, 0 ]
}, },
{ {
"t": 2.000, "t": 1.000,
"min": [ 400, 0, 0 ], "min": [ 300, 0, 0 ],
"max": [ 400, 0, 0 ] "max": [ 300, 0, 0 ]
} }
] ]
}, },
@ -82,7 +81,195 @@
"color": "color":
{ {
"value": [ 1, 1, 1, 1 ] "value": [ 1, 1, 1, 1 ]
},
"emitters":
[
{
"name": "Spark",
"matchDeathTime": "true",
"maxParticles": 110,
"preloading": 110,
"texturePath": "textures/spark-white.png",
"gravity": [0, -100, 0],
"spawnRange_system": "PARTICLE_BIRTH",
"spawnTotal":
{
"interpolation": "LINEAR_SPLINE",
"timeline":
[
{
"t": 0.000,
"value": 0
},
{
"t": 1,
"value": 50
}
]
},
"spawnRange":
{
"value": [ 0, 0, 0, 360 ]
},
"lifeTime":
{
"min": 1,
"max": 2
},
"coords_system": "PARTICLE_BIRTH",
"coords_axis_system": "PARTICLE_BIRTH",
"rotation_system": "PARTICLE_BIRTH",
"coords":
{
"interpolation": "LINEAR_SPLINE",
"timeline":
[
{
"t": 0.000,
"value": [ 0, 0, 0 ]
},
{
"t": 1.000,
"min": [ 0, 0, 0 ],
"max": [ 50, 0, 0 ]
}
]
},
"rotation":
{
"value": [ 0, 0, 0 ]
},
"scale":
{
"value": [ 10, 10 ]
},
"color":
{
"interpolation": "LINEAR_SPLINE",
"timeline":
[
{
"t": 0.000,
"value": [ 0, 1, 1, 1 ]
},
{
"t": 1.000,
"value": [ 0, 0, 1, 1 ]
},
{
"t": 1.200,
"value": [ 0, 0, 1, 0 ]
}
]
}
},
{
"name": "Spark",
"matchParentDeathTime": "true",
"matchDeathTime": "true",
"maxParticles": 300,
"preloading": 300,
"texturePath": "textures/spark-white.png",
"hasInertion": "true",
"gravity": [0, -100, 0],
"spawnRange_system": "PARTICLE_BIRTH",
"spawnTotal":
{
"interpolation": "DISCRETE",
"timeline":
[
{
"t": 0.000,
"value": 0
},
{
"t": 2.000,
"value": 300
}
]
},
"spawnRange":
{
"value": [ 0, 0, 0, 360 ]
},
"lifeTime":
{
"min": 1,
"max": 2
},
"coords_system": "PARTICLE_BIRTH",
"coords_axis_system": "PARTICLE_BIRTH",
"rotation_system": "PARTICLE_BIRTH",
"coords":
{
"interpolation": "LINEAR_SPLINE",
"timeline":
[
{
"t": 0.000,
"value": [ 0, 0, 0 ]
},
{
"t": 1.000,
"min": [ 25, 0, 0 ],
"max": [ 300, 0, 0 ]
}
]
},
"rotation":
{
"value": [ 0, 0, 0 ]
},
"scale":
{
"value": [ 10, 10 ]
},
"color":
{
"interpolation": "LINEAR_SPLINE",
"timeline":
[
{
"t": 0.000,
"value": [ 1, 1, 0, 1 ]
},
{
"t": 1.000,
"value": [ 1, 0, 0, 1 ]
},
{
"t": 1.200,
"value": [ 1, 0, 0, 0 ]
}
]
} }
} }
] ]
}
]
} }

View File

@ -38,8 +38,7 @@
"lifeTime": "lifeTime":
{ {
"min": 6, "value": 6
"max": 6
}, },
"coords_system": "PARTICLE_EFFECT", "coords_system": "PARTICLE_EFFECT",
@ -96,14 +95,8 @@
}, },
"scale": "scale":
{
"interpolation": "DISCRETE",
"timeline":
[
{ {
"value": [ 20, 7.12 ] "value": [ 20, 7.12 ]
}
]
}, },
"color": "color":

View File

@ -38,8 +38,7 @@
"lifeTime": "lifeTime":
{ {
"min": 6, "value": 6
"max": 6
}, },
"coords_system": "PARTICLE_EFFECT", "coords_system": "PARTICLE_EFFECT",
@ -96,14 +95,8 @@
}, },
"scale": "scale":
{
"interpolation": "DISCRETE",
"timeline":
[
{ {
"value": [ 10, 10 ] "value": [ 10, 10 ]
}
]
}, },
"color": "color":

View File

@ -0,0 +1,91 @@
{
"name": "Simple Sparkler",
"emitters":
[
{
"name": "Spark",
"maxParticles": 2000,
"preloading": 2000,
"texturePath": "textures/spark-white.png",
"hasInertion": "false",
"gravity": [0, 0, 0],
"spawnRange_system": "PARTICLE_EFFECT",
"spawnTotal":
{
"interpolation": "CUBIC_SPLINE",
"timelineType": "LOOPED",
"timeline":
[
{
"t": 0.000,
"value": 0
},
{
"t": 0.001,
"value": 0
},
{
"t": 9.999,
"value": 10000
},
{
"t": 10.000,
"value": 10000
}
]
},
"spawnRange":
{
"value": [ 0, 0, 0, 360 ]
},
"lifeTime":
{
"min": 0.1,
"max": 1
},
"coords_system": "PARTICLE_BIRTH",
"coords_axis_system": "PARTICLE_BIRTH",
"rotation_system": "PARTICLE_EFFECT",
"coords":
{
"interpolation": "LINEAR_SPLINE",
"timeline":
[
{
"t": 0.000,
"value": [ 0, 0, 0 ]
},
{
"t": 1,
"min": [ 300, 0, 0 ],
"max": [ 600, 0, 0 ]
}
]
},
"rotation":
{
"value": [ 0, 0, 0 ]
},
"scale":
{
"value": [ 10, 10 ]
},
"color":
{
"value": [ 1, 1, 0, 1 ]
}
}
]
}

View File

@ -70,14 +70,8 @@
}, },
"scale": "scale":
{
"interpolation": "DISCRETE",
"timeline":
[
{ {
"value": [ 10, 10 ] "value": [ 10, 10 ]
}
]
}, },
"color": "color":

View File

@ -1,57 +1,37 @@
{ {
"name": "Simple Sparkler", "name": "Sparkler - бенгальский огонь",
"emitters": "emitters":
[ [
{ {
"name": "Spark", "name": "Magic Star",
"maxParticles": 1000, "maxParticles": 10000,
"preloading": 1000, "preloading": 1000,
"texturePath": "textures/spark-white.png",
"hasInertion": "false", "texturePath": "textures/star-white.png",
"gravity": [0, 0, 0],
"gravity": [ 0, -100, 0 ],
"spawnRange_system": "PARTICLE_EFFECT", "spawnRange_system": "PARTICLE_EFFECT",
"spawnTotal": "spawnTotal":
{ {
"interpolation": "CUBIC_SPLINE", "value": 50
"timelineType": "LIMITED",
"timeline":
[
{
"t": 0.000,
"value": 0
},
{
"t": 0.010,
"value": 0
},
{
"t": 9.990,
"value": 2000
},
{
"t": 10.000,
"value": 2000
}
]
}, },
"spawnRange": "spawnRange":
{ {
"value": [ 0, 0, 0, 360 ] "value": [ 0, 0, 360, 180 ]
}, },
"lifeTime": "lifeTime":
{ {
"min": 0.1, "min": 10,
"max": 1 "max": 10
}, },
"coords_system": "PARTICLE_BIRTH", "coords_system": "PARTICLE_EFFECT",
"coords_axis_system": "PARTICLE_BIRTH", "coords_axis_system": "PARTICLE_BIRTH",
"rotation_system": "PARTICLE_EFFECT", "rotation_system": "PARTICLE_EFFECT",
@ -65,16 +45,33 @@
"value": [ 0, 0, 0 ] "value": [ 0, 0, 0 ]
}, },
{ {
"t": 1, "t": 1.000,
"min": [ 300, 0, 0 ], "min": [ 150, 0, 0 ],
"max": [ 600, 0, 0 ] "max": [ 150, 0, 0 ]
} }
] ]
}, },
"rotation": "rotation":
{ {
"value": [ 0, 0, 0 ] "interpolation": "LINEAR_SPLINE",
"timeOffset":
{
"min": 0,
"max": 1
},
"timelineType": "LOOPED",
"timeline":
[
{
"t": 0.000,
"value": [ 0, 45, 0 ]
},
{
"t": 1.000,
"value": [ 360, 45, 0 ]
}
]
}, },
"scale": "scale":
@ -90,7 +87,181 @@
"color": "color":
{ {
"value": [ 1, 1, 0, 1 ] "value": [ 0, 1, 0, 1 ]
}
},
{
"name": "Magic Star",
"maxParticles": 10000,
"preloading": 1000,
"texturePath": "textures/circle-white.png",
"gravity": [ 0, -100, 0 ],
"spawnRange_system": "PARTICLE_EFFECT",
"spawnTotal":
{
"value": 50
},
"spawnRange":
{
"value": [ 0, 0, 360, 180 ]
},
"lifeTime":
{
"min": 10,
"max": 10
},
"coords_system": "PARTICLE_EFFECT",
"coords_axis_system": "PARTICLE_BIRTH",
"rotation_system": "PARTICLE_EFFECT",
"coords":
{
"interpolation": "LINEAR_SPLINE",
"timeline":
[
{
"t": 0.000,
"value": [ 0, 0, 0 ]
},
{
"t": 1.000,
"min": [ 150, 0, 0 ],
"max": [ 150, 0, 0 ]
}
]
},
"rotation":
{
"interpolation": "LINEAR_SPLINE",
"timeOffset":
{
"min": 0,
"max": 1
},
"timelineType": "LOOPED",
"timeline":
[
{
"t": 0.000,
"value": [ 0, 45, 0 ]
},
{
"t": 1.000,
"value": [ 360, 45, 0 ]
}
]
},
"scale":
{
"interpolation": "DISCRETE",
"timeline":
[
{
"value": [ 10, 10 ]
}
]
},
"color":
{
"value": [ 1, 0, 0, 1 ]
}
},
{
"name": "Magic Star",
"maxParticles": 10000,
"preloading": 1000,
"texturePath": "textures/rect-white.png",
"gravity": [ 0, -100, 0 ],
"spawnRange_system": "PARTICLE_EFFECT",
"spawnTotal":
{
"value": 50
},
"spawnRange":
{
"value": [ 0, 0, 360, 180 ]
},
"lifeTime":
{
"min": 10,
"max": 10
},
"coords_system": "PARTICLE_EFFECT",
"coords_axis_system": "PARTICLE_BIRTH",
"rotation_system": "PARTICLE_EFFECT",
"coords":
{
"interpolation": "LINEAR_SPLINE",
"timeline":
[
{
"t": 0.000,
"value": [ 0, 0, 0 ]
},
{
"t": 1.000,
"min": [ 150, 0, 0 ],
"max": [ 150, 0, 0 ]
}
]
},
"rotation":
{
"interpolation": "LINEAR_SPLINE",
"timeOffset":
{
"min": 0,
"max": 1
},
"timelineType": "LOOPED",
"timeline":
[
{
"t": 0.000,
"value": [ 0, 45, 0 ]
},
{
"t": 1.000,
"value": [ 360, 45, 0 ]
}
]
},
"scale":
{
"interpolation": "DISCRETE",
"timeline":
[
{
"value": [ 10, 10 ]
}
]
},
"color":
{
"value": [ 0, 0, 1, 1 ]
} }
} }
] ]

BIN
assets/textures/circle-white.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
assets/textures/rect-white.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
assets/textures/star-white.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -66,20 +66,14 @@ void TMyApplication::InnerDeinit()
{ {
} }
bool ignoreMove = false;
void TMyApplication::InnerOnMouseDown(TMouseState& mouseState) void TMyApplication::InnerOnMouseDown(TMouseState& mouseState)
{ {
ignoreMove = false;
if (mouseState.LeftButtonPressed) if (mouseState.LeftButtonPressed)
{ {
sparkler.setCoords({ (float)mouseState.X, Renderer->GetScreenHeight() - (float)mouseState.Y, 0 }); sparkler.setCoords({ (float)mouseState.X, Renderer->GetScreenHeight() - (float)mouseState.Y, 0 });
} }
else if (mouseState.RightButtonPressed) if (mouseState.RightButtonPressed)
{ {
ignoreMove = true;
if (sparkler.isSpawning()) if (sparkler.isSpawning())
{ {
sparkler.stopSpawn(); sparkler.stopSpawn();
@ -91,14 +85,12 @@ void TMyApplication::InnerOnMouseDown(TMouseState& mouseState)
} }
} }
void TMyApplication::InnerOnMove(Vector2f p, Vector2f shift) void TMyApplication::InnerOnMouseMove(TMouseState& mouseState)
{ {
if (ignoreMove) if (mouseState.LeftButtonPressed)
{ {
return; sparkler.setCoords({ (float)mouseState.X, Renderer->GetScreenHeight() - (float)mouseState.Y, 0 });
} }
sparkler.setCoords({ p[0], p[1], 0 });
} }
void TMyApplication::InnerDraw() void TMyApplication::InnerDraw()

View File

@ -54,7 +54,7 @@ public:
virtual void InnerOnMouseDown(TMouseState& mouseState); virtual void InnerOnMouseDown(TMouseState& mouseState);
virtual void InnerOnMove(Vector2f p, Vector2f shift); virtual void InnerOnMouseMove(TMouseState& mouseState);
}; };