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

View File

@ -4,10 +4,9 @@
"emitters":
[
{
"name": "Spark",
"name": "Magic Star",
"maxParticles": 300,
"preloading": 100,
"preloading": 20,
"texturePath": "textures/magic-star.png",
"hasInertion": "false",
@ -26,20 +25,20 @@
},
{
"t": 1,
"value": 1
"value": 2
}
]
},
"spawnRange":
{
"value": [ 0, 45, 0, 45 ]
"value": [ 0, 30, 0, 45 ]
},
"lifeTime":
{
"min": 1.5,
"max": 2.5
"max": 3
},
"coords_system": "PARTICLE_BIRTH",
@ -56,9 +55,9 @@
"value": [ 0, 0, 0 ]
},
{
"t": 2.000,
"min": [ 400, 0, 0 ],
"max": [ 400, 0, 0 ]
"t": 1.000,
"min": [ 300, 0, 0 ],
"max": [ 300, 0, 0 ]
}
]
},
@ -82,7 +81,195 @@
"color":
{
"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":
{
"min": 6,
"max": 6
"value": 6
},
"coords_system": "PARTICLE_EFFECT",
@ -96,14 +95,8 @@
},
"scale":
{
"interpolation": "DISCRETE",
"timeline":
[
{
"value": [ 20, 7.12 ]
}
]
},
"color":

View File

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

View File

@ -1,57 +1,37 @@
{
"name": "Simple Sparkler",
"name": "Sparkler - бенгальский огонь",
"emitters":
[
{
"name": "Spark",
"name": "Magic Star",
"maxParticles": 1000,
"maxParticles": 10000,
"preloading": 1000,
"texturePath": "textures/spark-white.png",
"hasInertion": "false",
"gravity": [0, 0, 0],
"texturePath": "textures/star-white.png",
"gravity": [ 0, -100, 0 ],
"spawnRange_system": "PARTICLE_EFFECT",
"spawnTotal":
{
"interpolation": "CUBIC_SPLINE",
"timelineType": "LIMITED",
"timeline":
[
{
"t": 0.000,
"value": 0
},
{
"t": 0.010,
"value": 0
},
{
"t": 9.990,
"value": 2000
},
{
"t": 10.000,
"value": 2000
}
]
"value": 50
},
"spawnRange":
{
"value": [ 0, 0, 0, 360 ]
"value": [ 0, 0, 360, 180 ]
},
"lifeTime":
{
"min": 0.1,
"max": 1
"min": 10,
"max": 10
},
"coords_system": "PARTICLE_BIRTH",
"coords_system": "PARTICLE_EFFECT",
"coords_axis_system": "PARTICLE_BIRTH",
"rotation_system": "PARTICLE_EFFECT",
@ -65,16 +45,33 @@
"value": [ 0, 0, 0 ]
},
{
"t": 1,
"min": [ 300, 0, 0 ],
"max": [ 600, 0, 0 ]
"t": 1.000,
"min": [ 150, 0, 0 ],
"max": [ 150, 0, 0 ]
}
]
},
"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":
@ -90,7 +87,181 @@
"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)
{
ignoreMove = false;
if (mouseState.LeftButtonPressed)
{
sparkler.setCoords({ (float)mouseState.X, Renderer->GetScreenHeight() - (float)mouseState.Y, 0 });
}
else if (mouseState.RightButtonPressed)
if (mouseState.RightButtonPressed)
{
ignoreMove = true;
if (sparkler.isSpawning())
{
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()

View File

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