Testing particles

This commit is contained in:
Vladislav Khorev Dev 2017-12-24 04:55:01 +05:00
parent 93e171ec5b
commit cbb3ffb008
27 changed files with 574 additions and 134 deletions

3
assets/config.json Executable file
View File

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

View File

@ -8,17 +8,16 @@
"maxParticles": 300,
"preloading": 100,
"texturePath": "spark.png",
"texturePath": "textures/spark.png",
"hasInertion": "false",
"gravity": [0, 0, 0],
"spawnRange_system": "PARTICLE_BIRTH",
"spawnRange_system": "PARTICLE_EFFECT",
"spawnTotal":
{
"interpolation": "LINEAR_SPLINE",
"isLooped": "false",
"timeline":
[
{
@ -26,21 +25,21 @@
"value": 0
},
{
"t": 10,
"value": 1000
"t": 1,
"value": 5
}
]
},
"spawnRange":
{
"value": [ 90, 0, 0, 360 ]
"value": [ 0, 0, 0, 0 ]
},
"lifeTime":
{
"min": 0.1,
"max": 0.3
"min": 2,
"max": 2
},
"coords_system": "PARTICLE_EFFECT",
@ -49,17 +48,28 @@
"coords":
{
"interpolation": "LINEAR_SPLINE",
"isLooped": "false",
"interpolation": "CUBIC_SPLINE",
"timeline":
[
{
"t": 0.000,
"value": [ 0, 0, 0 ]
"value": [ 0, 0, 0]
},
{
"t": 0.500,
"value": [ 50, 20, 0]
},
{
"t": 1.000,
"value": [ 0, 0, 400 ]
"value": [ 100, 150, 0]
},
{
"t": 1.500,
"value": [ 150, 280, 0]
},
{
"t": 2,
"value": [ 200, 300, 0]
}
]
},
@ -72,11 +82,10 @@
"scale":
{
"interpolation": "DISCRETE",
"isLooped": "false",
"timeline":
[
{
"value": [ 20, 20 ]
"value": [ 10, 10 ]
}
]
},

88
assets/effects/magic-stars.json Executable file
View File

@ -0,0 +1,88 @@
{
"name": "Sparkler - бенгальский огонь",
"emitters":
[
{
"name": "Spark",
"maxParticles": 300,
"preloading": 100,
"texturePath": "textures/magic-star.png",
"hasInertion": "false",
"gravity": [0, 0, 0],
"spawnRange_system": "PARTICLE_EFFECT",
"spawnTotal":
{
"interpolation": "LINEAR_SPLINE",
"timeline":
[
{
"t": 0,
"value": 0
},
{
"t": 1,
"value": 1
}
]
},
"spawnRange":
{
"value": [ 0, 45, 0, 45 ]
},
"lifeTime":
{
"min": 1.5,
"max": 2.5
},
"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": 2.000,
"min": [ 400, 0, 0 ],
"max": [ 400, 0, 0 ]
}
]
},
"rotation":
{
"value": [ 0, 0, 0 ]
},
"scale":
{
"interpolation": "DISCRETE",
"timeline":
[
{
"value": [ 22.625, 12.5 ]
}
]
},
"color":
{
"value": [ 1, 1, 1, 1 ]
}
}
]
}

115
assets/effects/sine-comets.json Executable file
View File

