Revision 1e672c1d
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 mTag;
|
|
| 51 |
int mAssociation;
|
|
| 52 | 52 |
|
| 53 | 53 |
static boolean[] mEnabled = new boolean[NUM_EFFECTS]; |
| 54 | 54 |
|
| ... | ... | |
| 67 | 67 |
mCenterDim = name.getCenterDimension(); |
| 68 | 68 |
mRegionDim = name.getRegionDimension(); |
| 69 | 69 |
|
| 70 |
mTag = 0xffffffff;
|
|
| 70 |
mAssociation = 0xffffffff;
|
|
| 71 | 71 |
|
| 72 | 72 |
int n = name.ordinal(); |
| 73 | 73 |
float[] u = name.getUnity(); |
| ... | ... | |
| 140 | 140 |
* |
| 141 | 141 |
* @y.exclude |
| 142 | 142 |
*/ |
| 143 |
public int getTag()
|
|
| 143 |
public int getAssociation()
|
|
| 144 | 144 |
{
|
| 145 |
return mTag;
|
|
| 145 |
return mAssociation;
|
|
| 146 | 146 |
} |
| 147 | 147 |
|
| 148 | 148 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/library/effect/VertexEffect.java | ||
|---|---|---|
| 58 | 58 |
{
|
| 59 | 59 |
return |
| 60 | 60 |
|
| 61 |
"if( vName[i]=="+effect+" && (int(a_Tag) & vTag[i]) != 0 )\n" +
|
|
| 61 |
"if( vName[i]=="+effect+" && (int(a_Association) & vAssociation[i]) != 0 )\n" +
|
|
| 62 | 62 |
"{\n" +
|
| 63 | 63 |
code +"\n" + |
| 64 | 64 |
"}\n" + |
| ... | ... | |
| 190 | 190 |
|
| 191 | 191 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 192 | 192 |
/** |
| 193 |
* Set a tag.
|
|
| 193 |
* Set Mesh association.
|
|
| 194 | 194 |
* |
| 195 |
* A 'tag' of a Vertex Effect joins the effect with a component of a Mesh the effect gets applied to.
|
|
| 196 |
* One can set a Tag of the effect and of a Component, and the Effect will only be active on vertices
|
|
| 197 |
* of Components such that (effect tag) & (component tag) != 0. (see retSection() above)
|
|
| 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 (effect assoc) & (component assoc) != 0. (see retSection() above)
|
|
| 198 | 198 |
* |
| 199 | 199 |
* The point: this way we can configure the system so that each Vertex Effect acts only on a certain |
| 200 |
* subset of the Mesh, thus potentially significantly reducing the number of render calls.
|
|
| 200 |
* subset of a Mesh, thus potentially significantly reducing the number of render calls.
|
|
| 201 | 201 |
*/ |
| 202 |
public void setTag(int tag)
|
|
| 202 |
public void setMeshAssociation(int association)
|
|
| 203 | 203 |
{
|
| 204 |
mTag = tag;
|
|
| 204 |
mAssociation = association;
|
|
| 205 | 205 |
} |
| 206 | 206 |
} |
| src/main/java/org/distorted/library/effectqueue/EffectQueue.java | ||
|---|---|---|
| 51 | 51 |
long[] mCurrentDuration; |
| 52 | 52 |
Effect[] mEffects; |
| 53 | 53 |
int[] mName; |
| 54 |
int[] mTag;
|
|
| 54 |
int[] mAssociation;
|
|
| 55 | 55 |
long mTime; |
| 56 | 56 |
|
| 57 | 57 |
private static int[] mMax = new int[EffectType.LENGTH]; |
| ... | ... | |
| 142 | 142 |
mCurrentDuration = new long[max]; |
| 143 | 143 |
mEffects = new Effect[max]; |
| 144 | 144 |
mName = new int[max]; |
| 145 |
mTag = new int[max];
|
|
| 145 |
mAssociation = new int[max];
|
|
| 146 | 146 |
} |
| 147 | 147 |
|
| 148 | 148 |
for(int i=0; i<mNumEffects; i++ ) |
| ... | ... | |
| 150 | 150 |
mEffects[i] = source.mEffects[i]; |
| 151 | 151 |
mCurrentDuration[i] = source.mCurrentDuration[i]; |
| 152 | 152 |
mName[i] = source.mName[i]; |
| 153 |
mTag[i] = source.mTag[i];
|
|
| 153 |
mAssociation[i] = source.mAssociation[i];
|
|
| 154 | 154 |
} |
| 155 | 155 |
} |
| 156 | 156 |
} |
| ... | ... | |
| 279 | 279 |
mEffects[j] = mEffects[j+1]; |
| 280 | 280 |
mCurrentDuration[j] = mCurrentDuration[j+1]; |
| 281 | 281 |
mName[j] = mName[j+1]; |
| 282 |
mTag[j] = mTag[j+1];
|
|
| 282 |
mAssociation[j] = mAssociation[j+1];
|
|
| 283 | 283 |
} |
| 284 | 284 |
|
| 285 | 285 |
mEffects[mNumEffects] = null; |
| ... | ... | |
| 430 | 430 |
mCurrentDuration = new long[max]; |
| 431 | 431 |
mEffects = new Effect[max]; |
| 432 | 432 |
mName = new int[max]; |
| 433 |
mTag = new int[max];
|
|
| 433 |
mAssociation = new int[max];
|
|
| 434 | 434 |
} |
| 435 | 435 |
mCreated = true; |
| 436 | 436 |
|
| ... | ... | |
| 442 | 442 |
if( position==-1 ) |
| 443 | 443 |
{
|
| 444 | 444 |
mCurrentDuration[mNumEffects] = 0; |
| 445 |
mEffects[mNumEffects] = job.effect; |
|
| 446 |
mName[mNumEffects] = job.effect.getName().ordinal(); |
|
| 447 |
mTag[mNumEffects] = job.effect.getTag();
|
|
| 445 |
mEffects[mNumEffects] = job.effect;
|
|
| 446 |
mName[mNumEffects] = job.effect.getName().ordinal();
|
|
| 447 |
mAssociation[mNumEffects]= job.effect.getAssociation();
|
|
| 448 | 448 |
|
| 449 | 449 |
mNumEffects++; |
| 450 | 450 |
changed = true; |
| ... | ... | |
| 456 | 456 |
mCurrentDuration[j] = mCurrentDuration[j-1]; |
| 457 | 457 |
mEffects[j] = mEffects[j-1]; |
| 458 | 458 |
mName[j] = mName[j-1]; |
| 459 |
mTag[j] = mTag[j-1];
|
|
| 459 |
mAssociation[j] = mAssociation[j-1];
|
|
| 460 | 460 |
} |
| 461 | 461 |
|
| 462 | 462 |
mCurrentDuration[position] = 0; |
| 463 |
mEffects[position] = job.effect; |
|
| 464 |
mName[position] = job.effect.getName().ordinal(); |
|
| 465 |
mTag[position] = job.effect.getTag();
|
|
| 463 |
mEffects[position] = job.effect;
|
|
| 464 |
mName[position] = job.effect.getName().ordinal();
|
|
| 465 |
mAssociation[position]= job.effect.getAssociation();
|
|
| 466 | 466 |
|
| 467 | 467 |
mNumEffects++; |
| 468 | 468 |
changed = true; |
| src/main/java/org/distorted/library/effectqueue/EffectQueueVertex.java | ||
|---|---|---|
| 39 | 39 |
private static int[] mNumEffectsH = new int[MAIN_VARIANTS]; |
| 40 | 40 |
private static int[] mNameH = new int[MAIN_VARIANTS]; |
| 41 | 41 |
private static int[] mUniformsH = new int[MAIN_VARIANTS]; |
| 42 |
private static int[] mTagH = new int[MAIN_VARIANTS];
|
|
| 42 |
private static int[] mAssociationH= new int[MAIN_VARIANTS];
|
|
| 43 | 43 |
private static int[] mInflateH = new int[MAIN_VARIANTS]; |
| 44 | 44 |
|
| 45 | 45 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 60 | 60 |
|
| 61 | 61 |
static void uniforms(int mProgramH, int variant) |
| 62 | 62 |
{
|
| 63 |
mNumEffectsH[variant]= GLES30.glGetUniformLocation( mProgramH, "vNumEffects"); |
|
| 64 |
mNameH[variant] = GLES30.glGetUniformLocation( mProgramH, "vName"); |
|
| 65 |
mUniformsH[variant] = GLES30.glGetUniformLocation( mProgramH, "vUniforms"); |
|
| 66 |
mTagH[variant] = GLES30.glGetUniformLocation( mProgramH, "vTag");
|
|
| 67 |
mInflateH[variant] = GLES30.glGetUniformLocation( mProgramH, "u_Inflate"); |
|
| 63 |
mNumEffectsH[variant] = GLES30.glGetUniformLocation( mProgramH, "vNumEffects");
|
|
| 64 |
mNameH[variant] = GLES30.glGetUniformLocation( mProgramH, "vName");
|
|
| 65 |
mUniformsH[variant] = GLES30.glGetUniformLocation( mProgramH, "vUniforms");
|
|
| 66 |
mAssociationH[variant]= GLES30.glGetUniformLocation( mProgramH, "vAssociation");
|
|
| 67 |
mInflateH[variant] = GLES30.glGetUniformLocation( mProgramH, "u_Inflate");
|
|
| 68 | 68 |
} |
| 69 | 69 |
|
| 70 | 70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 82 | 82 |
for(int i=0; i<mNumEffects; i++) |
| 83 | 83 |
{
|
| 84 | 84 |
mCurrentDuration[i] += step; |
| 85 |
mTag[i] = mEffects[i].getTag();
|
|
| 85 |
mAssociation[i] = mEffects[i].getAssociation();
|
|
| 86 | 86 |
|
| 87 | 87 |
if( mEffects[i].compute(mUniforms, NUM_UNIFORMS*i, mCurrentDuration[i], step) ) |
| 88 | 88 |
{
|
| ... | ... | |
| 106 | 106 |
|
| 107 | 107 |
if( mNumEffects>0 ) |
| 108 | 108 |
{
|
| 109 |
GLES30.glUniform1iv( mNameH[variant] , mNumEffects, mName ,0);
|
|
| 110 |
GLES30.glUniform1iv( mTagH[variant] , mNumEffects, mTag ,0);
|
|
| 111 |
GLES30.glUniform4fv( mUniformsH[variant],(NUM_UNIFORMS/4)*mNumEffects, mUniforms,0);
|
|
| 109 |
GLES30.glUniform1iv( mNameH[variant] , mNumEffects, mName , 0);
|
|
| 110 |
GLES30.glUniform1iv( mAssociationH[variant], mNumEffects, mAssociation, 0);
|
|
| 111 |
GLES30.glUniform4fv( mUniformsH[variant] ,(NUM_UNIFORMS/4)*mNumEffects, mUniforms , 0);
|
|
| 112 | 112 |
} |
| 113 | 113 |
} |
| 114 | 114 |
} |
| src/main/java/org/distorted/library/mesh/MeshBase.java | ||
|---|---|---|
| 43 | 43 |
*/ |
| 44 | 44 |
public abstract class MeshBase |
| 45 | 45 |
{
|
| 46 |
static final float DEFAULT_TAG = 0xffffffff;
|
|
| 46 |
static final float DEFAULT_ASSOCIATION = 0xffffffff;
|
|
| 47 | 47 |
|
| 48 | 48 |
// sizes of attributes of an individual vertex. |
| 49 | 49 |
private static final int POS_DATA_SIZE= 3; // vertex coordinates: x,y,z |
| 50 | 50 |
private static final int NOR_DATA_SIZE= 3; // normal vector: x,y,z |
| 51 | 51 |
private static final int INF_DATA_SIZE= 3; // 'inflate' vector: x,y,z |
| 52 | 52 |
private static final int TEX_DATA_SIZE= 2; // texture coordinates: s,t |
| 53 |
private static final int TAG_DATA_SIZE= 1; // tag, a single float
|
|
| 53 |
private static final int ASS_DATA_SIZE= 1; // association, a single float
|
|
| 54 | 54 |
|
| 55 | 55 |
static final int POS_ATTRIB = 0; |
| 56 | 56 |
static final int NOR_ATTRIB = POS_DATA_SIZE; |
| 57 | 57 |
static final int INF_ATTRIB = POS_DATA_SIZE + NOR_DATA_SIZE; |
| 58 | 58 |
static final int TEX_ATTRIB = 0; |
| 59 |
static final int TAG_ATTRIB = TEX_DATA_SIZE;
|
|
| 59 |
static final int ASS_ATTRIB = TEX_DATA_SIZE;
|
|
| 60 | 60 |
|
| 61 | 61 |
static final int VERT1_ATTRIBS= POS_DATA_SIZE + NOR_DATA_SIZE + INF_DATA_SIZE; // number of attributes of a vertex (the part changed by preapply) |
| 62 |
static final int VERT2_ATTRIBS= TEX_DATA_SIZE + TAG_DATA_SIZE; // number of attributes of a vertex (the 'preapply invariant' part)
|
|
| 62 |
static final int VERT2_ATTRIBS= TEX_DATA_SIZE + ASS_DATA_SIZE; // number of attributes of a vertex (the 'preapply invariant' part)
|
|
| 63 | 63 |
static final int TRAN_ATTRIBS = POS_DATA_SIZE + NOR_DATA_SIZE + INF_DATA_SIZE; // number of attributes of a transform feedback vertex |
| 64 | 64 |
|
| 65 | 65 |
private static final int BYTES_PER_FLOAT = 4; |
| ... | ... | |
| 68 | 68 |
private static final int OFFSET_NOR = NOR_ATTRIB*BYTES_PER_FLOAT; |
| 69 | 69 |
private static final int OFFSET_INF = INF_ATTRIB*BYTES_PER_FLOAT; |
| 70 | 70 |
private static final int OFFSET_TEX = TEX_ATTRIB*BYTES_PER_FLOAT; |
| 71 |
private static final int OFFSET_TAG = TAG_ATTRIB*BYTES_PER_FLOAT;
|
|
| 71 |
private static final int OFFSET_TAG = ASS_ATTRIB*BYTES_PER_FLOAT;
|
|
| 72 | 72 |
|
| 73 | 73 |
private static final int TRAN_SIZE = TRAN_ATTRIBS*BYTES_PER_FLOAT; |
| 74 | 74 |
private static final int VERT1_SIZE = VERT1_ATTRIBS*BYTES_PER_FLOAT; |
| ... | ... | |
| 400 | 400 |
GLES30.glVertexAttribPointer(program.mAttribute[2], INF_DATA_SIZE, GLES30.GL_FLOAT, false, VERT1_SIZE, OFFSET_INF); |
| 401 | 401 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, index2 ); |
| 402 | 402 |
GLES30.glVertexAttribPointer(program.mAttribute[3], TEX_DATA_SIZE, GLES30.GL_FLOAT, false, VERT2_SIZE, OFFSET_TEX); |
| 403 |
GLES30.glVertexAttribPointer(program.mAttribute[4], TAG_DATA_SIZE, GLES30.GL_FLOAT, false, VERT2_SIZE, OFFSET_TAG);
|
|
| 403 |
GLES30.glVertexAttribPointer(program.mAttribute[4], ASS_DATA_SIZE, GLES30.GL_FLOAT, false, VERT2_SIZE, OFFSET_TAG);
|
|
| 404 | 404 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0); |
| 405 | 405 |
} |
| 406 | 406 |
|
| ... | ... | |
| 583 | 583 |
|
| 584 | 584 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 585 | 585 |
/** |
| 586 |
* Set a component's tag.
|
|
| 586 |
* Set Effect association.
|
|
| 587 | 587 |
* |
| 588 |
* A 'tag' of a component associates all vertices which belong to the component with all Vertex Effects
|
|
| 589 |
* with a matching tag - i.e. one can set a tag of an Effect and of a Component, and the Effect will
|
|
| 590 |
* only be active on vertices of Components such that (effect tag) & (component tag) != 0.
|
|
| 588 |
* This creates an association between a Component of this Mesh and a Vertex Effect.
|
|
| 589 |
* One can set the association of an Effect and of a Component, and the Effect will only be active on
|
|
| 590 |
* vertices of Components such that (effect assoc) & (component assoc) != 0. (see VertexEffect.retSection() )
|
|
| 591 | 591 |
* |
| 592 | 592 |
* The point: this way we can configure the system so that each Vertex Effect acts only on a certain |
| 593 |
* subset of the Mesh, thus potentially significantly reducing the number of render calls.
|
|
| 593 |
* subset of a Mesh, thus potentially significantly reducing the number of render calls.
|
|
| 594 | 594 |
*/ |
| 595 |
public void setTag(int component, int tag)
|
|
| 595 |
public void setEffectAssociation(int component, int association)
|
|
| 596 | 596 |
{
|
| 597 | 597 |
int num = mComponent.size(); |
| 598 | 598 |
|
| ... | ... | |
| 601 | 601 |
int sta = component>0 ? mComponent.get(component-1).mEndIndex+1 : 0; |
| 602 | 602 |
int end = mComponent.get(component).mEndIndex; |
| 603 | 603 |
|
| 604 |
sta = sta*VERT2_ATTRIBS + TAG_ATTRIB;
|
|
| 605 |
end = end*VERT2_ATTRIBS + TAG_ATTRIB;
|
|
| 604 |
sta = sta*VERT2_ATTRIBS + ASS_ATTRIB;
|
|
| 605 |
end = end*VERT2_ATTRIBS + ASS_ATTRIB;
|
|
| 606 | 606 |
|
| 607 | 607 |
for(int i=sta; i<=end; i+=VERT2_ATTRIBS) |
| 608 | 608 |
{
|
| 609 |
mVertAttribs2[i] = tag;
|
|
| 609 |
mVertAttribs2[i] = association;
|
|
| 610 | 610 |
} |
| 611 | 611 |
|
| 612 | 612 |
mVBO2.invalidate(); |
| src/main/java/org/distorted/library/mesh/MeshCubes.java | ||
|---|---|---|
| 643 | 643 |
attribs2[VERT2_ATTRIBS*currVert + TEX_ATTRIB+1] = mTexMappingY[BACK] + (1.0f-y) * mTexMappingH[BACK]; |
| 644 | 644 |
} |
| 645 | 645 |
|
| 646 |
attribs2[VERT2_ATTRIBS*currVert + TAG_ATTRIB] = DEFAULT_TAG;
|
|
| 646 |
attribs2[VERT2_ATTRIBS*currVert + ASS_ATTRIB] = DEFAULT_ASSOCIATION;
|
|
| 647 | 647 |
|
| 648 | 648 |
currVert++; |
| 649 | 649 |
} |
| ... | ... | |
| 677 | 677 |
|
| 678 | 678 |
attribs2[VERT2_ATTRIBS*currVert + TEX_ATTRIB ] = mTexMappingX[TOP] + x * mTexMappingW[TOP]; |
| 679 | 679 |
attribs2[VERT2_ATTRIBS*currVert + TEX_ATTRIB+1] = mTexMappingY[TOP] + (0.5f-z) * mTexMappingH[TOP]; |
| 680 |
attribs2[VERT2_ATTRIBS*currVert + TAG_ATTRIB ] = DEFAULT_TAG;
|
|
| 680 |
attribs2[VERT2_ATTRIBS*currVert + ASS_ATTRIB ] = DEFAULT_ASSOCIATION;
|
|
| 681 | 681 |
|
| 682 | 682 |
break; |
| 683 | 683 |
case SOUTH: row = curr.row+1; |
| ... | ... | |
| 700 | 700 |
|
| 701 | 701 |
attribs2[VERT2_ATTRIBS*currVert + TEX_ATTRIB ] = mTexMappingX[BOTTOM] + x * mTexMappingW[BOTTOM]; |
| 702 | 702 |
attribs2[VERT2_ATTRIBS*currVert + TEX_ATTRIB+1] = mTexMappingY[BOTTOM] + (0.5f-z) * mTexMappingH[BOTTOM]; |
| 703 |
attribs2[VERT2_ATTRIBS*currVert + TAG_ATTRIB ] = DEFAULT_TAG;
|
|
| 703 |
attribs2[VERT2_ATTRIBS*currVert + ASS_ATTRIB ] = DEFAULT_ASSOCIATION;
|
|
| 704 | 704 |
|
| 705 | 705 |
break; |
| 706 | 706 |
case WEST : row = (back ? (curr.row+1):(curr.row)); |
| ... | ... | |
| 723 | 723 |
|
| 724 | 724 |
attribs2[VERT2_ATTRIBS*currVert + TEX_ATTRIB ] = mTexMappingX[LEFT] + (0.5f-z) * mTexMappingW[LEFT]; |
| 725 | 725 |
attribs2[VERT2_ATTRIBS*currVert + TEX_ATTRIB+1] = mTexMappingY[LEFT] + (1.0f-y) * mTexMappingH[LEFT]; |
| 726 |
attribs2[VERT2_ATTRIBS*currVert + TAG_ATTRIB ] = DEFAULT_TAG;
|
|
| 726 |
attribs2[VERT2_ATTRIBS*currVert + ASS_ATTRIB ] = DEFAULT_ASSOCIATION;
|
|
| 727 | 727 |
|
| 728 | 728 |
break; |
| 729 | 729 |
case EAST : row = (back ? (curr.row):(curr.row+1)); |
| ... | ... | |
| 746 | 746 |
|
| 747 | 747 |
attribs2[VERT2_ATTRIBS*currVert + TEX_ATTRIB ] = mTexMappingX[RIGHT] + (0.5f-z) * mTexMappingW[RIGHT]; |
| 748 | 748 |
attribs2[VERT2_ATTRIBS*currVert + TEX_ATTRIB+1] = mTexMappingY[RIGHT] + (1.0f-y) * mTexMappingH[RIGHT]; |
| 749 |
attribs2[VERT2_ATTRIBS*currVert + TAG_ATTRIB ] = DEFAULT_TAG;
|
|
| 749 |
attribs2[VERT2_ATTRIBS*currVert + ASS_ATTRIB ] = DEFAULT_ASSOCIATION;
|
|
| 750 | 750 |
|
| 751 | 751 |
break; |
| 752 | 752 |
} |
| ... | ... | |
| 772 | 772 |
|
| 773 | 773 |
attribs2[VERT2_ATTRIBS*currVert + TEX_ATTRIB ] = attribs2[VERT2_ATTRIBS*(currVert-1) + TEX_ATTRIB ]; |
| 774 | 774 |
attribs2[VERT2_ATTRIBS*currVert + TEX_ATTRIB+1] = attribs2[VERT2_ATTRIBS*(currVert-1) + TEX_ATTRIB+1]; |
| 775 |
attribs2[VERT2_ATTRIBS*currVert + TAG_ATTRIB ] = DEFAULT_TAG;
|
|
| 775 |
attribs2[VERT2_ATTRIBS*currVert + ASS_ATTRIB ] = DEFAULT_ASSOCIATION;
|
|
| 776 | 776 |
|
| 777 | 777 |
currVert++; |
| 778 | 778 |
} |
| src/main/java/org/distorted/library/mesh/MeshQuad.java | ||
|---|---|---|
| 46 | 46 |
|
| 47 | 47 |
attribs2[VERT2_ATTRIBS*index + TEX_ATTRIB ] = x; |
| 48 | 48 |
attribs2[VERT2_ATTRIBS*index + TEX_ATTRIB+1] = 1.0f-y; |
| 49 |
attribs2[VERT2_ATTRIBS*index + TAG_ATTRIB ] = DEFAULT_TAG;
|
|
| 49 |
attribs2[VERT2_ATTRIBS*index + ASS_ATTRIB ] = DEFAULT_ASSOCIATION;
|
|
| 50 | 50 |
} |
| 51 | 51 |
|
| 52 | 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/library/mesh/MeshRectangles.java | ||
|---|---|---|
| 73 | 73 |
|
| 74 | 74 |
attribs2[VERT2_ATTRIBS*vertex + TEX_ATTRIB ] = x; |
| 75 | 75 |
attribs2[VERT2_ATTRIBS*vertex + TEX_ATTRIB+1] = 1.0f-y; |
| 76 |
attribs2[VERT2_ATTRIBS*vertex + TAG_ATTRIB ] = DEFAULT_TAG;
|
|
| 76 |
attribs2[VERT2_ATTRIBS*vertex + ASS_ATTRIB ] = DEFAULT_ASSOCIATION;
|
|
| 77 | 77 |
|
| 78 | 78 |
return vertex+1; |
| 79 | 79 |
} |
| ... | ... | |
| 100 | 100 |
|
| 101 | 101 |
attribs2[VERT2_ATTRIBS*vertex + TEX_ATTRIB ] = attribs2[VERT2_ATTRIBS*(vertex-1) + TEX_ATTRIB ]; |
| 102 | 102 |
attribs2[VERT2_ATTRIBS*vertex + TEX_ATTRIB+1] = attribs2[VERT2_ATTRIBS*(vertex-1) + TEX_ATTRIB+1]; |
| 103 |
attribs2[VERT2_ATTRIBS*vertex + TAG_ATTRIB ] = DEFAULT_TAG;
|
|
| 103 |
attribs2[VERT2_ATTRIBS*vertex + ASS_ATTRIB ] = DEFAULT_ASSOCIATION;
|
|
| 104 | 104 |
|
| 105 | 105 |
vertex++; |
| 106 | 106 |
} |
| src/main/java/org/distorted/library/mesh/MeshSphere.java | ||
|---|---|---|
| 95 | 95 |
|
| 96 | 96 |
attribs2[VERT2_ATTRIBS*currentVert + TEX_ATTRIB ] = attribs2[VERT2_ATTRIBS*(currentVert-1) + TEX_ATTRIB ]; |
| 97 | 97 |
attribs2[VERT2_ATTRIBS*currentVert + TEX_ATTRIB+1] = attribs2[VERT2_ATTRIBS*(currentVert-1) + TEX_ATTRIB+1]; |
| 98 |
attribs2[VERT2_ATTRIBS*currentVert + TAG_ATTRIB ] = DEFAULT_TAG;
|
|
| 98 |
attribs2[VERT2_ATTRIBS*currentVert + ASS_ATTRIB ] = DEFAULT_ASSOCIATION;
|
|
| 99 | 99 |
|
| 100 | 100 |
currentVert++; |
| 101 | 101 |
} |
| ... | ... | |
| 199 | 199 |
|
| 200 | 200 |
attribs2[VERT2_ATTRIBS*currentVert + TEX_ATTRIB ] = (float)texX; |
| 201 | 201 |
attribs2[VERT2_ATTRIBS*currentVert + TEX_ATTRIB+1] = (float)texY; |
| 202 |
attribs2[VERT2_ATTRIBS*currentVert + TAG_ATTRIB ] = DEFAULT_TAG;
|
|
| 202 |
attribs2[VERT2_ATTRIBS*currentVert + ASS_ATTRIB ] = DEFAULT_ASSOCIATION;
|
|
| 203 | 203 |
|
| 204 | 204 |
currentVert++; |
| 205 | 205 |
|
| src/main/java/org/distorted/library/mesh/MeshTriangles.java | ||
|---|---|---|
| 48 | 48 |
|
| 49 | 49 |
attribs2[VERT2_ATTRIBS*vertex + TEX_ATTRIB ] = x; |
| 50 | 50 |
attribs2[VERT2_ATTRIBS*vertex + TEX_ATTRIB+1] = y; |
| 51 |
attribs2[VERT2_ATTRIBS*vertex + TAG_ATTRIB ] = DEFAULT_TAG;
|
|
| 51 |
attribs2[VERT2_ATTRIBS*vertex + ASS_ATTRIB ] = DEFAULT_ASSOCIATION;
|
|
| 52 | 52 |
|
| 53 | 53 |
return vertex+1; |
| 54 | 54 |
} |
| src/main/res/raw/main_vertex_shader.glsl | ||
|---|---|---|
| 25 | 25 |
in vec3 a_Inflate; // This vector describes the direction this vertex needs to go when we 'inflate' the whole mesh. |
| 26 | 26 |
// If the mesh is locally smooth, this is equal to the normal vector. Otherwise (on sharp edges) - no. |
| 27 | 27 |
in vec2 a_TexCoordinate; // Per-vertex texture coordinate. |
| 28 |
in float a_Tag; // Per-vertex tag. Connects the vertex (really the mesh component the vertex is a member of) to a vertex effect. |
|
| 29 |
// An effect will only be active on a vertex iff (a_Tag & vTag[effect]) != 0. ( see VertexEffect.retSection() ) |
|
| 28 |
in float a_Association; // Per-vertex association. Connects the vertex (really the mesh component the vertex is a member of) |
|
| 29 |
// to a vertex effect. An effect will only be active on a vertex iff (a_Association & vAssociation[effect]) != 0. |
|
| 30 |
// ( see VertexEffect.retSection() ) |
|
| 30 | 31 |
|
| 31 | 32 |
out vec3 v_Position; // |
| 32 | 33 |
out vec3 v_endPosition; // for Transform Feedback only |
| ... | ... | |
| 48 | 49 |
uniform vec4 vUniforms[3*NUM_VERTEX];// i-th effect is 3 consecutive vec4's: [3*i], [3*i+1], [3*i+2]. |
| 49 | 50 |
// The first vec4 is the Interpolated values, |
| 50 | 51 |
// second vec4: first float - cache, next 3: Center, the third - the Region. |
| 51 |
uniform int vTag[NUM_VERTEX]; // Tags of the vertex effects. Tags are used to connect an effect to a Mesh component.
|
|
| 52 |
uniform int vAssociation[NUM_VERTEX];// Associations of the vertex effects. Those are used to connect an effect to a Mesh component.
|
|
| 52 | 53 |
|
| 53 | 54 |
////////////////////////////////////////////////////////////////////////////////////////////// |
| 54 | 55 |
// HELPER FUNCTIONS |
Also available in: Unified diff
Change 'tag' to a more appropriate name - 'association'.