Revision 0f10a0b6
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/library/effect/VertexEffectDeform.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.library.effect; |
21 | 21 |
|
22 |
import org.distorted.library.type.Data1D; |
|
22 | 23 |
import org.distorted.library.type.Data3D; |
23 | 24 |
import org.distorted.library.type.Data4D; |
24 | 25 |
|
... | ... | |
29 | 30 |
public class VertexEffectDeform extends VertexEffect |
30 | 31 |
{ |
31 | 32 |
private Data3D mVector, mCenter; |
33 |
private Data1D mRadius; |
|
32 | 34 |
private Data4D mRegion; |
33 | 35 |
|
34 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
41 | 43 |
{ |
42 | 44 |
mCenter.get(uniforms,index+CENTER_OFFSET,currentDuration,step); |
43 | 45 |
mRegion.get(uniforms,index+REGION_OFFSET,currentDuration,step); |
46 |
mRadius.get(uniforms,index+3,currentDuration,step); |
|
44 | 47 |
return mVector.get(uniforms,index,currentDuration,step); |
45 | 48 |
} |
46 | 49 |
|
... | ... | |
98 | 101 |
// along the force line is. |
99 | 102 |
// 0<=C<1 looks completely ridiculous and C<0 destroys the system. |
100 | 103 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
104 |
// 2020-05-03: replaced vec3 'u_Bounding' with a uniform 'vUniforms[effect].w' (i.e. mRadius) |
|
105 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
101 | 106 |
/** |
102 | 107 |
* Have to call this before the shaders get compiled (i.e before DistortedLibrary.onCreate()) for the Effect to work. |
103 | 108 |
*/ |
... | ... | |
113 | 118 |
+ "vec3 center = vUniforms[effect+1].yzw; \n" |
114 | 119 |
+ "vec3 ps = center-v; \n" |
115 | 120 |
+ "vec3 aPS = abs(ps); \n" |
116 |
+ "vec3 maxps = u_Bounding + abs(center); \n"
|
|
117 |
+ "float d = degree_region(vUniforms[effect+2],ps); \n"
|
|
121 |
+ "vec3 maxps = vUniforms[effect].w + abs(center); \n"
|
|
122 |
+ "float d = degree(vUniforms[effect+2],ps); \n"
|
|
118 | 123 |
+ "vec3 force = vUniforms[effect].xyz * d; \n" |
119 | 124 |
+ "vec3 aForce = abs(force); \n" |
120 | 125 |
+ "float denom = dot(ps+(1.0-d)*force,ps); \n" |
... | ... | |
149 | 154 |
* a (possibly changing in time) point on the Mesh. |
150 | 155 |
* |
151 | 156 |
* @param vector Vector of force that deforms the Mesh. |
157 |
* @param radius How 'bendy' the object is. Don';t set this to 0. Typically set this to the object's |
|
158 |
* mesh size (i.e. more or less X of the rightmost vertex - X of the leftmost vertex) |
|
152 | 159 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. |
153 | 160 |
* @param region Region that masks the Effect. |
154 | 161 |
*/ |
155 |
public VertexEffectDeform(Data3D vector, Data3D center, Data4D region) |
|
162 |
public VertexEffectDeform(Data3D vector, Data1D radius, Data3D center, Data4D region)
|
|
156 | 163 |
{ |
157 | 164 |
super(EffectName.DEFORM); |
158 | 165 |
mVector = vector; |
166 |
mRadius = radius; |
|
159 | 167 |
mCenter = center; |
160 | 168 |
mRegion = (region==null ? MAX_REGION : region); |
161 | 169 |
} |
... | ... | |
166 | 174 |
* a (possibly changing in time) point on the Mesh. |
167 | 175 |
* |
168 | 176 |
* @param vector Vector of force that deforms the Mesh. |
177 |
* @param radius How 'bendy' the object is. Don't set this to 0. Typically set this to the object's |
|
178 |
* mesh size (i.e. more or less X of the rightmost vertex - X of the leftmost vertex) |
|
169 | 179 |
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect. |
170 | 180 |
*/ |
171 |
public VertexEffectDeform(Data3D vector, Data3D center) |
|
181 |
public VertexEffectDeform(Data3D vector, Data1D radius, Data3D center)
|
|
172 | 182 |
{ |
173 | 183 |
super(EffectName.DEFORM); |
174 | 184 |
mVector = vector; |
185 |
mRadius = radius; |
|
175 | 186 |
mCenter = center; |
176 | 187 |
mRegion = MAX_REGION; |
177 | 188 |
} |
Also available in: Unified diff
A lot of changes.
1) main vertex shader: remove support for degree_object. This functionality will hopefully come back when we introduce other than circular regions.
2) MeshBase: remove the need to set a Bounding box (this is the point of the whole thing - we wanted to get rid of this so that the advances in MeshJoined will be easier)
3) Set ground for removing the MeshBase.setStretch / getStretch (another thing needed to advance MeshJoined )
4) since we removed the Bounding box, we need to change the DEFORN effect to have 1 additional parameter, the 'radius' which takes over the function of the bounding box in the vertex shader.
5) since the'res no bounding box, simplify the postprocessing Halo (remove EffectQueueMatrix.magnify() )
6) adjust applications.
After this we will hopefully be ready to introduce MeshBase.preApply(VertexEffect), i.e. bending several simple Meshes with any VertexEffect - including the freshly-introduced PseudoMatrix-Vertex effects like VertexEffectScale - and then combining them into one MeshJoined.