@ -0,0 +1,115 @@
{
"name": "Sparkler - бенгальский огонь",
"emitters":
[
{
"name": "Spark",
"maxParticles": 300,
"preloading": 100,
"texturePath": "textures/comet.png",
"hasInertion": "false",
"gravity": [0, 0, 0],
"spawnRange_system": "PARTICLE_EFFECT",
"spawnTotal":
{
"interpolation": "LINEAR_SPLINE",
"timeline":
[
{
"t": 0,
"value": 0
},
{
"t": 1,
"value": 3
}
]
},
"spawnRange":
{
"value": [ 0, 0, 0, 0 ]
},
"lifeTime":
{
"min": 6,
"max": 6
},
"coords_system": "PARTICLE_EFFECT",
"coords_axis_system": "PARTICLE_BIRTH",
"rotation_system": "PARTICLE_ITSELF",
"coords":
{
"interpolation": "CUBIC_SPLINE",
"timeline":
[
{
"t": 0.000,
"value": [ 50, 0, 0 ]
},
{
"t": 0.001,
"value": [ 50, 0, 0 ]
},
{
"t": 1.000,
"value": [ 100, 100, 0 ]
},
{
"t": 2.000,
"value": [ 200, -100, 0 ]
},
{
"t": 3.000,
"value": [ 300, 100, 0 ]
},
{
"t": 4.000,
"value": [ 400, -100, 0 ]
},
{
"t": 5.000,
"value": [ 500, 100, 0 ]
},
{
"t": 5.999,
"value": [ 600, -100, 0 ]
},
{
"t": 6.000,
"value": [ 600, -100, 0 ]
}
]
},
"rotation":
{
"value": [ 0, 0, 0 ]
},
"scale":
{
"interpolation": "DISCRETE",
"timeline":
[
{
"value": [ 20, 7.12 ]
}
]
},
"color":
{
"value": [ 1, 1, 1, 1 ]
}
}
]
}

115
assets/effects/sine-sparks.json Executable file
View File

@ -0,0 +1,115 @@
{
"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": 20
}
]
},
"spawnRange":
{
"value": [ 0, 0, 0, 0 ]
},
"lifeTime":
{
"min": 6,
"max": 6
},
"coords_system": "PARTICLE_EFFECT",
"coords_axis_system": "PARTICLE_BIRTH",
"rotation_system": "PARTICLE_EFFECT",
"coords":
{
"interpolation": "CUBIC_SPLINE",
"timeline":
[
{
"t": 0.000,
"value": [ 50, 0, 0 ]
},
{
"t": 0.001,
"value": [ 50, 0, 0 ]
},
{
"t": 1.000,
"value": [ 100, 100, 0 ]
},
{
"t": 2.000,
"value": [ 200, -100, 0 ]
},
{
"t": 3.000,
"value": [ 300, 100, 0 ]
},
{
"t": 4.000,
"value": [ 400, -100, 0 ]
},
{
"t": 5.000,
"value": [ 500, 100, 0 ]
},
{
"t": 5.999,
"value": [ 600, -100, 0 ]
},
{
"t": 6.000,
"value": [ 600, -100, 0 ]
}
]
},
"rotation":
{
"value": [ 0, 0, 0 ]
},
"scale":
{
"interpolation": "DISCRETE",
"timeline":
[
{
"value": [ 10, 10 ]
}
]
},
"color":
{
"value": [ 1, 1, 0, 1 ]
}
}
]
}

89
assets/effects/sparkler.json Executable file
View File

@ -0,0 +1,89 @@
{
"name": "Simple Sparkler",
"emitters":
[
{
"name": "Spark",
"maxParticles": 1000,
"preloading": 1000,
"texturePath": "textures/spark-white.png",
"hasInertion": "false",
"gravity": [0, 0, 0],
"spawnRange_system": "PARTICLE_EFFECT",
"spawnTotal":
{
"interpolation": "LINEAR_SPLINE",
"timelineType": "CONTINUED",
"timeline":
[
{
"t": 0.000,
"value": 0
},
{
"t": 1.000,
"value": 200
}
]
},
"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":
{
"interpolation": "DISCRETE",
"timeline":
[
{
"value": [ 10, 10 ]
}
]
},
"color":
{
"value": [ 1, 1, 0, 1 ]
}
}
]
}

97
assets/effects/test.json Executable file
View File

@ -0,0 +1,97 @@
{
"name": "Simple Sparkler",
"emitters":
[
{
"name": "Spark",
"maxParticles": 1000,
"preloading": 1000,
"texturePath": "textures/spark-white.png",
"hasInertion": "false",
"gravity": [0, 0, 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
}
]
},
"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":
{
"interpolation": "DISCRETE",
"timeline":
[
{
"value": [ 10, 10 ]
}
]
},
"color":
{
"value": [ 1, 1, 0, 1 ]
}
}
]
}

View File

