Revision c5b1451b
Added by Leszek Koltunski about 9 years ago
| src/main/java/org/distorted/library/Distorted.java | ||
|---|---|---|
| 91 | 91 |
static int mTextureCoordH; // pass in model texture coordinate information. |
| 92 | 92 |
static int mProgramH; // This is a handle to our shading program. |
| 93 | 93 |
|
| 94 |
static DistortedProjection mProjection = new DistortedProjection(false);
|
|
| 94 |
static DistortedProjection mProjection = new DistortedProjection(); |
|
| 95 | 95 |
static float mFOV = 60.0f; |
| 96 | 96 |
|
| 97 | 97 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/library/DistortedNode.java | ||
|---|---|---|
| 248 | 248 |
|
| 249 | 249 |
if( newList.size()>1 && mData.mProjection==null ) |
| 250 | 250 |
{
|
| 251 |
mData.mProjection = new DistortedProjection(true);
|
|
| 251 |
mData.mProjection = new DistortedProjection(); |
|
| 252 | 252 |
mData.mProjection.onSurfaceChanged(mObject.getWidth(), mObject.getHeight()); |
| 253 | 253 |
mData.mFramebufferID = 0; |
| 254 | 254 |
mData.mTextureID = TEXTURE_NOT_CREATED_YET; |
| src/main/java/org/distorted/library/DistortedProjection.java | ||
|---|---|---|
| 29 | 29 |
{
|
| 30 | 30 |
int width,height,depth,distance; |
| 31 | 31 |
float[] projectionMatrix; |
| 32 |
|
|
| 33 |
private boolean invert; // invert top with bottom? We don't do that for the projection to the screen, |
|
| 34 |
// but we need that for the projection to FBOs. (that's because each time we |
|
| 35 |
// render to FBO we invert the texture upside down because its vertex coords |
|
| 36 |
// are purposefully set upside down in DistortedBackground; so each time we |
|
| 37 |
// render through FBO we need to invert it once more to counter this effect) |
|
| 38 | 32 |
|
| 39 | 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 40 | 34 |
|
| 41 |
public DistortedProjection(boolean inv)
|
|
| 35 |
public DistortedProjection()
|
|
| 42 | 36 |
{
|
| 43 |
invert = inv; |
|
| 44 | 37 |
projectionMatrix = new float[16]; |
| 45 | 38 |
} |
| 46 | 39 |
|
| ... | ... | |
| 64 | 57 |
distance = (int)(height*near/(top-bottom)); |
| 65 | 58 |
far = 2*distance-near; |
| 66 | 59 |
|
| 67 |
if( invert ) Matrix.frustumM(projectionMatrix, 0, left, right, top, bottom, near, far); |
|
| 68 |
else Matrix.frustumM(projectionMatrix, 0, left, right, bottom, top, near, far); |
|
| 60 |
Matrix.frustumM(projectionMatrix, 0, left, right, bottom, top, near, far); |
|
| 69 | 61 |
} |
| 70 | 62 |
else // parallel projection |
| 71 | 63 |
{
|
| ... | ... | |
| 73 | 65 |
distance = (int)(height*near/(top-bottom)); |
| 74 | 66 |
far = 2*distance-near; |
| 75 | 67 |
|
| 76 |
if( invert ) Matrix.orthoM(projectionMatrix, 0, -surfaceWidth/2, surfaceWidth/2, surfaceHeight/2,-surfaceHeight/2, near, far); |
|
| 77 |
else Matrix.orthoM(projectionMatrix, 0, -surfaceWidth/2, surfaceWidth/2,-surfaceHeight/2, surfaceHeight/2, near, far); |
|
| 68 |
Matrix.orthoM(projectionMatrix, 0, -surfaceWidth/2, surfaceWidth/2,-surfaceHeight/2, surfaceHeight/2, near, far); |
|
| 78 | 69 |
} |
| 79 | 70 |
|
| 80 | 71 |
depth = (int)((far-near)/2); |
| src/main/java/org/distorted/library/EffectQueueMatrix.java | ||
|---|---|---|
| 227 | 227 |
} |
| 228 | 228 |
} |
| 229 | 229 |
|
| 230 |
Matrix.translateM(viewMatrix, 0, mObjHalfX,-mObjHalfY, -mObjHalfZ);
|
|
| 230 |
Matrix.translateM(viewMatrix, 0, mObjHalfX,-mObjHalfY, 0);
|
|
| 231 | 231 |
Matrix.multiplyMM(mMVPMatrix, 0, dp.projectionMatrix, 0, viewMatrix, 0); |
| 232 | 232 |
|
| 233 | 233 |
GLES20.glUniform3f( mObjDH , mObjHalfX, mObjHalfY, mObjHalfZ); |
| ... | ... | |
| 242 | 242 |
synchronized void sendNoEffects(DistortedProjection dp) |
| 243 | 243 |
{
|
| 244 | 244 |
Matrix.setIdentityM(mTmpMatrix, 0); |
| 245 |
Matrix.translateM(mTmpMatrix, 0, mObjHalfX-dp.width/2, dp.height/2-mObjHalfY, mObjHalfZ-dp.distance);
|
|
| 245 |
Matrix.translateM(mTmpMatrix, 0, mObjHalfX-dp.width/2, dp.height/2-mObjHalfY, -dp.distance); |
|
| 246 | 246 |
Matrix.multiplyMM(mMVPMatrix, 0, dp.projectionMatrix, 0, mTmpMatrix, 0); |
| 247 | 247 |
|
| 248 | 248 |
GLES20.glUniform3f( mObjDH , mObjHalfX, mObjHalfY, mObjHalfZ); |
Also available in: Unified diff
Remove the 'invert' option from DistortedProjection - this was making the DistortedNode-based apps not show the Objects, because the winding of triangles was wrong.
Now however the DistortedNode based stuff is inverted top-down :)