Project

General

Profile

« Previous | Next » 

Revision f6d884d5

Added by Leszek Koltunski over 7 years ago

Complete the split DistortedObject -> (DistortedTexture,DistortedEffectQueue)

View differences:

src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java
27 27

  
28 28
import org.distorted.examples.R;
29 29
import org.distorted.library.Distorted;
30
import org.distorted.library.DistortedObject;
30
import org.distorted.library.DistortedTexture;
31
import org.distorted.library.DistortedEffectQueues;
31 32
import org.distorted.library.GridFlat;
32 33
import org.distorted.library.EffectTypes;
33 34
import org.distorted.library.type.Dynamic3D;
......
44 45
class MonaLisaRenderer implements GLSurfaceView.Renderer 
45 46
{
46 47
    private GLSurfaceView mView;
47
    private DistortedObject mObject;
48
    private DistortedTexture mTexture;
49
    private DistortedEffectQueues mQueues;
48 50
    private GridFlat mGrid;
49
    private Static3D pLeft, pRight;
50
    private Static4D rLeft, rRight;
51
    private Dynamic3D dLeft, dRight;
52

  
53 51
    private int bmpHeight, bmpWidth;
54 52

  
55 53
///////////////////////////////////////////////////////////////////////////////////////////////////
56 54

  
57
    public MonaLisaRenderer(GLSurfaceView v) 
55
    MonaLisaRenderer(GLSurfaceView v)
58 56
      {
59 57
      mView = v;
60 58

  
61
      pLeft = new Static3D( 90, 258, 0);
62
      pRight= new Static3D(176, 255, 0);
59
      Static3D pLeft = new Static3D( 90, 258, 0);
60
      Static3D pRight= new Static3D(176, 255, 0);
63 61

  
64
      rLeft = new Static4D(-10,-10,25,25);
65
      rRight= new Static4D( 10, -5,25,25);
66
      dLeft = new Dynamic3D(1000,0.0f);
67
      dRight= new Dynamic3D(1000,0.0f);
62
      Static4D rLeft = new Static4D(-10,-10,25,25);
63
      Static4D rRight= new Static4D( 10, -5,25,25);
64
      Dynamic3D dLeft = new Dynamic3D(1000,0.0f);
65
      Dynamic3D dRight= new Dynamic3D(1000,0.0f);
68 66
      dLeft.add ( new Static3D(  0,  0,0) );
69 67
      dLeft.add ( new Static3D(-20,-20,0) );
70 68
      dRight.add( new Static3D(  0,  0,0) );
71 69
      dRight.add( new Static3D( 20,-10,0) );
70

  
71
      mQueues = new DistortedEffectQueues();
72
      mQueues.distort( dLeft, pLeft , rLeft );
73
      mQueues.distort(dRight, pRight, rRight);
72 74
      }
73 75

  
74 76
///////////////////////////////////////////////////////////////////////////////////////////////////
......
76 78
    public void onDrawFrame(GL10 glUnused) 
77 79
      {
78 80
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
79
      mObject.draw(System.currentTimeMillis(),mGrid);
81
      mQueues.draw(System.currentTimeMillis(),mTexture,mGrid);
80 82
      }
81 83

  
82 84
///////////////////////////////////////////////////////////////////////////////////////////////////
83 85
    
84 86
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
85 87
      { 
86
      mObject.abortEffects(EffectTypes.MATRIX);
88
      mQueues.abortEffects(EffectTypes.MATRIX);
87 89

  
88 90
      if( (float)bmpHeight/bmpWidth > (float)height/width )
89 91
        {
90 92
        int w = (height*bmpWidth)/bmpHeight;
91 93
        float factor = (float)height/bmpHeight;
92
        mObject.move( new Static3D((width-w)/2,0,0) );
93
        mObject.scale(factor);
94
        mQueues.move( new Static3D((width-w)/2,0,0) );
95
        mQueues.scale(factor);
94 96
        }
95 97
      else
96 98
        {
97 99
        int h = (width*bmpHeight)/bmpWidth;
98 100
        float factor = (float)width/bmpWidth;
99
        mObject.move( new Static3D(0,(height-h)/2,0) );
100
        mObject.scale(factor);
101
        mQueues.move( new Static3D(0,(height-h)/2,0) );
102
        mQueues.scale(factor);
101 103
        }
102 104

  
103 105
      Distorted.onSurfaceChanged(width, height); 
......
129 131
      bmpWidth  = bitmap.getWidth();
130 132

  
131 133
      mGrid = new GridFlat(9,9*bmpHeight/bmpWidth);
132
      mObject = new DistortedObject(bmpWidth,bmpHeight,1);
133
      mObject.setTexture(bitmap);
134
      mObject.distort( dLeft, pLeft , rLeft );
135
      mObject.distort(dRight, pRight, rRight);
134
      mTexture = new DistortedTexture(bmpWidth,bmpHeight,0);
135
      mTexture.setTexture(bitmap);
136 136

  
137 137
      try
138 138
        {

Also available in: Unified diff