1
0
Fork 0

Minor changes, use int for type instead of organic bool

This commit is contained in:
Delta Echo 2020-02-01 11:38:39 +01:00
parent be7e278f1c
commit 3bf12ce8e7
2 changed files with 23 additions and 23 deletions

View file

@ -143,7 +143,7 @@
<wetness><use>/environment/surface/wetness</use></wetness>
<rnorm><use>/environment/rain-norm</use></rnorm>
<!-- Wingflex -->
<organic type="bool">0</organic>
<wingflex-type type="int">0</wingflex-type>
<body-width type="float">0.7</body-width>
<wingflex-alpha>0.0</wingflex-alpha>
<wingflex-trailing-alpha>0.0</wingflex-trailing-alpha>
@ -499,9 +499,9 @@
</uniform>
<uniform>
<name>organic</name>
<type>bool</type>
<value><use>organic</use></value>
<name>wingflex_type</name>
<type>int</type>
<value><use>wingflex-type</use></value>
</uniform>
<uniform>

View file

@ -22,7 +22,7 @@ attribute vec3 binormal;
uniform float pitch;
uniform float roll;
uniform float hdg;
uniform bool organic;
uniform int wingflex_type;
uniform float body_width;
uniform float wingflex_alpha;
uniform float wingflex_trailing_alpha;
@ -59,7 +59,24 @@ void main(void)
{
vec4 vertex = gl_Vertex;
if ( organic ) {
if ( wingflex_type == 0 ) {
float x_factor = max((abs(vertex.x) - body_width),0);
float y_factor = max(vertex.y,0.0);
float distance;
if(vertex.y < body_width && vertex.y > -body_width){
//this part does not move
distance = 0;
}else if(vertex.y > body_width){
distance = vertex.y - (body_width/2);
}else if(vertex.y < -body_width){
distance = vertex.y - ((-1*body_width)/2);
}
float deflection = wingflex_z * (distance*distance)/(wing_span*wing_span);
vertex.z += deflection;
vertex.y -= deflection/wing_span;
} else if (wingflex_type == 1 ) {
float arm_reach = 4.8;
float x_factor = max((abs(vertex.x) - body_width),0);
@ -98,23 +115,6 @@ void main(void)
if (vertex.x > 0.0) {sweep_x = - 0.5;}
vertex.x+= sweep_x * (1.0 + 0.5 *x_factor) * wingsweep_factor;
} else {
float x_factor = max((abs(vertex.x) - body_width),0);
float y_factor = max(vertex.y,0.0);
float distance;
if(vertex.y < body_width && vertex.y > -body_width){
//this part does not move
distance = 0;
}else if(vertex.y > body_width){
distance = vertex.y - (body_width/2);
}else if(vertex.y < -body_width){
distance = vertex.y - ((-1*body_width)/2);
}
float deflection = wingflex_z * (distance*distance)/(wing_span*wing_span);
vertex.z += deflection;
vertex.y -= deflection/wing_span;
}