Project

General

Profile

« Previous | Next » 

Revision 37320052

Added by Leszek Koltunski over 4 years ago

New MeshJoined.
Test app says it's not working - bug in MeshBase.join().

View differences:

src/main/java/org/distorted/examples/meshjoin/MeshJoinRenderer.java
27 27
import org.distorted.library.effect.MatrixEffect;
28 28
import org.distorted.library.effect.MatrixEffectMove;
29 29
import org.distorted.library.effect.MatrixEffectQuaternion;
30
import org.distorted.library.effect.MatrixEffectRotate;
30 31
import org.distorted.library.effect.MatrixEffectScale;
31 32
import org.distorted.library.main.DistortedEffects;
32 33
import org.distorted.library.main.DistortedLibrary;
33 34
import org.distorted.library.main.DistortedScreen;
34 35
import org.distorted.library.main.DistortedTexture;
35 36
import org.distorted.library.mesh.MeshBase;
37
import org.distorted.library.mesh.MeshJoined;
36 38
import org.distorted.library.mesh.MeshQuad;
37 39
import org.distorted.library.type.DynamicQuat;
40
import org.distorted.library.type.Static1D;
38 41
import org.distorted.library.type.Static3D;
39 42
import org.distorted.library.type.Static4D;
40 43

  
......
54 57
    private DistortedEffects mEffects;
55 58
    private Static3D mScale;
56 59
    private MeshBase mMesh;
57
    private float mObjHeight, mObjWidth, mObjDepth;
58 60

  
59 61
    Static4D mQuat1, mQuat2;
60 62
    int mScreenMin;
......
95 97
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
96 98
      {
97 99
      final float SCALE = 0.75f;
98

  
99 100
      mScreenMin = width<height ? width:height;
100
      float factor = ( width*mObjHeight > height*mObjWidth ) ? (SCALE*height)/mObjHeight :  (SCALE*width)/mObjWidth;
101
      float factor = SCALE*mScreenMin;
101 102
      mScale.set(factor,factor,factor);
102 103
      mScreen.resize(width, height);
103 104
      }
......
127 128

  
128 129
      if( mMesh==null ) mMesh = createJoinedMesh();
129 130

  
130
      mObjWidth = mMesh.getStretchX();
131
      mObjHeight= mMesh.getStretchY();
132
      mObjDepth = mMesh.getStretchZ();
133

  
134 131
      mScreen.detachAll();
135 132
      mScreen.attach(mTexture,mEffects,mMesh);
136 133

  
......
148 145

  
149 146
    private MeshBase createJoinedMesh()
150 147
      {
151
      MatrixEffect[] effects = new MatrixEffect[1];
152
      effects[0] = new MatrixEffectMove(new Static3D(0,0,0.5f));
148
      Static3D axis   = new Static3D(0,1,0);
149
      Static3D center = new Static3D(0,0,0);
150
      Static1D angle  = new Static1D(0);
151

  
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 );
155

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

  
158
      for(int i=0; i<4; i++) meshes[i] = new MeshQuad();
153 159

  
154
      MeshBase mesh = new MeshQuad();
155
      mesh.apply(effects);
160
      angle.set(0);
161
      meshes[0].apply(effects);
162
      angle.set(90);
163
      meshes[1].apply(effects);
164
      angle.set(180);
165
      meshes[2].apply(effects);
166
      angle.set(270);
167
      meshes[3].apply(effects);
156 168

  
157
      return mesh;
169
      return new MeshJoined(meshes);
158 170
      }
159 171
}

Also available in: Unified diff