@ -1,11 +0,0 @@
precision mediump float;
varying vec2 texCoord;
uniform sampler2D Texture;
uniform vec4 Color;
void main()
{
gl_FragColor = texture2D(Texture,texCoord) * Color;
}

View File

@ -0,0 +1,11 @@
precision mediump float;
in vec2 texCoord;
flat in vec4 color;
uniform sampler2D Texture;
void main()
{
gl_FragColor = texture2D(Texture,texCoord) * color;
}

View File

@ -1,7 +1,9 @@
attribute vec3 vPosition;
attribute vec2 vTexCoord;
attribute vec4 vColor;
varying vec2 texCoord;
out vec2 texCoord;
flat out vec4 color;
uniform mat4 ProjectionMatrix;
@ -9,4 +11,5 @@ void main()
{
gl_Position = ProjectionMatrix * vec4(vPosition.xyz, 1.0);
texCoord = vTexCoord;
color = vColor;
}

View File

@ -1,100 +0,0 @@
{
"name": "Sparkler - бенгальский огонь",
"emitters":
[
{
"name": "Spark",
"maxParticles": 300,
"preloading": 100,
"texturePath": "spark.png",
"hasInertion": "false",
"gravity": [0, -2, 0],
"spawnRange_system": "PARTICLE_BIRTH",
"spawnTotal":
{
"interpolation": "LINEAR_SPLINE",
"isLooped": "false",
"timeline":
[
{
"t": 0.000,
"value": 0
},
{
"t": 0.001,
"value": 0
},
{
"t": 9.999,
"value": 300
},
{
"t": 10.000,
"value": 300
}
]
},
"spawnRange":
{
"value": [ 0, 0, 360, 180 ]
},
"lifeTime":
{
"min": 0.100,
"max": 1.000
},
"coords_system": "PARTICLE_BIRTH",
"coords_axis_system": "PARTICLE_EFFECT",
"rotation_system": "PARTICLE_BIRTH",
"coords":
{
"interpolation": "CUBIC_SPLINE",
"isLooped": "false",
"timeline":
[
{
"t": 0.000,
"min": [ -1, -1, -1 ],
"max": [ 1, 1, 1 ]
},
{
"t": 1.000,
"min": [ -2, -2, -2 ],
"max": [ 2, 2, 2 ]
}
]
},
"rotation":
{
"value": [ 0, 0, 0 ]
},
"scale":
{
"interpolation": "DISCRETE",
"isLooped": "false",
"timeline":
[
{
"value": [ 5, 5 ]
}
]
},
"color":
{
"value": [ 1, 1, 0, 1 ]
}
}
]
}

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

BIN
assets/textures/comet.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

View File

