Revision 16b336db
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java | ||
|---|---|---|
| 50 | 50 |
|
| 51 | 51 |
class MeshFileRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener |
| 52 | 52 |
{
|
| 53 |
private final float DEFAULT_SCALE = 0.3f; |
|
| 54 |
|
|
| 53 | 55 |
private GLSurfaceView mView; |
| 54 | 56 |
private DistortedTexture mTexture; |
| 55 | 57 |
private DistortedScreen mScreen; |
| ... | ... | |
| 58 | 60 |
private long mTime; |
| 59 | 61 |
private int mBytes; |
| 60 | 62 |
private int mVertices; |
| 63 |
private float mCurrentScale; |
|
| 61 | 64 |
|
| 62 | 65 |
Static4D mQuat1, mQuat2; |
| 63 | 66 |
int mScreenMin; |
| ... | ... | |
| 71 | 74 |
mScale= new Static3D(1,1,1); |
| 72 | 75 |
Static3D center=new Static3D(0,0,0); |
| 73 | 76 |
|
| 77 |
mCurrentScale = DEFAULT_SCALE; |
|
| 78 |
|
|
| 74 | 79 |
mQuat1 = new Static4D(0,0,0,1); |
| 75 | 80 |
mQuat2 = new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f); |
| 76 | 81 |
|
| ... | ... | |
| 100 | 105 |
|
| 101 | 106 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
| 102 | 107 |
{
|
| 103 |
final float SCALE = 0.3f; |
|
| 104 | 108 |
mScreenMin = Math.min(width, height); |
| 105 |
float factor = SCALE*mScreenMin;
|
|
| 109 |
float factor = mCurrentScale*mScreenMin;
|
|
| 106 | 110 |
mScale.set(factor,factor,factor); |
| 107 | 111 |
mScreen.resize(width, height); |
| 108 | 112 |
} |
| ... | ... | |
| 123 | 127 |
android.util.Log.e("MeshFile", ex.getMessage() );
|
| 124 | 128 |
} |
| 125 | 129 |
|
| 130 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 131 |
// 0 ---> 0 |
|
| 132 |
// 50 ---> DEFAULT_SCALE |
|
| 133 |
// 100 ---> 4*DEFAULT_SCALE |
|
| 134 |
|
|
| 135 |
void setScale(int scale) |
|
| 136 |
{
|
|
| 137 |
if( scale<= 50 ) |
|
| 138 |
{
|
|
| 139 |
mCurrentScale = DEFAULT_SCALE * scale / 50.0f; |
|
| 140 |
} |
|
| 141 |
else |
|
| 142 |
{
|
|
| 143 |
mCurrentScale = DEFAULT_SCALE * ( 3*(scale/50.0f) - 2.0f); |
|
| 144 |
} |
|
| 145 |
|
|
| 146 |
float factor = mCurrentScale*mScreenMin; |
|
| 147 |
mScale.set(factor,factor,factor); |
|
| 148 |
} |
|
| 149 |
|
|
| 126 | 150 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 127 | 151 |
|
| 128 | 152 |
void open(int resourceID) |
Also available in: Unified diff
Add a 'Scale' seekBar to the MeshFile app.