Project

General

Profile

« Previous | Next » 

Revision c92c163c

Added by Leszek Koltunski over 3 years ago

New API for the library: add an empty texture component to a Mesh.
Use this in thr Magic Cube to add empty texture components to some types of cubits.

View differences:

src/main/java/org/distorted/library/mesh/DeferredJobs.java
37 37
 */
38 38
public class DeferredJobs
39 39
  {
40
  private static final int JOB_TYPE_VERTEX   = 0;
41
  private static final int JOB_TYPE_MATRIX   = 1;
42
  private static final int JOB_TYPE_MERGE_TEX= 2;
43
  private static final int JOB_TYPE_MERGE_EFF= 3;
44
  private static final int JOB_TYPE_JOIN     = 4;
45
  private static final int JOB_TYPE_COPY     = 5;
46
  private static final int JOB_TYPE_TEXTURE  = 6;
47
  private static final int JOB_TYPE_ASSOC    = 7;
48
  private static final int JOB_TYPE_CENTER   = 8;
40
  private static final int JOB_TYPE_VERTEX       = 0;
41
  private static final int JOB_TYPE_MATRIX       = 1;
42
  private static final int JOB_TYPE_MERGE_TEX    = 2;
43
  private static final int JOB_TYPE_MERGE_EFF    = 3;
44
  private static final int JOB_TYPE_JOIN         = 4;
45
  private static final int JOB_TYPE_COPY         = 5;
46
  private static final int JOB_TYPE_TEXTURE      = 6;
47
  private static final int JOB_TYPE_ASSOC        = 7;
48
  private static final int JOB_TYPE_CENTER       = 8;
49
  private static final int JOB_TYPE_ADD_EMPTY_TEX= 9;
49 50

  
50 51
  private static ArrayList<JobNode> mJobs = new ArrayList<>();
51 52

  
......
62 63
    private int mComp, mAndAssoc, mEquAssoc;
63 64
    private float mX,mY,mZ;
64 65

  
65
    Job(int type, MeshBase target, MeshBase[] source, VertexEffect vEff, MatrixEffect mEff, Static4D[] maps, int comp, int and, int equ, float x, float y, float z)
66
    Job(int type, MeshBase target, MeshBase[] source, VertexEffect vEff, MatrixEffect mEff,
67
        Static4D[] maps, int comp, int and, int equ, float x, float y, float z)
66 68
      {
67 69
      mType     = type;
68 70
      mTarget   = target;
......
93 95
      {
94 96
      switch(mType)
95 97
        {
96
        case JOB_TYPE_VERTEX   : DistortedLibrary.adjustVertices(mTarget, mVertexEffects);
97
                                 break;
98
        case JOB_TYPE_MATRIX   : mTarget.applyMatrix(mMatrixEffect,mAndAssoc,mEquAssoc);
99
                                 break;
100
        case JOB_TYPE_MERGE_TEX: mTarget.mergeTexComponentsNow();
101
                                 break;
102
        case JOB_TYPE_MERGE_EFF: mTarget.mergeEffComponentsNow();
103
                                 break;
104
        case JOB_TYPE_JOIN     : mTarget.joinAttribs(mSource);
105
                                 break;
106
        case JOB_TYPE_COPY     : mTarget.copy(mSource[0]);
107
                                 break;
108
        case JOB_TYPE_TEXTURE  : mTarget.textureMap(mMaps,mComp);
109
                                 break;
110
        case JOB_TYPE_ASSOC    : mTarget.setEffectAssociationNow(mComp,mAndAssoc,mEquAssoc);
111
                                 break;
112
        case JOB_TYPE_CENTER   : mTarget.setComponentCenterNow(mComp,mX,mY,mZ);
113
                                 break;
98
        case JOB_TYPE_VERTEX       : DistortedLibrary.adjustVertices(mTarget, mVertexEffects);
99
                                     break;
100
        case JOB_TYPE_MATRIX       : mTarget.applyMatrix(mMatrixEffect,mAndAssoc,mEquAssoc);
101
                                     break;
102
        case JOB_TYPE_MERGE_TEX    : mTarget.mergeTexComponentsNow();
103
                                     break;
104
        case JOB_TYPE_MERGE_EFF    : mTarget.mergeEffComponentsNow();
105
                                     break;
106
        case JOB_TYPE_JOIN         : mTarget.joinAttribs(mSource);
107
                                     break;
108
        case JOB_TYPE_COPY         : mTarget.copy(mSource[0]);
109
                                     break;
110
        case JOB_TYPE_TEXTURE      : mTarget.textureMap(mMaps,mComp);
111
                                     break;
112
        case JOB_TYPE_ASSOC        : mTarget.setEffectAssociationNow(mComp,mAndAssoc,mEquAssoc);
113
                                     break;
114
        case JOB_TYPE_CENTER       : mTarget.setComponentCenterNow(mComp,mX,mY,mZ);
115
                                     break;
116
        case JOB_TYPE_ADD_EMPTY_TEX: mTarget.addEmptyTexComponentNow();
117
                                     break;
114 118
        }
115
/*
116
      Log.e("jobs", "executing "+print()+" job");
117
      mTarget.print();
118
*/
119 119
      }
120 120

  
121 121
    void clear()
......
127 127
      {
128 128
      switch(mType)
129 129
        {
130
        case JOB_TYPE_VERTEX   : return "VERTEX";
131
        case JOB_TYPE_MATRIX   : return "MATRIX";
132
        case JOB_TYPE_MERGE_TEX: return "MERGE_TEX";
133
        case JOB_TYPE_MERGE_EFF: return "MERGE_EFF";
134
        case JOB_TYPE_JOIN     : return "JOIN";
135
        case JOB_TYPE_COPY     : return "COPY";
136
        case JOB_TYPE_TEXTURE  : return "TEXTURE";
137
        case JOB_TYPE_ASSOC    : return "ASSOC";
138
        case JOB_TYPE_CENTER   : return "CENTER";
130
        case JOB_TYPE_VERTEX       : return "VERTEX";
131
        case JOB_TYPE_MATRIX       : return "MATRIX";
132
        case JOB_TYPE_MERGE_TEX    : return "MERGE_TEX";
133
        case JOB_TYPE_MERGE_EFF    : return "MERGE_EFF";
134
        case JOB_TYPE_JOIN         : return "JOIN";
135
        case JOB_TYPE_COPY         : return "COPY";
136
        case JOB_TYPE_TEXTURE      : return "TEXTURE";
137
        case JOB_TYPE_ASSOC        : return "ASSOC";
138
        case JOB_TYPE_CENTER       : return "CENTER";
139
        case JOB_TYPE_ADD_EMPTY_TEX: return "ADD_EMPTY_TEX";
139 140
        }
140 141

  
141 142
      return null;
......
289 290
    return node;
290 291
    }
291 292

  
293
///////////////////////////////////////////////////////////////////////////////////////////////////
294

  
295
  static JobNode addEmptyTex(MeshBase target)
296
    {
297
    JobNode jn = target.mJobNode[0];
298
    Job job = new Job(JOB_TYPE_ADD_EMPTY_TEX,target,null,null,null,null,0,0,0,0,0,0);
299
    JobNode node = new JobNode(job);
300
    node.mPrevJobs.add(jn);
301
    jn.mNextJobs.add(node);
302
    mJobs.add(node);
303
    return node;
304
    }
305

  
292 306
///////////////////////////////////////////////////////////////////////////////////////////////////
293 307

  
294 308
  static JobNode mergeEff(MeshBase target)
src/main/java/org/distorted/library/mesh/MeshBase.java
220 220
       }
221 221
     }
