Project

General

Profile

« Previous | Next » 

Revision 8a99c681

Added by Leszek Koltunski about 7 years ago

Make a MeshCubes object rendered with no effects have its front wall at the screen's surface (so that when we just replace MeshFlat with MeshCubes, it looks more similar)

View differences:

src/main/java/org/distorted/examples/quaternion/QuaternionRenderer.java
31 31
import org.distorted.library.DistortedEffects;
32 32
import org.distorted.library.DistortedScreen;
33 33
import org.distorted.library.EffectTypes;
34
import org.distorted.library.MeshObject;
34 35
import org.distorted.library.type.Dynamic;
35 36
import org.distorted.library.type.DynamicQuat;
36 37
import org.distorted.library.MeshCubes;
......
41 42

  
42 43
import android.graphics.Bitmap;
43 44
import android.graphics.BitmapFactory;
44
import android.opengl.GLES30;
45 45
import android.opengl.GLSurfaceView;
46 46

  
47 47
///////////////////////////////////////////////////////////////////////////////////////////////////
......
53 53
  private GLSurfaceView mView;
54 54
  private DistortedTexture mTexture;
55 55
  private DistortedEffects mEffects;
56
  private MeshObject mMesh;
56 57
  private DistortedScreen mScreen;
57 58
  private DynamicQuat mRot;
58 59
    
......
63 64
    mView    = v;
64 65
    mTexture = new DistortedTexture(1,1);
65 66
    mEffects = new DistortedEffects();
67
    mMesh    = new MeshCubes(1,1,false);
66 68
    mRot     = new DynamicQuat();
67 69

  
68 70
    Random rnd = new Random(System.currentTimeMillis());
......
85 87
    mRot.setMode(Dynamic.MODE_LOOP);
86 88

  
87 89
    mScreen = new DistortedScreen();
88
    mScreen.attach(mTexture,mEffects,new MeshCubes(1,1,false));
90
    mScreen.attach(mTexture,mEffects,mMesh);
89 91
    }
90 92

  
91 93
///////////////////////////////////////////////////////////////////////////////////////////////////
......
99 101
    
100 102
  public void onSurfaceChanged(GL10 glUnused, int width, int height) 
101 103
    {
102
    float scaleFactor = width>height ? height/3:width/3;
104
    float w = mTexture.getWidth();
105
    float h = mTexture.getHeight();
106
    float d = mTexture.getDepth(mMesh);
107

  
108
    float scaleFactor = 0.5f*(width>height ? height/h:width/w);
109
    Static3D center = new Static3D(w/2,h/2,-d/2);
103 110

  
104 111
    mEffects.abortEffects(EffectTypes.MATRIX);
105
    mEffects.move( new Static3D( (width-scaleFactor)/2 , (height-scaleFactor)/2 , 0) );
112
    mEffects.move( new Static3D( (width-scaleFactor*w)/2 , (height-scaleFactor*h)/2 , 0) );
106 113
    mEffects.scale(scaleFactor);
107
    mEffects.quaternion( mRot, new Static3D( (float)mTexture.getWidth()/2, (float)mTexture.getHeight()/2 , 0) );
114
    mEffects.quaternion( mRot,center );
108 115
       
109 116
    mScreen.resize(width, height);
110 117
    }

Also available in: Unified diff