Revision 25eeb4d4
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/examples/girl/GirlActivity.java | ||
|---|---|---|
| 60 | 60 |
barSize.setProgress(50); |
| 61 | 61 |
barHips.setProgress(0); |
| 62 | 62 |
|
| 63 |
textSwing.setText(getString(R.string.swing_placeholder,0)); |
|
| 63 |
textSwing.setText(getString(R.string.swing_placeholder,0.0f));
|
|
| 64 | 64 |
textSize.setText(getString(R.string.size_placeholder,1.0f)); |
| 65 | 65 |
textHips.setText(getString(R.string.hips_placeholder,0)); |
| 66 | 66 |
} |
| ... | ... | |
| 96 | 96 |
DistortedLibrary.onDestroy(); |
| 97 | 97 |
super.onDestroy(); |
| 98 | 98 |
} |
| 99 |
|
|
| 100 |
/////////////////////////////////////////////////////////////////// |
|
| 101 |
|
|
| 99 |
|
|
| 100 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
| 101 |
|
|
| 102 | 102 |
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) |
| 103 | 103 |
{
|
| 104 |
int v;
|
|
| 105 |
float s;
|
|
| 104 |
float v;
|
|
| 105 |
int i;
|
|
| 106 | 106 |
GirlSurfaceView view = findViewById(R.id.girlSurfaceView); |
| 107 | 107 |
|
| 108 | 108 |
switch (bar.getId()) |
| 109 | 109 |
{
|
| 110 |
case R.id.girlSeekSwing: v = progress/5;
|
|
| 110 |
case R.id.girlSeekSwing: v = progress/(5*400.0f);
|
|
| 111 | 111 |
view.getRenderer().setSwing(v); |
| 112 | 112 |
textSwing.setText(getString(R.string.swing_placeholder,v)); |
| 113 | 113 |
break; |
| 114 |
case R.id.girlSeekSize : if( progress> 50) s = (progress-50)/16.0f + 1.0f;
|
|
| 115 |
else s = 0.015f*progress + 0.25f;
|
|
| 116 |
view.getRenderer().setSize(s);
|
|
| 117 |
textSize.setText(getString(R.string.size_placeholder,(((int)(s*10))/10.0f)));
|
|
| 114 |
case R.id.girlSeekSize : if( progress> 50) v = (progress-50)/18.0f + 1.0f;
|
|
| 115 |
else v = 0.015f*progress + 0.25f;
|
|
| 116 |
view.getRenderer().setSize(v);
|
|
| 117 |
textSize.setText(getString(R.string.size_placeholder,v));
|
|
| 118 | 118 |
break; |
| 119 |
case R.id.girlSeekHips : v = progress/5;
|
|
| 120 |
view.getRenderer().setHips(v);
|
|
| 121 |
textHips.setText(getString(R.string.hips_placeholder,v));
|
|
| 119 |
case R.id.girlSeekHips : i = progress/6;
|
|
| 120 |
view.getRenderer().setHips(i);
|
|
| 121 |
textHips.setText(getString(R.string.hips_placeholder,i));
|
|
| 122 | 122 |
break; |
| 123 | 123 |
} |
| 124 | 124 |
} |
| 125 | 125 |
|
| 126 |
/////////////////////////////////////////////////////////////////// |
|
| 126 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
| 127 | 127 |
|
| 128 | 128 |
public void onStartTrackingTouch(SeekBar bar) { }
|
| 129 |
|
|
| 130 |
/////////////////////////////////////////////////////////////////// |
|
| 129 |
|
|
| 130 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
| 131 | 131 |
|
| 132 | 132 |
public void onStopTrackingTouch(SeekBar bar) { }
|
| 133 | 133 |
|
| src/main/java/org/distorted/examples/girl/GirlRenderer.java | ||
|---|---|---|
| 58 | 58 |
private Static3D v0,v1,v2,v3; |
| 59 | 59 |
private Static1D dBegin, dMiddle, dEnd, s0; |
| 60 | 60 |
private Static3D mScale; |
| 61 |
private float mBmpRatio; |
|
| 61 | 62 |
|
| 62 | 63 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 64 |
// girl bitmap: 400x600 |
|
| 63 | 65 |
|
| 64 | 66 |
GirlRenderer(GLSurfaceView v) |
| 65 | 67 |
{
|
| 66 | 68 |
mView = v; |
| 67 | 69 |
|
| 68 |
Static3D pLeft = new Static3D(-68, 36, 0);
|
|
| 69 |
Static3D pRight= new Static3D( 47, 36, 0);
|
|
| 70 |
Static3D pLeft = new Static3D(-68/400.0f, 36/600.0f, 0);
|
|
| 71 |
Static3D pRight= new Static3D( 47/400.0f, 36/600.0f, 0);
|
|
| 70 | 72 |
|
| 71 | 73 |
// Size |
| 72 |
Static4D sinkRegion = new Static4D(0,0,0,60); |
|
| 74 |
Static4D sinkRegion = new Static4D(0,0,0,60/400.0f);
|
|
| 73 | 75 |
|
| 74 | 76 |
s0 = new Static1D(1.0f); |
| 75 | 77 |
|
| ... | ... | |
| 77 | 79 |
diSink.add(s0); |
| 78 | 80 |
|
| 79 | 81 |
// Upper Movement |
| 80 |
Static4D Region = new Static4D(0,0,0,45); |
|
| 82 |
Static4D Region = new Static4D(0,0,0,45/400.0f);
|
|
| 81 | 83 |
|
| 82 | 84 |
Dynamic3D diL = new Dynamic3D(1000,0.0f); |
| 83 | 85 |
Dynamic3D diR = new Dynamic3D(1000,0.0f); |
| ... | ... | |
| 98 | 100 |
diR.add(v1); |
| 99 | 101 |
|
| 100 | 102 |
// Lower Movement |
| 101 |
Static3D pHips = new Static3D( 16,-205,0);
|
|
| 102 |
Static4D HipsRegion = new Static4D(0,0,0,120); |
|
| 103 |
Static3D pHips = new Static3D( 16/400.0f,-205/600.0f,0);
|
|
| 104 |
Static4D HipsRegion = new Static4D(0,0,0,120/400.0f);
|
|
| 103 | 105 |
Dynamic1D diHips = new Dynamic1D(1500,0.0f); |
| 104 | 106 |
|
| 105 | 107 |
dBegin = new Static1D(0); |
| ... | ... | |
| 124 | 126 |
mScale= new Static3D(1,1,1); |
| 125 | 127 |
mEffects.apply(new MatrixEffectScale(mScale)); |
| 126 | 128 |
|
| 129 |
mTexture = new DistortedTexture(); |
|
| 127 | 130 |
mScreen = new DistortedScreen(); |
| 128 | 131 |
} |
| 129 | 132 |
|
| ... | ... | |
| 144 | 147 |
|
| 145 | 148 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 146 | 149 |
|
| 147 |
void setSwing(int swing)
|
|
| 150 |
void setSwing(float swing)
|
|
| 148 | 151 |
{
|
| 149 | 152 |
v0.set( 0, swing, 0); |
| 150 | 153 |
v1.set( swing, 0, 0); |
| ... | ... | |
| 163 | 166 |
|
| 164 | 167 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
| 165 | 168 |
{
|
| 166 |
float horiRatio = (float)width / mMesh.getStretchX(); |
|
| 167 |
float vertRatio = (float)height/ mMesh.getStretchY(); |
|
| 168 |
float factor = horiRatio > vertRatio ? vertRatio : horiRatio; |
|
| 169 |
float min= width>height ? height : width; |
|
| 169 | 170 |
|
| 170 |
mScale.set( factor,factor,factor );
|
|
| 171 |
mScale.set( min, min*mBmpRatio, min );
|
|
| 171 | 172 |
mScreen.resize(width, height); |
| 172 | 173 |
} |
| 173 | 174 |
|
| ... | ... | |
| 191 | 192 |
catch(IOException e) { }
|
| 192 | 193 |
} |
| 193 | 194 |
|
| 194 |
int bmpHeight = bitmap.getHeight(); |
|
| 195 |
int bmpWidth = bitmap.getWidth(); |
|
| 196 |
|
|
| 197 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
|
| 195 |
mBmpRatio = (float)bitmap.getHeight()/bitmap.getWidth(); |
|
| 198 | 196 |
mTexture.setTexture(bitmap); |
| 199 | 197 |
|
| 200 |
if( mMesh==null ) |
|
| 201 |
{
|
|
| 202 |
mMesh = new MeshRectangles(30,30*bmpHeight/bmpWidth); |
|
| 203 |
mMesh.setStretch(bmpWidth,bmpHeight,0); |
|
| 204 |
} |
|
| 198 |
if( mMesh==null ) mMesh = new MeshRectangles(30, (int)(30*mBmpRatio)); |
|
| 205 | 199 |
|
| 206 | 200 |
mScreen.detachAll(); |
| 207 | 201 |
mScreen.attach(mTexture,mEffects,mMesh); |
| src/main/res/values/strings.xml | ||
|---|---|---|
| 104 | 104 |
<string name="amplitude_placeholder">Amplitu %1$d</string> |
| 105 | 105 |
<string name="alpha_placeholder">Alpha %1$d</string> |
| 106 | 106 |
<string name="beta_placeholder">Beta %1$d</string> |
| 107 |
<string name="swing_placeholder">Swing %1$d</string>
|
|
| 108 |
<string name="size_placeholder">Size %1$.1f</string>
|
|
| 107 |
<string name="swing_placeholder">Swing %1$.3f</string>
|
|
| 108 |
<string name="size_placeholder">Size %1$.3f</string>
|
|
| 109 | 109 |
<string name="hips_placeholder">Hips %1$d</string> |
| 110 | 110 |
<string name="fov_placeholder">FOV: %1$d</string> |
| 111 | 111 |
<string name="near_placeholder">Near: %1$.2f</string> |
Also available in: Unified diff
Port Girl to the new setStretch-less API.