First pass that actually work
Not at all done, but it'll have to do for now
This commit is contained in:
@@ -2,14 +2,15 @@
|
||||
<ExplosionOrigin X="0" Y="0" Z="0"/>
|
||||
<TimeSinceDeath>0</TimeSinceDeath>
|
||||
<ExplosionDuration>2</ExplosionDuration>
|
||||
<Gravity>1</Gravity>
|
||||
<GravityForce>1</GravityForce>
|
||||
<ObjectRadius>2</ObjectRadius>
|
||||
<!--<Gravity>1</Gravity>-->
|
||||
<!--<GravityForce>1</GravityForce>-->
|
||||
<!--<ObjectRadius>2</ObjectRadius>-->
|
||||
<EndColor R="0" G="0" B="0" A="0"/>
|
||||
<Randomness>0</Randomness>
|
||||
<RandomnessScalar>1</RandomnessScalar>
|
||||
<Acceleration X="2" Y="2"/>
|
||||
<ColorPerPolygon>0</ColorPerPolygon>
|
||||
<ReverseAnimation>0</ReverseAnimation>
|
||||
<Wireframe>0</Wireframe>
|
||||
<Velocity X="2" Y="2"/>
|
||||
<ColorByDistance>0</ColorByDistance>
|
||||
<!--<ReverseAnimation>0</ReverseAnimation>-->
|
||||
<!--<Wireframe>0</Wireframe>-->
|
||||
<ExponentialAccelaration>0</ExponentialAccelaration>
|
||||
</c:CoolDeathAnim>
|
||||
@@ -18,15 +18,15 @@
|
||||
<xs:element name="ExplosionDuration" type="t:double" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>How many seconds the death animation should be</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="Gravity" type="t:bool" minOccurs="0">
|
||||
<!--<xs:element name="Gravity" type="t:bool" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>Enable/disable gravity</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="GravityForce" type="t:double" minOccurs="0">
|
||||
</xs:element>-->
|
||||
<!--<xs:element name="GravityForce" type="t:double" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>The force of the gravity</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="ObjectRadius" type="t:double" minOccurs="0">
|
||||
</xs:element>-->
|
||||
<!--<xs:element name="ObjectRadius" type="t:double" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>Object radius (TO BE REMOVED AND AUTOMATED)</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
</xs:element>-->
|
||||
<xs:element name="EndColor" type="t:Color" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>The tint the polys end with</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
@@ -36,17 +36,20 @@
|
||||
<xs:element name="RandomnessScalar" type="t:double" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>Alter the power of the randomness</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="Acceleration" type="t:Vector" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>The accelaration factors (start/end)</xs:documentation></xs:annotation>
|
||||
<xs:element name="Velocity" type="t:Vector" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>The velocity factors (start/end)</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="ColorPerPolygon" type="t:bool" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>Change the color per polygon</xs:documentation></xs:annotation>
|
||||
<xs:element name="ColorByDistance" type="t:bool" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>Change the color by its moved distance instead of by its time</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="ReverseAnimation" type="t:bool" minOccurs="0">
|
||||
<!--<xs:element name="ReverseAnimation" type="t:bool" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>Implosions are cooler</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="Wireframe" type="t:bool" minOccurs="0">
|
||||
</xs:element>-->
|
||||
<!--<xs:element name="Wireframe" type="t:bool" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>Enable/disable wireframe</xs:documentation></xs:annotation>
|
||||
</xs:element>-->
|
||||
<xs:element name="ExponentialAccelaration" type="t:bool" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>Linear/Exponential accelaration</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
|
||||
@@ -76,16 +76,17 @@
|
||||
<ExplosionOrigin X="0" Y="0" Z="0"/>
|
||||
<TimeSinceDeath>0</TimeSinceDeath>
|
||||
<ExplosionDuration>2</ExplosionDuration>
|
||||
<Gravity>1</Gravity>
|
||||
<GravityForce>1</GravityForce>
|
||||
<ObjectRadius>2</ObjectRadius>
|
||||
<!--<Gravity>1</Gravity>-->
|
||||
<!--<GravityForce>1</GravityForce>-->
|
||||
<!--<ObjectRadius>2</ObjectRadius>-->
|
||||
<EndColor R="0" G="0" B="0" A="0"/>
|
||||
<Randomness>0</Randomness>
|
||||
<RandomnessScalar>1</RandomnessScalar>
|
||||
<Acceleration X="2" Y="2"/>
|
||||
<ColorPerPolygon>0</ColorPerPolygon>
|
||||
<ReverseAnimation>0</ReverseAnimation>
|
||||
<Wireframe>0</Wireframe>
|
||||
<Velocity X="2" Y="2"/>
|
||||
<ColorByDistance>0</ColorByDistance>
|
||||
<!--<ReverseAnimation>0</ReverseAnimation>-->
|
||||
<!--<Wireframe>0</Wireframe>-->
|
||||
<ExponentialAccelaration>0</ExponentialAccelaration>
|
||||
</c:CoolDeathAnim>
|
||||
</Components>
|
||||
<Children>
|
||||
|
||||
@@ -6,17 +6,18 @@ uniform mat4 P;
|
||||
uniform vec3 ExplosionOrigin;
|
||||
uniform float TimeSinceDeath;
|
||||
uniform float ExplosionDuration;
|
||||
uniform bool Gravity;
|
||||
uniform float GravityForce;
|
||||
uniform float ObjectRadius;
|
||||
//uniform bool Gravity;
|
||||
//uniform float GravityForce;
|
||||
//uniform float ObjectRadius;
|
||||
uniform vec4 EndColor;
|
||||
uniform bool Randomness;
|
||||
uniform float RandomNumbers[20];
|
||||
uniform float RandomnessScalar;
|
||||
uniform vec2 Velocity; // CHANGED THIS TO VELOCITY REMEMBER YOU FUCKER
|
||||
uniform bool ColorPerPolygon;
|
||||
uniform bool ReverseAnimation;
|
||||
uniform bool Wireframe;
|
||||
uniform vec2 Velocity;
|
||||
uniform bool ColorByDistance;
|
||||
//uniform bool ReverseAnimation;
|
||||
//uniform bool Wireframe;
|
||||
uniform bool ExponentialAccelaration;
|
||||
|
||||
in VertexData{
|
||||
vec3 Position;
|
||||
@@ -65,6 +66,7 @@ float GetRandomNumber(int polygon_index)
|
||||
}
|
||||
|
||||
float randomNumber = 0.0;
|
||||
float randomDistance = 0.0;
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -93,45 +95,51 @@ void main()
|
||||
// center position of triangle
|
||||
vec3 centerOfTriangle = Input[1].Position + (s * dir1);
|
||||
|
||||
// normalized center position of triangle to origin vector
|
||||
vec3 origin2TriangleCenterVector = normalize(centerOfTriangle - ExplosionOrigin);
|
||||
// center position of triangle to origin vector
|
||||
vec3 origin2TriangleCenterVector = centerOfTriangle - ExplosionOrigin;
|
||||
vec3 normalizedOrigin2TriangleCenterVector = normalize(origin2TriangleCenterVector);
|
||||
|
||||
// time percentage until end of explosion (0.0-1.0)
|
||||
float timePercetage = TimeSinceDeath / ExplosionDuration;
|
||||
|
||||
// accelaration to use on current frame. is a interpolation between start and end value
|
||||
float currentAccelaration = mix(Velocity.x, Velocity.y, timePercetage);
|
||||
float currentVelocity = mix(Velocity.x, Velocity.y, timePercetage);
|
||||
|
||||
if (ExponentialAccelaration == true)
|
||||
{
|
||||
currentVelocity = pow(currentVelocity, 2) / 2.0;
|
||||
}
|
||||
|
||||
// distance between origin and the center of the current triangle
|
||||
float origin2TriangleCenterDistance = distance(ExplosionOrigin, centerOfTriangle);
|
||||
float origin2TriangleCenterDistance = length(origin2TriangleCenterVector);
|
||||
|
||||
// get a random number if randomness is enabled, otherwise the random number will be zero and won't affect the other algorithms
|
||||
if (Randomness == true)
|
||||
{
|
||||
randomNumber = GetRandomNumber(gl_PrimitiveIDIn);
|
||||
randomDistance = GetRandomNumber(gl_PrimitiveIDIn) * RandomnessScalar;
|
||||
}
|
||||
|
||||
// the distance from origin to the triangle center with eventual randomness added
|
||||
float fullDistanceWithRandomness = origin2TriangleCenterDistance + (randomNumber * RandomnessScalar);
|
||||
|
||||
// vector from the triangle center to the explosion's shockwave
|
||||
vec3 triangleCenter2ExplosionRadius = (origin2TriangleCenterVector * (TimeSinceDeath * currentAccelaration)) - (origin2TriangleCenterVector * fullDistanceWithRandomness);
|
||||
float fullDistanceWithRandomness = origin2TriangleCenterDistance + randomDistance;
|
||||
|
||||
// vector from the triangle center to the explosion's shockwave
|
||||
vec3 triangleCenter2ExplosionRadius = (normalizedOrigin2TriangleCenterVector * (TimeSinceDeath * currentVelocity)) - (normalizedOrigin2TriangleCenterVector * fullDistanceWithRandomness);
|
||||
|
||||
// if the triangle is inside the blast radius...
|
||||
if (fullDistanceWithRandomness <= (TimeSinceDeath * currentAccelaration))
|
||||
if (fullDistanceWithRandomness <= (TimeSinceDeath * currentVelocity))
|
||||
{
|
||||
float maxRadius = max(TimeSinceDeath * currentVelocity, (ExplosionDuration * currentVelocity));
|
||||
|
||||
float a = (Velocity.y - Velocity.x) / ExplosionDuration;
|
||||
//float t = sqrt((2 * origin2TriangleCenterDistance) / a);
|
||||
|
||||
// if explosion color should be affected by distance instead of time...
|
||||
if (ColorPerPolygon == true)
|
||||
if (ColorByDistance == true)
|
||||
{
|
||||
// the position of the center of the triangle after it has exploded
|
||||
vec3 movedCenterOfTriangle = vec3(centerOfTriangle + triangleCenter2ExplosionRadius);
|
||||
|
||||
// calculate the max distance (s) the triangle will move
|
||||
float a = (Velocity.y - Velocity.x) / ExplosionDuration;
|
||||
float s = (Velocity.x * ExplosionDuration) + (0.5 * a * pow(ExplosionDuration, 2));
|
||||
|
||||
ExplosionColor = EndColor * (length(triangleCenter2ExplosionRadius) / s);
|
||||
//ExplosionColor = EndColor * (distance(ExplosionOrigin, movedCenterOfTriangle) - distance(ExplosionOrigin, centerOfTriangle))
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -154,20 +162,22 @@ void main()
|
||||
vec4 ExplodedPositionInModelSpace = M * vec4(ExplodedPosition, 1.0);
|
||||
|
||||
// if there is gravity, apply it
|
||||
if (Gravity == true)
|
||||
{
|
||||
ExplodedPositionInModelSpace.y = ExplodedPositionInModelSpace.y - pow((TimeSinceDeath - fullDistanceWithRandomness) * GravityForce, 2);
|
||||
}
|
||||
//if (Gravity == true)
|
||||
//{
|
||||
// // ---DO THIS----> //ExplodedPositionInModelSpace.y = ExplodedPositionInModelSpace.y - TimeSinceHit;
|
||||
//
|
||||
// ExplodedPositionInModelSpace.y = ExplodedPositionInModelSpace.y - pow(TimeSinceDeath, 2);
|
||||
//}
|
||||
|
||||
// convert to screen space
|
||||
gl_Position = P*V * vec4(ExplodedPosition, 1.0);
|
||||
// convert to screen space
|
||||
gl_Position = P*V * ExplodedPositionInModelSpace;
|
||||
EmitVertex();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// if explosion color should be affected by distance instead of time...
|
||||
if (ColorPerPolygon == true)
|
||||
if (ColorByDistance == true)
|
||||
{
|
||||
ExplosionColor = vec4(0.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user