Revision 2aeb75aa
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/library/effect/Effect.java | ||
|---|---|---|
| 48 | 48 |
private final static float[] mUnity= new float[MAX_UNITY_DIM*NUM_EFFECTS]; |
| 49 | 49 |
private final static int[] mUnityDim = new int[NUM_EFFECTS]; |
| 50 | 50 |
|
| 51 |
int mAssociation; |
|
| 52 |
int mComponent;
|
|
| 51 |
int mAndAssociation;
|
|
| 52 |
int mEquAssociation;
|
|
| 53 | 53 |
|
| 54 | 54 |
static boolean[] mEnabled = new boolean[NUM_EFFECTS]; |
| 55 | 55 |
|
| ... | ... | |
| 68 | 68 |
mCenterDim = name.getCenterDimension(); |
| 69 | 69 |
mRegionDim = name.getRegionDimension(); |
| 70 | 70 |
|
| 71 |
mAssociation = 0xffffffff; |
|
| 72 |
mComponent = 0;
|
|
| 71 |
mAndAssociation = 0xffffffff;
|
|
| 72 |
mEquAssociation = 0;
|
|
| 73 | 73 |
|
| 74 | 74 |
int n = name.ordinal(); |
| 75 | 75 |
float[] u = name.getUnity(); |
| ... | ... | |
| 142 | 142 |
* |
| 143 | 143 |
* @y.exclude |
| 144 | 144 |
*/ |
| 145 |
public int getAssociation() |
|
| 145 |
public int getAndAssociation()
|
|
| 146 | 146 |
{
|
| 147 |
return mAssociation; |
|
| 147 |
return mAndAssociation;
|
|
| 148 | 148 |
} |
| 149 | 149 |
|
| 150 | 150 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 153 | 153 |
* |
| 154 | 154 |
* @y.exclude |
| 155 | 155 |
*/ |
| 156 |
public int getComponent()
|
|
| 156 |
public int getEquAssociation()
|
|
| 157 | 157 |
{
|
| 158 |
return mComponent;
|
|
| 158 |
return mEquAssociation;
|
|
| 159 | 159 |
} |
| 160 | 160 |
|
| 161 | 161 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/library/effect/VertexEffect.java | ||
|---|---|---|
| 192 | 192 |
/** |
| 193 | 193 |
* Set Mesh association. |
| 194 | 194 |
* |
| 195 |
* This creates an association between this Vertex Effect and a Component of a Mesh.
|
|
| 196 |
* One can set the association of an Effect and of a Component, and the Effect will only be active on
|
|
| 197 |
* vertices of Components such that |
|
| 195 |
* This creates an association between a Component of a Mesh and this Vertex Effect.
|
|
| 196 |
* One can set two types of associations - an 'logical and' and a 'equal' associations and the Effect
|
|
| 197 |
* will only be active on vertices of Components such that
|
|
| 198 | 198 |
* |
| 199 |
* (effect assoc) & (component assoc) != 0 || (effect component) == (mesh component)
|
|
| 199 |
* (effect andAssoc) & (component andAssoc) != 0 || (effect equAssoc) == (mesh equAssoc)
|
|
| 200 | 200 |
* |
| 201 | 201 |
* (see main_vertex_shader) |
| 202 | 202 |
* |
| 203 | 203 |
* The point: this way we can configure the system so that each Vertex Effect acts only on a certain |
| 204 | 204 |
* subset of a Mesh, thus potentially significantly reducing the number of render calls. |
| 205 | 205 |
*/ |
| 206 |
public void setMeshAssociation(int component, int association)
|
|
| 206 |
public void setMeshAssociation(int andAssociation, int equAssociation)
|
|
| 207 | 207 |
{
|
| 208 |
mComponent = component;
|
|
| 209 |
mAssociation = association;
|
|
| 208 |
mAndAssociation = andAssociation;
|
|
| 209 |
mEquAssociation = equAssociation;
|
|
| 210 | 210 |
} |
| 211 | 211 |
} |
| src/main/java/org/distorted/library/effectqueue/EffectQueue.java | ||
|---|---|---|
| 51 | 51 |
long[] mCurrentDuration; |
| 52 | 52 |
Effect[] mEffects; |
| 53 | 53 |
int[] mName; |
| 54 |
int[] mAssociation; |
|
| 55 |
int[] mComponent;
|
|
| 54 |
int[] mAndAssociation;
|
|
| 55 |
int[] mEquAssociation;
|
|
| 56 | 56 |
long mTime; |
| 57 | 57 |
|
| 58 | 58 |
private static int[] mMax = new int[EffectType.LENGTH]; |
| ... | ... | |
| 143 | 143 |
mCurrentDuration = new long[max]; |
| 144 | 144 |
mEffects = new Effect[max]; |
| 145 | 145 |
mName = new int[max]; |
| 146 |
mAssociation = new int[max];
|
|
| 147 |
mComponent = new int[max];
|
|
| 146 |
mAndAssociation = new int[max];
|
|
| 147 |
mEquAssociation = new int[max];
|
|
| 148 | 148 |
} |
| 149 | 149 |
|
| 150 | 150 |
for(int i=0; i<mNumEffects; i++ ) |
| ... | ... | |
| 152 | 152 |
mEffects[i] = source.mEffects[i]; |
| 153 | 153 |
mCurrentDuration[i] = source.mCurrentDuration[i]; |
| 154 | 154 |
mName[i] = source.mName[i]; |
| 155 |
mAssociation[i] = source.mAssociation[i];
|
|
| 156 |
mComponent[i] = source.mComponent[i];
|
|
| 155 |
mAndAssociation[i] = source.mAndAssociation[i];
|
|
| 156 |
mEquAssociation[i] = source.mEquAssociation[i];
|
|
| 157 | 157 |
} |
| 158 | 158 |
} |
| 159 | 159 |
} |
| ... | ... | |
| 282 | 282 |
mEffects[j] = mEffects[j+1]; |
| 283 | 283 |
mCurrentDuration[j] = mCurrentDuration[j+1]; |
| 284 | 284 |
mName[j] = mName[j+1]; |
| 285 |
mAssociation[j] = mAssociation[j+1];
|
|
| 286 |
mComponent[j] = mComponent[j+1];
|
|
| 285 |
mAndAssociation[j] = mAndAssociation[j+1];
|
|
| 286 |
mEquAssociation[j] = mEquAssociation[j+1];
|
|
| 287 | 287 |
} |
| 288 | 288 |
|
| 289 | 289 |
mEffects[mNumEffects] = null; |
| ... | ... | |
| 441 | 441 |
mCurrentDuration = new long[max]; |
| 442 | 442 |
mEffects = new Effect[max]; |
| 443 | 443 |
mName = new int[max]; |
| 444 |
mAssociation = new int[max];
|
|
| 445 |
mComponent = new int[max];
|
|
| 444 |
mAndAssociation = new int[max];
|
|
| 445 |
mEquAssociation = new int[max];
|
|
| 446 | 446 |
} |
| 447 | 447 |
mCreated = true; |
| 448 | 448 |
|
| ... | ... | |
| 453 | 453 |
|
| 454 | 454 |
if( position==-1 ) |
| 455 | 455 |
{
|
| 456 |
mCurrentDuration[mNumEffects] = 0;
|
|
| 457 |
mEffects[mNumEffects] = job.effect; |
|
| 458 |
mName[mNumEffects] = job.effect.getName().ordinal(); |
|
| 459 |
mAssociation[mNumEffects]= job.effect.getAssociation();
|
|
| 460 |
mComponent[mNumEffects] = job.effect.getComponent();
|
|
| 456 |
mCurrentDuration[mNumEffects]= 0; |
|
| 457 |
mEffects[mNumEffects] = job.effect;
|
|
| 458 |
mName[mNumEffects] = job.effect.getName().ordinal();
|
|
| 459 |
mAndAssociation[mNumEffects] = job.effect.getAndAssociation();
|
|
| 460 |
mEquAssociation[mNumEffects] = job.effect.getEquAssociation();
|
|
| 461 | 461 |
|
| 462 | 462 |
mNumEffects++; |
| 463 | 463 |
changed = true; |
| ... | ... | |
| 469 | 469 |
mCurrentDuration[j] = mCurrentDuration[j-1]; |
| 470 | 470 |
mEffects[j] = mEffects[j-1]; |
| 471 | 471 |
mName[j] = mName[j-1]; |
| 472 |
mAssociation[j] = mAssociation[j-1];
|
|
| 473 |
mComponent[j] = mComponent[j-1];
|
|
| 472 |
mAndAssociation[j] = mAndAssociation[j-1];
|
|
| 473 |
mEquAssociation[j] = mEquAssociation[j-1];
|
|
| 474 | 474 |
} |
| 475 | 475 |
|
| 476 |
mCurrentDuration[position] = 0;
|
|
| 477 |
mEffects[position] = job.effect; |
|
| 478 |
mName[position] = job.effect.getName().ordinal(); |
|
| 479 |
mAssociation[position]= job.effect.getAssociation();
|
|
| 480 |
mComponent[position] = job.effect.getComponent();
|
|
| 476 |
mCurrentDuration[position]= 0; |
|
| 477 |
mEffects[position] = job.effect;
|
|
| 478 |
mName[position] = job.effect.getName().ordinal();
|
|
| 479 |
mAndAssociation[position] = job.effect.getAndAssociation();
|
|
| 480 |
mEquAssociation[position] = job.effect.getEquAssociation();
|
|
| 481 | 481 |
|
| 482 | 482 |
mNumEffects++; |
| 483 | 483 |
changed = true; |
| src/main/java/org/distorted/library/effectqueue/EffectQueueVertex.java | ||
|---|---|---|
| 36 | 36 |
private static final int NUM_UNIFORMS = VertexEffect.NUM_UNIFORMS; |
| 37 | 37 |
private static final int INDEX = EffectType.VERTEX.ordinal(); |
| 38 | 38 |
|
| 39 |
private static int[] mNumEffectsH = new int[MAIN_VARIANTS]; |
|
| 40 |
private static int[] mNameH = new int[MAIN_VARIANTS]; |
|
| 41 |
private static int[] mUniformsH = new int[MAIN_VARIANTS]; |
|
| 42 |
private static int[] mAssociationH= new int[MAIN_VARIANTS]; |
|
| 43 |
private static int[] mComponentH = new int[MAIN_VARIANTS];
|
|
| 44 |
private static int[] mInflateH = new int[MAIN_VARIANTS]; |
|
| 39 |
private static int[] mNumEffectsH = new int[MAIN_VARIANTS];
|
|
| 40 |
private static int[] mNameH = new int[MAIN_VARIANTS];
|
|
| 41 |
private static int[] mUniformsH = new int[MAIN_VARIANTS];
|
|
| 42 |
private static int[] mAndAssociationH= new int[MAIN_VARIANTS];
|
|
| 43 |
private static int[] mEquAssociationH= new int[MAIN_VARIANTS];
|
|
| 44 |
private static int[] mInflateH = new int[MAIN_VARIANTS];
|
|
| 45 | 45 |
|
| 46 | 46 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 47 | 47 |
|
| ... | ... | |
| 61 | 61 |
|
| 62 | 62 |
static void uniforms(int mProgramH, int variant) |
| 63 | 63 |
{
|
| 64 |
mNumEffectsH[variant] = GLES30.glGetUniformLocation( mProgramH, "vNumEffects"); |
|
| 65 |
mNameH[variant] = GLES30.glGetUniformLocation( mProgramH, "vName"); |
|
| 66 |
mUniformsH[variant] = GLES30.glGetUniformLocation( mProgramH, "vUniforms"); |
|
| 67 |
mAssociationH[variant]= GLES30.glGetUniformLocation( mProgramH, "vEffectAssoc");
|
|
| 68 |
mComponentH[variant] = GLES30.glGetUniformLocation( mProgramH, "vEffectCompo");
|
|
| 69 |
mInflateH[variant] = GLES30.glGetUniformLocation( mProgramH, "u_Inflate"); |
|
| 64 |
mNumEffectsH[variant] = GLES30.glGetUniformLocation( mProgramH, "vNumEffects");
|
|
| 65 |
mNameH[variant] = GLES30.glGetUniformLocation( mProgramH, "vName");
|
|
| 66 |
mUniformsH[variant] = GLES30.glGetUniformLocation( mProgramH, "vUniforms");
|
|
| 67 |
mAndAssociationH[variant]= GLES30.glGetUniformLocation( mProgramH, "vEffAndAssoc");
|
|
| 68 |
mEquAssociationH[variant]= GLES30.glGetUniformLocation( mProgramH, "vEffEquAssoc");
|
|
| 69 |
mInflateH[variant] = GLES30.glGetUniformLocation( mProgramH, "u_Inflate");
|
|
| 70 | 70 |
} |
| 71 | 71 |
|
| 72 | 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 84 | 84 |
for(int i=0; i<mNumEffects; i++) |
| 85 | 85 |
{
|
| 86 | 86 |
mCurrentDuration[i] += step; |
| 87 |
mAssociation[i] = mEffects[i].getAssociation();
|
|
| 88 |
mComponent[i] = mEffects[i].getComponent();
|
|
| 87 |
mAndAssociation[i] = mEffects[i].getAndAssociation();
|
|
| 88 |
mEquAssociation[i] = mEffects[i].getEquAssociation();
|
|
| 89 | 89 |
|
| 90 | 90 |
if( mEffects[i].compute(mUniforms, NUM_UNIFORMS*i, mCurrentDuration[i], step) ) |
| 91 | 91 |
{
|
| ... | ... | |
| 109 | 109 |
|
| 110 | 110 |
if( mNumEffects>0 ) |
| 111 | 111 |
{
|
| 112 |
GLES30.glUniform1iv( mNameH[variant] , mNumEffects, mName , 0);
|
|
| 113 |
GLES30.glUniform1iv( mAssociationH[variant], mNumEffects, mAssociation, 0);
|
|
| 114 |
GLES30.glUniform1iv( mComponentH[variant] , mNumEffects, mComponent , 0);
|
|
| 115 |
GLES30.glUniform4fv( mUniformsH[variant] ,(NUM_UNIFORMS/4)*mNumEffects, mUniforms , 0);
|
|
| 112 |
GLES30.glUniform1iv( mNameH[variant] , mNumEffects, mName , 0);
|
|
| 113 |
GLES30.glUniform1iv( mAndAssociationH[variant], mNumEffects, mAndAssociation, 0);
|
|
| 114 |
GLES30.glUniform1iv( mEquAssociationH[variant], mNumEffects, mEquAssociation, 0);
|
|
| 115 |
GLES30.glUniform4fv( mUniformsH[variant] ,(NUM_UNIFORMS/4)*mNumEffects, mUniforms , 0);
|
|
| 116 | 116 |
} |
| 117 | 117 |
} |
| 118 | 118 |
} |
| src/main/java/org/distorted/library/mesh/MeshBase.java | ||
|---|---|---|
| 80 | 80 |
private float[] mVertAttribs1; // packed: PosX,PosY,PosZ, NorX,NorY,NorZ, InfX,InfY,InfZ |
| 81 | 81 |
private float[] mVertAttribs2; // packed: TexS,TexT, Component |
| 82 | 82 |
private float mInflate; |
| 83 |
private int[] mAssociation; |
|
| 83 |
private int[] mEquAssociation; |
|
| 84 |
private int[] mAndAssociation; |
|
| 84 | 85 |
|
| 85 | 86 |
DeferredJobs.JobNode[] mJobNode; |
| 86 | 87 |
|
| 87 |
private static int[] mComponentAssociationH = new int[EffectQueue.MAIN_VARIANTS]; |
|
| 88 |
private static int[] mEquAssociationH = new int[EffectQueue.MAIN_VARIANTS]; |
|
| 89 |
private static int[] mAndAssociationH = new int[EffectQueue.MAIN_VARIANTS]; |
|
| 88 | 90 |
|
| 89 | 91 |
private static class Component |
| 90 | 92 |
{
|
| ... | ... | |
| 122 | 124 |
mShowNormals= false; |
| 123 | 125 |
mInflate = 0.0f; |
| 124 | 126 |
mComponent = new ArrayList<>(); |
| 125 |
mAssociation= new int[MAX_COMPONENTS]; |
|
| 127 |
mEquAssociation= new int[MAX_COMPONENTS]; |
|
| 128 |
mAndAssociation= new int[MAX_COMPONENTS]; |
|
| 126 | 129 |
|
| 127 | 130 |
mJobNode = new DeferredJobs.JobNode[1]; |
| 128 | 131 |
|
| 129 |
for(int i=0; i<MAX_COMPONENTS; i++) mAssociation[i] = DEFAULT_ASSOCIATION; |
|
| 132 |
for(int i=0; i<MAX_COMPONENTS; i++) |
|
| 133 |
{
|
|
| 134 |
mAndAssociation[i] = DEFAULT_ASSOCIATION; |
|
| 135 |
mEquAssociation[i] = i; |
|
| 136 |
} |
|
| 130 | 137 |
|
| 131 | 138 |
mVBO1= new InternalBuffer(GLES30.GL_ARRAY_BUFFER , GLES30.GL_STATIC_READ); |
| 132 | 139 |
mVBO2= new InternalBuffer(GLES30.GL_ARRAY_BUFFER , GLES30.GL_STATIC_READ); |
| ... | ... | |
| 142 | 149 |
mInflate = original.mInflate; |
| 143 | 150 |
mNumVertices= original.mNumVertices; |
| 144 | 151 |
|
| 145 |
mAssociation= new int[MAX_COMPONENTS]; |
|
| 146 |
System.arraycopy(original.mAssociation, 0, mAssociation, 0, MAX_COMPONENTS); |
|
| 152 |
mAndAssociation= new int[MAX_COMPONENTS]; |
|
| 153 |
System.arraycopy(original.mAndAssociation, 0, mAndAssociation, 0, MAX_COMPONENTS); |
|
| 154 |
mEquAssociation= new int[MAX_COMPONENTS]; |
|
| 155 |
System.arraycopy(original.mEquAssociation, 0, mEquAssociation, 0, MAX_COMPONENTS); |
|
| 147 | 156 |
|
| 148 | 157 |
if( deep ) |
| 149 | 158 |
{
|
| ... | ... | |
| 270 | 279 |
|
| 271 | 280 |
if( origComponents<MAX_COMPONENTS ) |
| 272 | 281 |
{
|
| 273 |
mAssociation[origComponents] = mesh.mAssociation[j]; |
|
| 282 |
mAndAssociation[origComponents] = mesh.mAndAssociation[j]; |
|
| 283 |
mEquAssociation[origComponents] = mesh.mEquAssociation[j]; |
|
| 274 | 284 |
origComponents++; |
| 275 | 285 |
} |
| 276 | 286 |
} |
| ... | ... | |
| 424 | 434 |
|
| 425 | 435 |
public static void getUniforms(int mProgramH, int variant) |
| 426 | 436 |
{
|
| 427 |
mComponentAssociationH[variant] = GLES30.glGetUniformLocation( mProgramH, "vComponAssoc"); |
|
| 437 |
mEquAssociationH[variant] = GLES30.glGetUniformLocation( mProgramH, "vComEquAssoc"); |
|
| 438 |
mAndAssociationH[variant] = GLES30.glGetUniformLocation( mProgramH, "vComAndAssoc"); |
|
| 428 | 439 |
} |
| 429 | 440 |
|
| 430 | 441 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 532 | 543 |
*/ |
| 533 | 544 |
public void send(int variant) |
| 534 | 545 |
{
|
| 535 |
GLES30.glUniform1iv( mComponentAssociationH[variant], MAX_COMPONENTS, mAssociation, 0); |
|
| 546 |
GLES30.glUniform1iv( mEquAssociationH[variant], MAX_COMPONENTS, mEquAssociation, 0); |
|
| 547 |
GLES30.glUniform1iv( mAndAssociationH[variant], MAX_COMPONENTS, mAndAssociation, 0); |
|
| 536 | 548 |
} |
| 537 | 549 |
|
| 538 | 550 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 721 | 733 |
* Set Effect association. |
| 722 | 734 |
* |
| 723 | 735 |
* This creates an association between a Component of this Mesh and a Vertex Effect. |
| 724 |
* One can set the association of an Effect and of a Component, and the Effect will only be active on
|
|
| 725 |
* vertices of Components such that |
|
| 736 |
* One can set two types of associations - an 'logical and' and a 'equal' associations and the Effect
|
|
| 737 |
* will only be active on vertices of Components such that
|
|
| 726 | 738 |
* |
| 727 |
* (effect assoc) & (component assoc) != 0 || (effect component) == (mesh component)
|
|
| 739 |
* (effect andAssoc) & (component andAssoc) != 0 || (effect equAssoc) == (mesh equAssoc)
|
|
| 728 | 740 |
* |
| 729 | 741 |
* (see main_vertex_shader) |
| 730 | 742 |
* |
| 731 | 743 |
* The point: this way we can configure the system so that each Vertex Effect acts only on a certain |
| 732 | 744 |
* subset of a Mesh, thus potentially significantly reducing the number of render calls. |
| 733 | 745 |
*/ |
| 734 |
public void setEffectAssociation(int component, int association) |
|
| 746 |
public void setEffectAssociation(int component, int andAssociation, int equAssociation)
|
|
| 735 | 747 |
{
|
| 736 | 748 |
if( component>=0 && component<MAX_COMPONENTS ) |
| 737 | 749 |
{
|
| 738 |
mAssociation[component] = association; |
|
| 750 |
mAndAssociation[component] = andAssociation; |
|
| 751 |
mEquAssociation[component] = equAssociation; |
|
| 739 | 752 |
} |
| 740 | 753 |
} |
| 741 | 754 |
|
| src/main/res/raw/main_vertex_shader.glsl | ||
|---|---|---|
| 49 | 49 |
uniform vec4 vUniforms[3*NUM_VERTEX];// i-th effect is 3 consecutive vec4's: [3*i], [3*i+1], [3*i+2]. |
| 50 | 50 |
// The first vec4 is the Interpolated values, |
| 51 | 51 |
// second vec4: first float - cache, next 3: Center, the third - the Region. |
| 52 |
uniform int vEffectAssoc[NUM_VERTEX];// Associations of the vertex effects. Those are used to connect an effect to a Mesh component. |
|
| 53 |
uniform int vEffectCompo[NUM_VERTEX];// Components the vertex effects work on. Likewise used to conneect an effect to a Mesh component. |
|
| 54 |
uniform int vComponAssoc[MAX_COMPON];// Associations of the component. |
|
| 52 |
uniform int vEffAndAssoc[NUM_VERTEX];// Associations of the vertex effects. Those are used to connect an effect to a Mesh component. |
|
| 53 |
uniform int vEffEquAssoc[NUM_VERTEX];// Components the vertex effects work on. Likewise used to connect an effect to a Mesh component. |
|
| 54 |
uniform int vComAndAssoc[MAX_COMPON];// 'logical AND' association of the component. |
|
| 55 |
uniform int vComEquAssoc[MAX_COMPON];// 'equal' association of the component. |
|
| 55 | 56 |
|
| 56 | 57 |
////////////////////////////////////////////////////////////////////////////////////////////// |
| 57 | 58 |
// HELPER FUNCTIONS |
| ... | ... | |
| 110 | 111 |
|
| 111 | 112 |
for(int i=0; i<vNumEffects; i++) |
| 112 | 113 |
{
|
| 113 |
if( ((vComponAssoc[component] & vEffectAssoc[i]) != 0) || (component == vEffectCompo[i]) )
|
|
| 114 |
if( ((vComAndAssoc[component] & vEffAndAssoc[i]) != 0) || (vComEquAssoc[component] == vEffEquAssoc[i]) )
|
|
| 114 | 115 |
{
|
| 115 | 116 |
// ENABLED EFFECTS WILL BE INSERTED HERE |
| 116 | 117 |
|
Also available in: Unified diff
Update Myanmar flag.