Project

General

Profile

« Previous | Next » 

Revision 0339e04e

Added by Leszek Koltunski over 4 years ago

Progress with MeshJoin - round the corners. Looks so-so.

View differences:

src/main/java/org/distorted/examples/meshjoin/MeshJoinRenderer.java
27 27
import org.distorted.library.effect.EffectType;
28 28
import org.distorted.library.effect.MatrixEffectQuaternion;
29 29
import org.distorted.library.effect.MatrixEffectScale;
30
import org.distorted.library.effect.VertexEffectDeform;
30 31
import org.distorted.library.effect.VertexEffectMove;
31 32
import org.distorted.library.effect.VertexEffectRotate;
32 33
import org.distorted.library.effect.VertexEffectScale;
......
128 129
      mScreen.detachAll();
129 130
      mScreen.attach(mTexture,mEffects,mMesh);
130 131

  
131
      DistortedLibrary.setMax(EffectType.VERTEX, 7);
132
      DistortedLibrary.setMax(EffectType.VERTEX, 11);
132 133
      VertexEffectSink.enable();
133 134

  
134 135
      try
......
223 224
      MeshBase result = new MeshJoined(meshes);
224 225
      result.setTextureMap(textureMaps);
225 226

  
227
      Static3D a0 = new Static3D(         0,        1,       0 );
228
      Static3D a1 = new Static3D(         0,  -1.0f/3, 2*SQ2/3 );
229
      Static3D a2 = new Static3D(-SQ2*SQ3/3,  -1.0f/3,  -SQ2/3 );
230
      Static3D a3 = new Static3D( SQ2*SQ3/3,  -1.0f/3,  -SQ2/3 );
231

  
232
      float tetraHeight = SQ2*SQ3/3;
233
      float d1 = 0.75f*tetraHeight;
234
      float d2 =-0.10f*tetraHeight;
235
      float d3 = 0.20f*tetraHeight;
236

  
237
      Static3D dCen0 = new Static3D( d1*a0.get0(), d1*a0.get1(), d1*a0.get2() );
238
      Static3D dCen1 = new Static3D( d1*a1.get0(), d1*a1.get1(), d1*a1.get2() );
239
      Static3D dCen2 = new Static3D( d1*a2.get0(), d1*a2.get1(), d1*a2.get2() );
240
      Static3D dCen3 = new Static3D( d1*a3.get0(), d1*a3.get1(), d1*a3.get2() );
241

  
242
      Static3D dVec0 = new Static3D( d2*a0.get0(), d2*a0.get1(), d2*a0.get2() );
243
      Static3D dVec1 = new Static3D( d2*a1.get0(), d2*a1.get1(), d2*a1.get2() );
244
      Static3D dVec2 = new Static3D( d2*a2.get0(), d2*a2.get1(), d2*a2.get2() );
245
      Static3D dVec3 = new Static3D( d2*a3.get0(), d2*a3.get1(), d2*a3.get2() );
246

  
247
      Static4D dReg  = new Static4D(0,0,0,d3);
248
      Static1D dRad  = new Static1D(1);
249

  
226 250
      Static1D angle  = new Static1D(angleFaces);
227 251
      Static3D axis1  = new Static3D(  -1, 0,      0);
228 252
      Static3D axis2  = new Static3D(0.5f, 0, -SQ3/2);
......
230 254
      Static3D center1= new Static3D(0,-SQ3*SQ2/12,-SQ3/6);
231 255
      Static3D center2= new Static3D(0,-SQ3*SQ2/12,+SQ3/3);
232 256

  
233
      VertexEffectScale  effect1 = new VertexEffectScale ( new Static3D(1,SQ3/2,1) );
234
      VertexEffectRotate effect2 = new VertexEffectRotate( new Static1D(90), new Static3D(1,0,0), new Static3D(0,0,0) );
235
      VertexEffectMove   effect3 = new VertexEffectMove  ( new Static3D(0,-SQ3*SQ2/12,SQ3/12) );
236
      VertexEffectRotate effect4 = new VertexEffectRotate( new Static1D(180), new Static3D(0,0,1), center1 );
237
      VertexEffectRotate effect5 = new VertexEffectRotate( angle, axis1, center1 );
238
      VertexEffectRotate effect6 = new VertexEffectRotate( angle, axis2, center2 );
239
      VertexEffectRotate effect7 = new VertexEffectRotate( angle, axis3, center2 );
257
      VertexEffectScale   effect1 = new VertexEffectScale ( new Static3D(1,SQ3/2,1) );
258
      VertexEffectRotate  effect2 = new VertexEffectRotate( new Static1D(90), new Static3D(1,0,0), new Static3D(0,0,0) );
259
      VertexEffectMove    effect3 = new VertexEffectMove  ( new Static3D(0,-SQ3*SQ2/12,SQ3/12) );
260
      VertexEffectRotate  effect4 = new VertexEffectRotate( new Static1D(180), new Static3D(0,0,1), center1 );
261
      VertexEffectRotate  effect5 = new VertexEffectRotate( angle, axis1, center1 );
262
      VertexEffectRotate  effect6 = new VertexEffectRotate( angle, axis2, center2 );
263
      VertexEffectRotate  effect7 = new VertexEffectRotate( angle, axis3, center2 );
264

  
265
      VertexEffectDeform effect8 = new VertexEffectDeform(dVec0, dRad, dCen0, dReg);
266
      VertexEffectDeform effect9 = new VertexEffectDeform(dVec1, dRad, dCen1, dReg);
267
      VertexEffectDeform effect10= new VertexEffectDeform(dVec2, dRad, dCen2, dReg);
268
      VertexEffectDeform effect11= new VertexEffectDeform(dVec3, dRad, dCen3, dReg);
240 269

  
241 270
      effect1.setMeshAssociation(15);  // apply to all 4 meshes
242 271
      effect2.setMeshAssociation(15);  // apply to all 4 meshes
......
245 274
      effect5.setMeshAssociation( 2);  // apply only to mesh[1]
246 275
      effect6.setMeshAssociation( 4);  // apply only to mesh[2]
247 276
      effect7.setMeshAssociation( 8);  // apply only to mesh[3]
277
      effect8.setMeshAssociation(15);  // apply to all 4 meshes
278
      effect9.setMeshAssociation(15);  // apply to all 4 meshes
279
      effect10.setMeshAssociation(15); // apply to all 4 meshes
280
      effect11.setMeshAssociation(15); // apply to all 4 meshes
248 281

  
249 282
      result.apply(effect1);
250 283
      result.apply(effect2);
......
253 286
      result.apply(effect5);
254 287
      result.apply(effect6);
255 288
      result.apply(effect7);
289
      result.apply(effect8);
290
      result.apply(effect9);
291
      result.apply(effect10);
292
      result.apply(effect11);
256 293

  
257 294
      return result;
258 295
      }

Also available in: Unified diff