Project

General

Profile

« Previous | Next » 

Revision 8ff32d4d

Added by Leszek Koltunski over 7 years ago

Finally fix the 'when rendering though an FBO, the other side of triangles is visible'

View differences:

src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java
45 45
{
46 46
    private GLSurfaceView mView;
47 47
    private DistortedBitmap monaLisa;
48
    private Static2D pLeft, pRight;
49
    private Static4D rLeft, rRight;
50
    private Dynamic3D dLeft, dRight;
51

  
52
    private int bmpHeight, bmpWidth;
48 53

  
49 54
///////////////////////////////////////////////////////////////////////////////////////////////////
50 55

  
51 56
    public MonaLisaRenderer(GLSurfaceView v) 
52 57
      {
53 58
      mView = v;
59

  
60
      pLeft = new Static2D( 90, 258);
61
      pRight= new Static2D(176, 255);
62

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

  
56 73
///////////////////////////////////////////////////////////////////////////////////////////////////
......
59 76
      {
60 77
      GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
61 78
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
62
      
79

  
63 80
      monaLisa.draw(System.currentTimeMillis());
64 81
      }
65 82

  
......
68 85
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
69 86
      { 
70 87
      monaLisa.abortEffects(EffectTypes.MATRIX);
71
      monaLisa.move( new Static3D((width-200)/2, 10, 0) );
88

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

  
73 104
      Distorted.onSurfaceChanged(width, height); 
74 105
      }
......
93 124
        catch(IOException e) { }
94 125
        }  
95 126

  
96
      monaLisa = new DistortedBitmap(200,200,1);
97
      monaLisa.setBitmap(bitmap);
127
      bmpHeight = bitmap.getHeight();
128
      bmpWidth  = bitmap.getWidth();
129

  
130
      monaLisa = new DistortedBitmap(bitmap, 9);
131
      monaLisa.distort( dLeft, pLeft , rLeft );
132
      monaLisa.distort(dRight, pRight, rRight);
98 133

  
99 134
      try
100 135
        {
src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java
103 103
        tmp = (DistortedBitmap)mCircleNode[i].getObject();
104 104
        tmp.move( new Static3D(positions[2*i], positions[2*i+1], 0) );
105 105
        tmp.rotate( mRot, axis, center );
106
        tmp.chroma( new Static1D(0.8f), new Static3D(colors[3*i],colors[3*i+1], colors[3*i+2]) );
106
        tmp.chroma( new Static1D(0.5f), new Static3D(colors[3*i],colors[3*i+1], colors[3*i+2]) );
107 107
        }
108 108
      }
109 109

  
src/main/java/org/distorted/examples/vertex3d/Vertex3DRenderer.java
49 49
    private DistortedBitmap mBackground;
50 50
    private DistortedBitmap mCenter;
51 51
    private DistortedBitmap mRegion;
52
    private int mObjWidth, mObjHeight;
52
    private int mObjWidth, mObjHeight, mObjDepth;
53 53
    private DynamicQuat mQuatInt1, mQuatInt2;
54 54

  
55 55
    private Dynamic3D mCenterInter, mRegionInter;
......
75 75

  
76 76
      mObjWidth = mObject.getWidth();
77 77
      mObjHeight= mObject.getHeight();
78
      mObjDepth = mObject.getDepth();
78 79

  
79 80
      mQuat1 = new Static4D(0,0,0,1);  // unity
80 81
      mQuat2 = new Static4D(0,0,0,1);  // quaternions
......
176 177
      mCenter.quaternion(mQuatInt2, rotateCen);
177 178

  
178 179
      mCenter.move( new Static3D( (width -factorCen*centerSize-mFactorObj*mObjWidth )/2 ,
179
                                  (height-factorCen*centerSize-mFactorObj*mObjHeight)/2 , 10) );
180
                                  (height-factorCen*centerSize-mFactorObj*mObjHeight)/2 , mFactorObj*mObjDepth/2+10) );
180 181
      mCenter.move(mCenterInter);
181 182
      mCenter.scale(factorCen);
182 183

  
......
184 185
      mRegion.quaternion(mQuatInt2, rotateCen);
185 186

  
186 187
      mRegion.move( new Static3D( (width -mFactorObj*mObjWidth )/2 ,
187
                                  (height-mFactorObj*mObjHeight)/2 , 12) );
188
                                  (height-mFactorObj*mObjHeight)/2 , mFactorObj*mObjDepth/2+12) );
188 189
      mRegion.move(mCenterInter);
189 190
      mRegion.move(mRegionInter);
190 191
      mRegion.scale(mRegionScaleInter);

Also available in: Unified diff