Project

General

Profile

« Previous | Next » 

Revision 044b5494

Added by Leszek Koltunski about 4 years ago

Move the Effects.setStretch to Meshbase.setStretch

View differences:

src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
167 167
      MeshBase mesh = node.getMesh();
168 168
      DistortedEffects effects = node.getEffects();
169 169

  
170
      float halfW = effects.getStartchX() / 2.0f;
171
      float halfH = effects.getStartchY() / 2.0f;
172
      float halfZ = effects.getStartchZ() / 2.0f;
170
      float halfW = mesh.getStretchX() / 2.0f;
171
      float halfH = mesh.getStretchY() / 2.0f;
172
      float halfZ = mesh.getStretchZ() / 2.0f;
173 173

  
174 174
      int width   = buffer.getWidth();
175 175
      int height  = buffer.getHeight();
src/main/java/org/distorted/library/main/DistortedEffects.java
36 36
  private long mID;
37 37
  private EffectQueue[] mQueues;
38 38

  
39
  private int[] mStretchX, mStretchY, mStretchZ;
40

  
41 39
///////////////////////////////////////////////////////////////////////////////////////////////////
42 40
/**
43 41
 * @y.exclude
......
60 58
/**
61 59
 * Create empty effect queue.
62 60
 */
63
  public DistortedEffects(int stretchX, int stretchY, int stretchZ)
64
    {
65
    mStretchX = new int[1];
66
    mStretchY = new int[1];
67
    mStretchZ = new int[1];
68

  
69
    mStretchX[0] = stretchX;
70
    mStretchY[0] = stretchY;
71
    mStretchZ[0] = stretchZ;
72

  
73
    mID = ++mNextID;
74
    mQueues = new EffectQueue[EffectType.LENGTH];
75
    EffectQueue.allocateQueues(mQueues,null,0);
76
    }
77

  
78
///////////////////////////////////////////////////////////////////////////////////////////////////
79
/**
80
 * Temporary constructor.
81
 */
82
 public DistortedEffects(int dummy)
61
 public DistortedEffects()