@ -19,7 +19,7 @@ void TMyApplication::InnerInit()
#ifdef TARGET_WIN32
#ifdef NDEBUG
ST::PathToResources = "resources/";
ST::PathToResources = "../../../assets/";
#else
ST::PathToResources = "../../../assets/";
#endif
@ -35,20 +35,25 @@ void TMyApplication::InnerInit()
}
srand (static_cast<size_t>(time(NULL)));
ResourceManager->ShaderManager.AddShader("DefaultShader", "texture-shader.vertex", "texture-shader.fragment");
ResourceManager->ShaderManager.AddShader("ColorShader", "color-shader.vertex", "color-shader.fragment");
ResourceManager->ShaderManager.AddShader(ParticleEffect::PARTICLE_SHADER, "particle-shader.vertex", "particle-shader.fragment");
ResourceManager->ShaderManager.AddShader("DefaultShader", "shaders/texture-shader.vertex", "shaders/texture-shader.fragment");
ResourceManager->ShaderManager.AddShader("ColorShader", "shaders/color-shader.vertex", "shaders/color-shader.fragment");
ResourceManager->ShaderManager.AddShader(ParticleEffect::PARTICLE_SHADER, "shaders/particle-shader.vertex", "shaders/particle-shader.fragment");
Renderer->PushShader("ColorShader");
float width = Renderer->GetScreenWidth();
float height = Renderer->GetScreenHeight();
Renderer->SetOrthoProjection();
Renderer->PushProjectionMatrix(width, height, -1, 1);
Renderer->PushProjectionMatrix(width, height, -500, 500);
//Renderer->SetFullScreenViewport();
boost::property_tree::ptree JSONsource;
boost::property_tree::json_parser::read_json(ST::PathToResources + "test.json", JSONsource);
boost::property_tree::json_parser::read_json(ST::PathToResources + "config.json", JSONsource);
std::string effectJSON = JSONsource.get<std::string>("effect");
boost::property_tree::json_parser::read_json(ST::PathToResources + effectJSON, JSONsource);
sparkler.parse(JSONsource); // parse JSON
@ -61,14 +66,20 @@ void TMyApplication::InnerDeinit()
{
}
bool ignoreMove = false;
void TMyApplication::InnerOnMouseDown(TMouseState& mouseState)
{
ignoreMove = false;
if (mouseState.LeftButtonPressed)
{
sparkler.setCoords({ (float)mouseState.X, (float)mouseState.Y, 0 });
sparkler.setCoords({ (float)mouseState.X, Renderer->GetScreenHeight() - (float)mouseState.Y, 0 });
}
else if (mouseState.RightButtonPressed)
{
ignoreMove = true;
if (sparkler.isSpawning())
{
sparkler.stopSpawn();
@ -82,6 +93,11 @@ void TMyApplication::InnerOnMouseDown(TMouseState& mouseState)
void TMyApplication::InnerOnMove(Vector2f p, Vector2f shift)
{
if (ignoreMove)
{
return;
}
sparkler.setCoords({ p[0], p[1], 0 });
}

View File

@ -152,13 +152,14 @@
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;TARGET_WIN32;_WIN32_WINNT=0x0501;WIN32_LEAN_AND_MEAN;EIGEN_DONT_ALIGN_STATICALLY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../game;../../../../tes-engine;../../../../eigen;../../../../boost_1_63_0/;../../../../boost_1_63_0/bin.v2/libs/system/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../boost_1_63_0/bin.v2/libs/date_time/build/msvc-14.0/release/address-model-64/link-static/threading-multi/;../../../../boost_1_63_0/bin.v2/libs/regex/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../boost_1_63_0/bin.v2/libs/thread/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../boost_1_63_0/bin.v2/libs/chrono/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../boost_1_63_0/bin.v2/libs/signals/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../libs/boost-gil-extension;../../../../libs/jpeg-9;../../../../libs/jpeg-9/vc10;../../../../libs/lpng1510</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4503</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>../../../game;../../../../tes-engine;../../../../eigen;../../../../boost_1_63_0/;../../../../boost_1_63_0/bin.v2/libs/system/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../boost_1_63_0/bin.v2/libs/date_time/build/msvc-14.0/release/address-model-64/link-static/threading-multi/;../../../../boost_1_63_0/bin.v2/libs/regex/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../boost_1_63_0/bin.v2/libs/thread/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../boost_1_63_0/bin.v2/libs/chrono/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../boost_1_63_0/bin.v2/libs/signals/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../libs/boost-gil-extension;../../../../libs/jpeg-9;../../../../libs/jpeg-9/vc10;../../../../libs/lpng1510;../x64/Release</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>../../../game;../../../../tes-engine;../../../../eigen;../../../../boost_1_63_0/;../../../../boost_1_63_0/stage/x64/lib;../../../../boost_1_63_0/bin.v2/libs/system/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../boost_1_63_0/bin.v2/libs/date_time/build/msvc-14.0/release/address-model-64/link-static/threading-multi/;../../../../boost_1_63_0/bin.v2/libs/regex/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../boost_1_63_0/bin.v2/libs/thread/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../boost_1_63_0/bin.v2/libs/chrono/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../boost_1_63_0/bin.v2/libs/signals/build/msvc-14.0/release/address-model-64/link-static/threading-multi;../../../../libs/boost-gil-extension;../../../../libs/jpeg-9;../../../../libs/jpeg-9/vc10;../../../../libs/lpng1510;../x64/Release</AdditionalLibraryDirectories>
<AdditionalDependencies>libjpeg.lib;libpng.lib;Engine.lib;opengl32.lib;glu32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>