Lots of things done

This commit is contained in:
Ayumiwii
2016-01-08 16:42:59 +01:00
parent c133223bac
commit 3467315aef
15 changed files with 312 additions and 22 deletions
+1
View File
@@ -8,4 +8,5 @@
<xs:include schemaLocation="Components/Player.xsd"/>
<xs:include schemaLocation="Components/AABB.xsd"/>
<xs:include schemaLocation="Components/Trigger.xsd"/>
<xs:include schemaLocation="Components/CoolDeathAnim.xsd"/>
</xs:schema>
@@ -0,0 +1,5 @@
<c:CoolDeathAnim>
<OriginPos X="0" Y="0" Z="0"/>
<TimeSinceDeath>0</TimeSinceDeath>
<EndOfDeath>15</EndOfDeath>
</c:CoolDeathAnim>
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="CoolDeathAnim">
<xs:annotation>
<xs:documentation>A component that trigger the death effect</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:all>
<xs:element name="OriginPos" type="t:Vector" minOccurs="0">
<xs:annotation><xs:documentation>The position in which to spawn the component</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="TimeSinceDeath" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>Time since death</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="EndOfDeath" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>How long the death animation should be</xs:documentation></xs:annotation>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
+6 -1
View File
@@ -66,12 +66,17 @@
<Components>
<c:Transform>
<Position X="0" Y="0"/>
<Orientation X="0.0" Y="0" Z="1.0"/>
<Orientation X="0.0" Y="0.0" Z="0"/>
</c:Transform>
<c:Model>
<Resource>Models/Core/UnitRaptor.obj</Resource>
<Color R="1" G="0.4" B="0.8"/>
</c:Model>
<c:CoolDeathAnim>
<OriginPos X="0" Y="0" Z="0"/>
<TimeSinceDeath>0</TimeSinceDeath>
<EndOfDeath>15</EndOfDeath>
</c:CoolDeathAnim>
</Components>
<Children>
<Entity>
+1
View File
@@ -15,6 +15,7 @@
<xs:element ref="c:Test" minOccurs="0"/>
<xs:element ref="c:RaptorCopter" minOccurs="0"/>
<xs:element ref="c:Player" minOccurs="0"/>
<xs:element ref="c:CoolDeathAnim" minOccurs="0"/>
</xs:all>
</xs:complexType>
</xs:element>
+22
View File
@@ -0,0 +1,22 @@
#version 430
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
uniform vec4 Color;
uniform sampler2D texture0;
in vec3 Normal;
in vec3 Position;
in vec2 TextureCoordinate;
in vec4 DiffuseColor;
out vec4 fragmentColor;
void main()
{
vec4 texel = texture2D(texture0, TextureCoordinate);
fragmentColor = texel * DiffuseColor * Color;
}
+98
View File
@@ -0,0 +1,98 @@
#version 430
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
uniform vec3 OriginPos;
uniform float TimeSinceDeath;
uniform float EndOfDeath;
in VertexData{
vec3 Position;
vec3 Normal;
vec2 TextureCoordinate;
vec4 DiffuseColor;
}Input[];
out vec3 Normal;
out vec3 Position;
out vec2 TextureCoordinate;
out vec4 DiffuseColor;
layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;
void main()
{
// surface vectors for triangle
//vec3 v1 = Input[1].Position - Input[0].Position;
//vec3 v2 = Input[2].Position - Input[0].Position;
//vec3 v3 = Input[1].Position - OriginPos;
//v3 = normalize(v3);
// surface normal
//vec3 normal = cross(v1, v2);
//normal = normalize(normal);
// calculate middle of a vectors
vec3 v1 = Input[1].Position - Input[0].Position;
vec3 v2 = Input[2].Position - Input[0].Position;
vec3 v3 = Input[2].Position - (v1 / 2);
vec3 v4 = Input[1].Position - (v2 / 2);
//
//vec3 oriToTri = Input[1].Position - OriginPos;
//v5 = normalize(v3);
// calculate intersection
// normalize direction
vec3 dir1 = normalize(v1);
vec3 dir2 = normalize(v2);
vec3 vecA = Input[2].Position - Input[1].Position; //o2 - o1
vec3 vecB = cross(dir1, dir2);
mat3 matrisA = mat3(vecA, dir2, vecB);
mat3 matrisB = mat3(vecA, dir1, vecB);
float lengthA = length(cross(dir1, dir2));
lengthA = lengthA * lengthA;
float s = determinant(matrisA) / lengthA;
float t = determinant(matrisB) / lengthA;
// center position of triangle
vec3 centerPosS = Input[1].Position + (s * dir1);
//vec3 centerPosT = Input[2].Position + (t * dir2);
// center position of triangle to origin
vec3 oriToCenterTri = normalize(centerPosS - OriginPos);
for(int i = 0; i < gl_in.length(); i++)
{
vec4 screenPos = gl_in[i].gl_Position;
if (distance(OriginPos, Input[0].Position) <= TimeSinceDeath)
{
vec4 changedPos = M * vec4(Input[i].Position + (oriToCenterTri * TimeSinceDeath), 1.0); //objectspace
changedPos = vec4(changedPos.x, changedPos.y - pow(TimeSinceDeath, 2), changedPos.z, changedPos.w); //objectspace
screenPos = P*V * changedPos; //sceenspace
}
// Explosion from origin
Normal = Input[i].Normal;
Position = Input[i].Position;
TextureCoordinate = Input[i].TextureCoordinate;
DiffuseColor = vec4(Input[i].DiffuseColor.rg, Input[i].DiffuseColor.b + TimeSinceDeath, Input[i].DiffuseColor.a);
gl_Position = screenPos;
//gl_Position = gl_in[i].gl_Position;
EmitVertex();
}
}
+34
View File
@@ -0,0 +1,34 @@
#version 430
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec3 Tangent;
layout(location = 3) in vec3 BiTangent;
layout(location = 4) in vec2 TextureCoords;
layout(location = 5) in vec4 DiffuseVertexColor;
layout(location = 6) in vec4 SpecularVertexColor;
layout(location = 7) in vec4 BoneIndices1;
layout(location = 8) in vec4 BoneIndices2;
layout(location = 9) in vec4 BoneWeights1;
layout(location = 10) in vec4 BoneWeights2;
out VertexData{
vec3 Position;
vec3 Normal;
vec2 TextureCoordinate;
vec4 DiffuseColor;
}Output;
void main()
{
gl_Position = P*V*M * vec4(Position, 1.0);
Output.Position = Position;
Output.TextureCoordinate = TextureCoords;
Output.Normal = Normal;
Output.DiffuseColor = DiffuseVertexColor;
}