83 62
    {
84
    mStretchX = new int[1];
85
    mStretchY = new int[1];
86
    mStretchZ = new int[1];
87

  
88
    mStretchX[0] = 1;
89
    mStretchY[0] = 1;
90
    mStretchZ[0] = 1;
91

  
92 63
    mID = ++mNextID;
93 64
    mQueues = new EffectQueue[EffectType.LENGTH];
94 65
    EffectQueue.allocateQueues(mQueues,null,0);
......
106 77
 */
107 78
  public DistortedEffects(DistortedEffects dc, int flags)
108 79
    {
109
    mStretchX = dc.mStretchX;
110
    mStretchY = dc.mStretchY;
111
    mStretchZ = dc.mStretchZ;
112

  
113 80
    mID = ++mNextID;
114 81
    mQueues = new EffectQueue[EffectType.LENGTH];
115 82
    EffectQueue.allocateQueues(mQueues,dc.getQueues(),flags);
116 83
    }
117 84

  
118
///////////////////////////////////////////////////////////////////////////////////////////////////
119
/**
120
 * Sets the stretch parameters. Coordinates of all vertices of any Mesh rendered with those Effects
121
 * will be first pre-multiplied by those.
122
 */
123
  public void setStretch(int sx, int sy, int sz)
124
    {
125
    mStretchX[0] = sx;
126
    mStretchY[0] = sy;
127
    mStretchZ[0] = sz;
128
    }
129

  
130
///////////////////////////////////////////////////////////////////////////////////////////////////
131
/**
132
 * X coordinates of all vertices of any Mesh rendered with those Effects will be first pre-multiplied
133
 * by this parameter.
134
 */
135
  public int getStartchX()
136
    {
137
    return mStretchX[0];
138
    }
139

  
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141
/**
142
 * Y coordinates of all vertices of any Mesh rendered with those Effects will be first pre-multiplied
143
 * by this parameter.
144
 */
145
  public int getStartchY()
146
    {
147
    return mStretchY[0];
148
    }
149

  
150
///////////////////////////////////////////////////////////////////////////////////////////////////
151
/**
152
 * Z coordinates of all vertices of any Mesh rendered with those Effects will be first pre-multiplied
153
 * by this parameter.
154
 */
155
  public int getStartchZ()
156
    {
157
    return mStretchZ[0];
158
    }
159

  
160 85
///////////////////////////////////////////////////////////////////////////////////////////////////
161 86
/**
162 87
 * Returns unique ID of this instance.
src/main/java/org/distorted/library/main/DistortedLibrary.java
430 430

  
431 431
  static void drawPrivOIT(DistortedEffects effects, MeshBase mesh, InternalOutputSurface surface, long currTime)
432 432
    {
433
    float halfX = effects.getStartchX() / 2.0f;
434
    float halfY = effects.getStartchY() / 2.0f;
435
    float halfZ = effects.getStartchZ() / 2.0f;
433
    float halfX = mesh.getStretchX() / 2.0f;
434
    float halfY = mesh.getStretchY() / 2.0f;
435
    float halfZ = mesh.getStretchZ() / 2.0f;
436 436

  
437 437
    EffectQueue[] queues = effects.getQueues();
438 438

  
......
467 467

  
468 468
  static void drawPriv(DistortedEffects effects, MeshBase mesh, InternalOutputSurface surface, long currTime)
469 469
    {
470
    float halfX = effects.getStartchX() / 2.0f;
471
    float halfY = effects.getStartchY() / 2.0f;
472
    float halfZ = effects.getStartchZ() / 2.0f;
470
    float halfX = mesh.getStretchX() / 2.0f;
471
    float halfY = mesh.getStretchY() / 2.0f;
472
    float halfZ = mesh.getStretchZ() / 2.0f;
473 473

  
474 474
    EffectQueue[] queues = effects.getQueues();
475 475

  
src/main/java/org/distorted/library/main/DistortedNode.java
240 240

  
241 241
  private DistortedFramebuffer allocateNewFBO()
242 242
    {
243
    int width  = mFboW <= 0 ? mEffects.getStartchX() : mFboW;
244
    int height = mFboH <= 0 ? mEffects.getStartchY() : mFboH;
243
    int width  = mFboW <= 0 ? (int)mMesh.getStretchX() : mFboW;
244
    int height = mFboH <= 0 ? (int)mMesh.getStretchY() : mFboH;
245 245
    return new DistortedFramebuffer(1,mFboDepthStencil, InternalSurface.TYPE_TREE, width, height);
246 246
    }
247 247

  
src/main/java/org/distorted/library/main/DistortedScreen.java
165 165
      fpsTexture = new DistortedTexture();
166 166
      fpsTexture.setTexture(fpsBitmap);
167 167
      fpsCanvas = new Canvas(fpsBitmap);
168
      fpsEffects = new DistortedEffects(FPS_W,FPS_H,0);
168
      fpsEffects = new DistortedEffects();
169
      fpsMesh.setStretch(FPS_W,FPS_H,0);
169 170
      fpsEffects.apply(mMoveEffect);
170 171

  
171 172
      mPaint = new Paint();
src/main/java/org/distorted/library/mesh/MeshBase.java
68 68
   private int mNumVertices;
69 69
   private float[] mVertAttribs;      // packed: PosX,PosY,PosZ, NorX,NorY,NorZ, InfX,InfY,InfZ, TexS,TexT
70 70
   private float mInflate;
71
   private float mStretchX, mStretchY, mStretchZ;
71 72

  
72 73
   private class Component
73 74
     {
......
100 101

  
101 102
///////////////////////////////////////////////////////////////////////////////////////////////////
102 103

  
103
   MeshBase()
104
   MeshBase(float width, float height, float depth)
104 105
     {
106
     mStretchX = width;
107
     mStretchY = height;
108
     mStretchZ = depth;
109

  
105 110
     mShowNormals = false;
106 111
     mInflate     = 0.0f;
107 112
     mComponent = new ArrayList<>();
......
116 121

  
117 122
   MeshBase(MeshBase original)
118 123
     {
124
     mStretchX = original.mStretchX;
125
     mStretchY = original.mStretchY;
126
     mStretchZ = original.mStretchZ;
127

  
119 128
     mShowNormals = original.mShowNormals;
120 129
     mInflate     = original.mInflate;
121 130

  
......
173 182
     return mNumVertices;
174 183
     }
175 184

  
185
///////////////////////////////////////////////////////////////////////////////////////////////////
186
/**
187
 * Sets the stretch parameters. Coordinates of all vertices will be first pre-multiplied by those.
188
 */
189
  public void setStretch(int sx, int sy, int sz)
190
    {
191
    mStretchX = sx;
192
    mStretchY = sy;
193
    mStretchZ = sz;
194
    }
195

  
196
///////////////////////////////////////////////////////////////////////////////////////////////////
197
/**
198
 * X coordinates of all vertices will be first pre-multiplied by this parameter.
199
 */
200
  public float getStretchX()
201
    {
202
    return mStretchX;
203
    }
204

  
205
///////////////////////////////////////////////////////////////////////////////////////////////////
206
/**
207
 * Y coordinates of all vertices will be first pre-multiplied by this parameter.
208
 */
209
  public float getStretchY()
210
    {
211
    return mStretchY;
212
    }
213

  
214
///////////////////////////////////////////////////////////////////////////////////////////////////
215
/**
216
 * Z coordinates of all vertices will be first pre-multiplied by this parameter.
217
 */
218
  public float getStretchZ()
219
    {
220
    return mStretchZ;
221
    }
222

  
176 223
///////////////////////////////////////////////////////////////////////////////////////////////////
177 224
/**
178 225
 * Not part of public API, do not document (public only because has to be used from the main package)
src/main/java/org/distorted/library/mesh/MeshCubes.java
827 827
 */
828 828
 public MeshCubes(int cols, String desc, int slices)
829 829
   {
830
   super(1,1,1);
830 831
   Static4D map = new Static4D(0.0f,0.0f,1.0f,1.0f);
831 832
   fillTexMappings(map,map,map,map,map,map);
832 833
   prepareDataStructures(cols,desc,slices);
......
872 873
 */
873 874
 public MeshCubes(int cols, String desc, int slices, Static4D front, Static4D back, Static4D left, Static4D right, Static4D top, Static4D bottom)
874 875
   {
876
   super(1,1,1);
875 877
   fillTexMappings(front,back,left,right,top,bottom);
876 878
   prepareDataStructures(cols,desc,slices);
877 879
   build();
......
887 889
 */
888 890
 public MeshCubes(int cols, int rows, int slices)
889 891
   {
892
   super(1,1,1);
890 893
   Static4D map = new Static4D(0.0f,0.0f,1.0f,1.0f);
891 894
   fillTexMappings(map,map,map,map,map,map);
892 895
   prepareDataStructures(cols,rows,slices);
......
916 919
 */
917 920
 public MeshCubes(int cols, int rows, int slices, Static4D front, Static4D back, Static4D left, Static4D right, Static4D top, Static4D bottom)
918 921
   {
922
   super(1,1,1);
919 923
   fillTexMappings(front,back,left,right,top,bottom);
920 924
   prepareDataStructures(cols,rows,slices);
921 925
   build();
src/main/java/org/distorted/library/mesh/MeshQuad.java
56 56
   */
57 57
  public MeshQuad()
58 58
    {
59
    super(1,1,0);
59 60
    float[] attribs= new float[VERT_ATTRIBS*4];
60 61

  
61 62
    addVertex(0.0f,0.0f, attribs,0);
src/main/java/org/distorted/library/mesh/MeshRectangles.java
158 158
 */
159 159
 public MeshRectangles(int cols, int rows)
160 160
    {
161
    super(1,1,0);
161 162
    computeNumberOfVertices(cols,rows);
162 163

  
163 164
    float[] attribs= new float[VERT_ATTRIBS*numVertices];
src/main/java/org/distorted/library/mesh/MeshSphere.java
253 253
   */
254 254
  public MeshSphere(int level)
255 255
    {
256
    super(1,1,1);
256 257
    computeNumberOfVertices(level);
257 258
    float[] attribs= new float[VERT_ATTRIBS*numVertices];
258 259

  

Also available in: Unified diff