222 222

  
223

  
224
///////////////////////////////////////////////////////////////////////////////////////////////////
225

  
226
   void addEmptyTexComponentNow()
227
     {
228
     mTexComponent.add(new TexComponent(mNumVertices-1));
229
     }
230

  
223 231
///////////////////////////////////////////////////////////////////////////////////////////////////
224 232

  
225 233
   void mergeEffComponentsNow()
......
1210 1218
       }
1211 1219
     }
1212 1220

  
1221
///////////////////////////////////////////////////////////////////////////////////////////////////
1222
/**
1223
 * Adds an empty (no vertices) texture component to the end of the text component list.
1224
 *
1225
 * Sometimes we want to do this to have several Meshes with equal number of tex components each.
1226
 */
1227
   public void addEmptyTexComponent()
1228
     {
1229
      if( mJobNode[0]==null )
1230
       {
1231
       addEmptyTexComponentNow();
1232
       }
1233
     else
1234
       {
1235
       mJobNode[0] = DeferredJobs.addEmptyTex(this);
1236
       }
1237
     }
1238

  
1213 1239
///////////////////////////////////////////////////////////////////////////////////////////////////
1214 1240
/**
1215 1241
 * Return the number of texture components, i.e. individual subsets of the whole set of vertices

Also available in: Unified diff