Project

General

Profile

« Previous | Next » 

Revision 687263cc

Added by Leszek Koltunski about 4 years ago

Move the 'pre-multiply mesh before applying any effects' thing from [(Xsize of texture, Ysize of texture) x Mesh's zFactor] to Effects.setStretch(sx,sy,sz)

View differences:

src/main/java/org/distorted/examples/quaternion/QuaternionRenderer.java
35 35
import org.distorted.library.main.DistortedLibrary;
36 36
import org.distorted.library.main.DistortedScreen;
37 37
import org.distorted.library.main.DistortedTexture;
38
import org.distorted.library.mesh.MeshBase;
39 38
import org.distorted.library.mesh.MeshCubes;
40 39
import org.distorted.library.type.Dynamic;
41 40
import org.distorted.library.type.DynamicQuat;
......
54 53

  
55 54
  private GLSurfaceView mView;
56 55
  private DistortedTexture mTexture;
57
  private MeshBase mMesh;
58 56
  private DistortedScreen mScreen;
59 57
  private Static3D mMove, mScale, mCenter;
60 58

  
......
63 61
  QuaternionRenderer(GLSurfaceView v)
64 62
    {
65 63
    mView    = v;
66
    mTexture = new DistortedTexture(1,1);
67
    mMesh    = new MeshCubes(1,1,1);
64
    mTexture = new DistortedTexture();
68 65

  
69
    DistortedEffects effects = new DistortedEffects();
66
    DistortedEffects effects = new DistortedEffects(1);
70 67
    DynamicQuat rot = new DynamicQuat();
71 68

  
72 69
    Random rnd = new Random(System.currentTimeMillis());
......
97 94
    effects.apply( new MatrixEffectMove(mMove));
98 95

  
99 96
    mScreen = new DistortedScreen();
100
    mScreen.attach(mTexture,effects,mMesh);
97
    mScreen.attach(mTexture,effects,new MeshCubes(1,1,1));
101 98
    }
102 99

  
103 100
///////////////////////////////////////////////////////////////////////////////////////////////////
......
111 108
    
112 109
  public void onSurfaceChanged(GL10 glUnused, int width, int height) 
113 110
    {
114
    float w = mTexture.getWidth();
115
    float h = mTexture.getHeight();
116
    float d = mTexture.getDepth(mMesh);
111
    float factor = 0.5f*(width>height ? height:width);
117 112

  
118
    float factor = 0.5f*(width>height ? height/h:width/w);
119

  
120
    mCenter.set(w/2,h/2,d/2);
121
    mMove.set( (width-factor*w)/2 , (height-factor*h)/2 , -factor*d/2 );
113
    mCenter.set(0.5f,0.5f,0.5f);
114
    mMove.set( (width-factor)/2 , (height-factor)/2 , -factor/2 );
122 115
    mScale.set(factor,factor,factor);
123 116

  
124 117
    mScreen.resize(width, height);

Also available in: Unified diff