Project

General

Profile

« Previous | Next » 

Revision b3090c52

Added by Leszek Koltunski almost 5 years ago

Minor.
Looks like MeshBase.join() actually works.

View differences:

src/main/java/org/distorted/examples/meshjoin/MeshJoinRenderer.java
36 36
import org.distorted.library.mesh.MeshBase;
37 37
import org.distorted.library.mesh.MeshJoined;
38 38
import org.distorted.library.mesh.MeshQuad;
39
import org.distorted.library.mesh.MeshRectangles;
40
import org.distorted.library.mesh.MeshSphere;
41
import org.distorted.library.mesh.MeshTriangles;
39 42
import org.distorted.library.type.DynamicQuat;
40 43
import org.distorted.library.type.Static1D;
41 44
import org.distorted.library.type.Static3D;
......
96 99
    
97 100
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
98 101
      {
99
      final float SCALE = 0.75f;
102
      final float SCALE = 0.6f;
100 103
      mScreenMin = width<height ? width:height;
101 104
      float factor = SCALE*mScreenMin;
102 105
      mScale.set(factor,factor,factor);
......
128 131

  
129 132
      if( mMesh==null ) mMesh = createJoinedMesh();
130 133

  
134
      mMesh.setShowNormals(true);
135

  
131 136
      mScreen.detachAll();
132 137
      mScreen.attach(mTexture,mEffects,mMesh);
133 138

  
......
145 150

  
146 151
    private MeshBase createJoinedMesh()
147 152
      {
148
      Static3D axis   = new Static3D(0,1,0);
153
      MeshBase[] meshes = new MeshBase[2];
154
      meshes[0] = new MeshSphere(5);
155
      meshes[1] = new MeshTriangles(5);
156

  
157
      MatrixEffect[] effects0 = new MatrixEffect[2];
158
      effects0[0] = new MatrixEffectScale( new Static3D(0.5f, 1.0f, 0.5f) );
159
      effects0[1] = new MatrixEffectMove( new Static3D(+0.25f,0,0));
160

  
161
      meshes[0].apply(effects0);
162

  
163
      MatrixEffect[] effects1 = new MatrixEffect[2];
164
      effects1[0] = new MatrixEffectScale( new Static3D(0.5f, 1.0f, 0.5f) );
165
      effects1[1] = new MatrixEffectMove( new Static3D(-0.25f,0,0));
166

  
167
      meshes[1].apply(effects1);
168
      /*
169
      final int MESHES=6;
170

  
171
      Static3D axisY  = new Static3D(0,1,0);
172
      Static3D axisX  = new Static3D(1,0,0);
149 173
      Static3D center = new Static3D(0,0,0);
150 174
      Static1D angle  = new Static1D(0);
151 175

  
152
      MatrixEffect[] effects = new MatrixEffect[2];
153
      effects[0] = new MatrixEffectMove(new Static3D(0,0,-0.5f));
154
      effects[1] = new MatrixEffectRotate( angle, axis, center );
176
      MatrixEffect[] effectsY = new MatrixEffect[2];
177
      effectsY[0] = new MatrixEffectMove(new Static3D(0,0,+0.5f));
178
      effectsY[1] = new MatrixEffectRotate( angle, axisY, center );
155 179

  
156
      MeshBase[] meshes = new MeshQuad[4];
157

  
158
      for(int i=0; i<4; i++) meshes[i] = new MeshQuad();
180
      MeshBase[] meshes = new MeshRectangles[MESHES];
181
      for(int i=0; i<MESHES; i++) meshes[i] = new MeshRectangles(5,5);
159 182

  
160 183
      angle.set(0);
161
      meshes[0].apply(effects);
184
      meshes[0].apply(effectsY);
162 185
      angle.set(90);
163
      meshes[1].apply(effects);
186
      meshes[1].apply(effectsY);
164 187
      angle.set(180);
165
      meshes[2].apply(effects);
188
      meshes[2].apply(effectsY);
166 189
      angle.set(270);
167
      meshes[3].apply(effects);
190
      meshes[3].apply(effectsY);
191

  
192
      MatrixEffect[] effectsX = new MatrixEffect[2];
193
      effectsX[0] = new MatrixEffectMove(new Static3D(0,0,+0.5f));
194
      effectsX[1] = new MatrixEffectRotate( angle, axisX, center );
168 195

  
196
      angle.set( 90);
197
      meshes[4].apply(effectsX);
198
      angle.set(-90);
199
      meshes[5].apply(effectsX);
200
*/
169 201
      return new MeshJoined(meshes);
170 202
      }
171 203
}

Also available in: Unified diff