Revision e8e54972
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/examples/deform/DeformRenderer.java | ||
|---|---|---|
| 246 | 246 |
case DISTORT: vDistort[0].set(0,0,0); |
| 247 | 247 |
mEffects.apply(mMovingDistort); |
| 248 | 248 |
mLastEffect = mMovingDistort.getID(); |
| 249 |
mTouchPoint.set(xt,yt,0); |
|
| 249 | 250 |
break; |
| 250 | 251 |
case DEFORM : vDeform[0].set(0,0,0); |
| 251 | 252 |
mEffects.apply(mMovingDeform); |
| 252 | 253 |
mLastEffect = mMovingDeform.getID(); |
| 254 |
mTouchPoint.set(xt,yt,0); |
|
| 253 | 255 |
break; |
| 254 | 256 |
case SHEAR : vShear[0].set(0,0,0); |
| 255 | 257 |
mEffects.apply(mMovingShear); |
| 256 | 258 |
mLastEffect = mMovingShear.getID(); |
| 259 |
mTouchPoint.set(xt-textureWidth/2,yt-textureHeight/2,0); |
|
| 257 | 260 |
break; |
| 258 | 261 |
} |
| 259 | 262 |
} |
| src/main/java/org/distorted/examples/generic/Effects3DActivity.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2016 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Distorted. // |
|
| 5 |
// // |
|
| 6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Distorted is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.examples.generic; |
|
| 21 |
|
|
| 22 |
import android.app.Activity; |
|
| 23 |
import android.content.Intent; |
|
| 24 |
import android.os.Bundle; |
|
| 25 |
import android.view.Gravity; |
|
| 26 |
import android.view.View; |
|
| 27 |
import android.widget.AdapterView; |
|
| 28 |
import android.widget.ArrayAdapter; |
|
| 29 |
import android.widget.Button; |
|
| 30 |
import android.widget.LinearLayout; |
|
| 31 |
import android.widget.NumberPicker; |
|
| 32 |
import android.widget.Spinner; |
|
| 33 |
import android.widget.TableRow; |
|
| 34 |
|
|
| 35 |
import org.distorted.examples.R; |
|
| 36 |
|
|
| 37 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 38 |
|
|
| 39 |
public class Effects3DActivity extends Activity |
|
| 40 |
implements View.OnClickListener, AdapterView.OnItemSelectedListener |
|
| 41 |
{
|
|
| 42 |
private static final int COLOR_OFF = 0xffffe81f; |
|
| 43 |
private static final int COLOR_ON = 0xff0000ff; |
|
| 44 |
private static final int COLOR_INAC= 0xff999999; |
|
| 45 |
|
|
| 46 |
private int mNumCols = 1; |
|
| 47 |
private int mNumRows = 1; |
|
| 48 |
private int mNumSlic = 1; |
|
| 49 |
private boolean mGridInitialized; |
|
| 50 |
private NumberPicker mColsPicker, mRowsPicker, mSlicPicker; |
|
| 51 |
private boolean[] mShape; |
|
| 52 |
private int mObjectType; |
|
| 53 |
private int mBitmapID; |
|
| 54 |
private LinearLayout mLay; |
|
| 55 |
|
|
| 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 57 |
|
|
| 58 |
@Override |
|
| 59 |
protected void onCreate(Bundle savedState) |
|
| 60 |
{
|
|
| 61 |
super.onCreate(savedState); |
|
| 62 |
|
|
| 63 |
setContentView(R.layout.objectpickerlayout); |
|
| 64 |
|
|
| 65 |
mLay = findViewById(R.id.objectpicker_buttongrid); |
|
| 66 |
|
|
| 67 |
mColsPicker = findViewById(R.id.objectpicker_cols); |
|
| 68 |
mRowsPicker = findViewById(R.id.objectpicker_rows); |
|
| 69 |
mSlicPicker = findViewById(R.id.objectpicker_slices); |
|
| 70 |
|
|
| 71 |
mColsPicker.setMaxValue(40); |
|
| 72 |
mColsPicker.setMinValue( 1); |
|
| 73 |
mRowsPicker.setMaxValue(40); |
|
| 74 |
mRowsPicker.setMinValue( 1); |
|
| 75 |
mSlicPicker.setMaxValue(40); |
|
| 76 |
mSlicPicker.setMinValue( 0); |
|
| 77 |
|
|
| 78 |
mColsPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() |
|
| 79 |
{
|
|
| 80 |
@Override |
|
| 81 |
public void onValueChange(NumberPicker picker, int oldVal, int newVal) |
|
| 82 |
{
|
|
| 83 |
setGrid(); |
|
| 84 |
} |
|
| 85 |
}); |
|
| 86 |
|
|
| 87 |
mRowsPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() |
|
| 88 |
{
|
|
| 89 |
@Override |
|
| 90 |
public void onValueChange(NumberPicker picker, int oldVal, int newVal) |
|
| 91 |
{
|
|
| 92 |
setGrid(); |
|
| 93 |
} |
|
| 94 |
}); |
|
| 95 |
|
|
| 96 |
mSlicPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() |
|
| 97 |
{
|
|
| 98 |
@Override |
|
| 99 |
public void onValueChange(NumberPicker picker, int oldVal, int newVal) |
|
| 100 |
{
|
|
| 101 |
mNumSlic = mSlicPicker.getValue(); |
|
| 102 |
} |
|
| 103 |
}); |
|
| 104 |
|
|
| 105 |
mObjectType = 0; |
|
| 106 |
mGridInitialized = false; |
|
| 107 |
|
|
| 108 |
Spinner typeSpinner = findViewById(R.id.objectpicker_spinnerType); |
|
| 109 |
typeSpinner.setOnItemSelectedListener(this); |
|
| 110 |
|
|
| 111 |
String[] objectType = new String[] {"Mesh: Cubes", "Mesh: Flat", "Mesh: Sphere", "Mesh: Quad"};
|
|
| 112 |
|
|
| 113 |
ArrayAdapter<String> adapterType = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, objectType); |
|
| 114 |
adapterType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|
| 115 |
typeSpinner.setAdapter(adapterType); |
|
| 116 |
|
|
| 117 |
Spinner bitmapSpinner = findViewById(R.id.objectpicker_spinnerBitmap); |
|
| 118 |
bitmapSpinner.setOnItemSelectedListener(this); |
|
| 119 |
|
|
| 120 |
String[] objectBitmap = new String[] { "Texture: Grid", "Texture: Girl", "Texture: Dog", "Texture: Cat",
|
|
| 121 |
"Texture: Squares", "Texture: Bean", "Texture: Lisa", "Texture: World" }; |
|
| 122 |
|
|
| 123 |
ArrayAdapter<String> adapterBitmap = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, objectBitmap); |
|
| 124 |
adapterBitmap.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|
| 125 |
bitmapSpinner.setAdapter(adapterBitmap); |
|
| 126 |
} |
|
| 127 |
|
|
| 128 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 129 |
|
|
| 130 |
private void setGrid() |
|
| 131 |
{
|
|
| 132 |
mGridInitialized = true; |
|
| 133 |
|
|
| 134 |
mNumCols = mColsPicker.getValue(); |
|
| 135 |
mNumRows = mRowsPicker.getValue(); |
|
| 136 |
|
|
| 137 |
int width = mLay.getWidth(); |
|
| 138 |
int height= mLay.getHeight(); |
|
| 139 |
int w = mNumCols>0 ? (int)( 0.9f*width / mNumCols) : 0; |
|
| 140 |
int h = mNumRows>0 ? (int)( 0.9f*height/ mNumRows) : 0; |
|
| 141 |
int size= w<h ? w:h; |
|
| 142 |
int pad = size<20 ? 1 : size/20; |
|
| 143 |
|
|
| 144 |
mLay.removeAllViews(); |
|
| 145 |
|
|
| 146 |
mShape = new boolean[mNumRows*mNumCols]; |
|
| 147 |
|
|
| 148 |
TableRow.LayoutParams p = new TableRow.LayoutParams(); |
|
| 149 |
|
|
| 150 |
p.rightMargin = pad; |
|
| 151 |
p.leftMargin = pad; |
|
| 152 |
p.topMargin = pad; |
|
| 153 |
p.bottomMargin = pad; |
|
| 154 |
p.height = size; |
|
| 155 |
p.width = size; |
|
| 156 |
|
|
| 157 |
for (int rows=0; rows<mNumRows; rows++) |
|
| 158 |
{
|
|
| 159 |
TableRow tr = new TableRow(this); |
|
| 160 |
tr.setGravity(Gravity.CENTER); |
|
| 161 |
|
|
| 162 |
for(int cols=0; cols<mNumCols; cols++) |
|
| 163 |
{
|
|
| 164 |
Button b = new Button(this); |
|
| 165 |
b.setOnClickListener(this); |
|
| 166 |
b.setId(rows*mNumCols+cols); |
|
| 167 |
b.setLayoutParams(p); |
|
| 168 |
b.setBackgroundColor(mObjectType==0 ? COLOR_ON:COLOR_INAC); |
|
| 169 |
tr.addView(b, p); |
|
| 170 |
mShape[rows*mNumCols+cols] = true; |
|
| 171 |
} |
|
| 172 |
|
|
| 173 |
mLay.addView(tr); |
|
| 174 |
} |
|
| 175 |
} |
|
| 176 |
|
|
| 177 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 178 |
|
|
| 179 |
public void onClick(View view) |
|
| 180 |
{
|
|
| 181 |
if( mObjectType==0 ) // cubes |
|
| 182 |
{
|
|
| 183 |
Button tmp = (Button)view; |
|
| 184 |
int id = tmp.getId(); |
|
| 185 |
mShape[id] = !mShape[id]; |
|
| 186 |
tmp.setBackgroundColor(mShape[id] ? COLOR_ON:COLOR_OFF); |
|
| 187 |
} |
|
| 188 |
} |
|
| 189 |
|
|
| 190 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 191 |
|
|
| 192 |
private void uncheckAll() |
|
| 193 |
{
|
|
| 194 |
TableRow tr; |
|
| 195 |
Button butt; |
|
| 196 |
|
|
| 197 |
for (int row=0; row<mNumRows; row++) |
|
| 198 |
{
|
|
| 199 |
tr = (TableRow)mLay.getChildAt(row); |
|
| 200 |
|
|
| 201 |
if( tr!=null ) |
|
| 202 |
{
|
|
| 203 |
for(int col=0; col<mNumCols; col++) |
|
| 204 |
{
|
|
| 205 |
butt = (Button)tr.getVirtualChildAt(col); |
|
| 206 |
butt.setBackgroundColor(mObjectType==0 ? COLOR_ON : COLOR_INAC); |
|
| 207 |
mShape[row*mNumCols+col] = true; |
|
| 208 |
} |
|
| 209 |
} |
|
| 210 |
} |
|
| 211 |
} |
|
| 212 |
|
|
| 213 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 214 |
|
|
| 215 |
public void Create(View v) |
|
| 216 |
{
|
|
| 217 |
Intent mainInt = new Intent( getApplicationContext(), Effects3DActivity2.class); |
|
| 218 |
Bundle b = new Bundle(); |
|
| 219 |
|
|
| 220 |
int rows=0, cols=0; |
|
| 221 |
|
|
| 222 |
switch(mObjectType) |
|
| 223 |
{
|
|
| 224 |
case 0: |
|
| 225 |
case 1: rows = mNumRows; |
|
| 226 |
cols = mNumCols; |
|
| 227 |
break; |
|
| 228 |
case 2: rows = mNumRows; // always make the sphere equal in X and Y |
|
| 229 |
cols = mNumRows; // |
|
| 230 |
break; |
|
| 231 |
case 3: rows = 1; // a quad is always 1x1 |
|
| 232 |
cols = 1; |
|
| 233 |
break; |
|
| 234 |
} |
|
| 235 |
|
|
| 236 |
b.putInt("type", mObjectType);
|
|
| 237 |
b.putInt("cols", cols);
|
|
| 238 |
b.putInt("rows", rows);
|
|
| 239 |
b.putInt("slices", mNumSlic);
|
|
| 240 |
b.putInt("bitmap", mBitmapID);
|
|
| 241 |
|
|
| 242 |
if( mObjectType==0 ) // cubes |
|
| 243 |
{
|
|
| 244 |
String str = ""; |
|
| 245 |
|
|
| 246 |
for(int i=0; i<mNumRows*mNumCols; i++) |
|
| 247 |
str += mShape[i] ? "1" : "0"; |
|
| 248 |
|
|
| 249 |
b.putString("string", str);
|
|
| 250 |
} |
|
| 251 |
else |
|
| 252 |
{
|
|
| 253 |
b.putString("string", "");
|
|
| 254 |
} |
|
| 255 |
|
|
| 256 |
mainInt.putExtras(b); |
|
| 257 |
startActivity(mainInt); |
|
| 258 |
} |
|
| 259 |
|
|
| 260 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 261 |
|
|
| 262 |
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) |
|
| 263 |
{
|
|
| 264 |
switch(parent.getId()) |
|
| 265 |
{
|
|
| 266 |
case R.id.objectpicker_spinnerType : if( mObjectType!=pos ) |
|
| 267 |
{
|
|
| 268 |
mObjectType = pos; |
|
| 269 |
uncheckAll(); |
|
| 270 |
|
|
| 271 |
switch(mObjectType) |
|
| 272 |
{
|
|
| 273 |
case 0: mColsPicker.setEnabled(true); |
|
| 274 |
mRowsPicker.setEnabled(true); |
|
| 275 |
mSlicPicker.setEnabled(true); |
|
| 276 |
break; |
|
| 277 |
case 1: mColsPicker.setEnabled(true); |
|
| 278 |
mRowsPicker.setEnabled(true); |
|
| 279 |
mSlicPicker.setEnabled(false); |
|
| 280 |
break; |
|
| 281 |
case 2: mColsPicker.setEnabled(false); |
|
| 282 |
mRowsPicker.setEnabled(true); |
|
| 283 |
mSlicPicker.setEnabled(false); |
|
| 284 |
break; |
|
| 285 |
case 3: mColsPicker.setEnabled(false); |
|
| 286 |
mRowsPicker.setEnabled(false); |
|
| 287 |
mSlicPicker.setEnabled(false); |
|
| 288 |
break; |
|
| 289 |
} |
|
| 290 |
} |
|
| 291 |
break; |
|
| 292 |
case R.id.objectpicker_spinnerBitmap: switch(pos) |
|
| 293 |
{
|
|
| 294 |
case 0: mBitmapID = -1 ; break; |
|
| 295 |
case 1: mBitmapID = R.raw.face ; break; |
|
| 296 |
case 2: mBitmapID = R.raw.dog ; break; |
|
| 297 |
case 3: mBitmapID = R.raw.cat ; break; |
|
| 298 |
case 4: mBitmapID = R.raw.grid ; break; |
|
| 299 |
case 5: mBitmapID = R.raw.bean ; break; |
|
| 300 |
case 6: mBitmapID = R.raw.monalisa; break; |
|
| 301 |
case 7: mBitmapID = R.raw.world ; break; |
|
| 302 |
} |
|
| 303 |
break; |
|
| 304 |
} |
|
| 305 |
} |
|
| 306 |
|
|
| 307 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 308 |
|
|
| 309 |
public void onNothingSelected(AdapterView<?> parent) |
|
| 310 |
{
|
|
| 311 |
} |
|
| 312 |
|
|
| 313 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 314 |
// Overrides |
|
| 315 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 316 |
|
|
| 317 |
@Override |
|
| 318 |
public void onWindowFocusChanged(boolean hasFocus) |
|
| 319 |
{
|
|
| 320 |
super.onWindowFocusChanged(hasFocus); |
|
| 321 |
|
|
| 322 |
mColsPicker.setValue(mNumCols); |
|
| 323 |
mRowsPicker.setValue(mNumRows); |
|
| 324 |
mSlicPicker.setValue(mNumSlic); |
|
| 325 |
|
|
| 326 |
if( !mGridInitialized ) setGrid(); |
|
| 327 |
} |
|
| 328 |
} |
|
| src/main/java/org/distorted/examples/generic/Effects3DTabViewPager.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2018 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Distorted. // |
|
| 5 |
// // |
|
| 6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Distorted is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.examples.generic; |
|
| 21 |
|
|
| 22 |
import android.support.v4.app.Fragment; |
|
| 23 |
import android.support.v4.app.FragmentManager; |
|
| 24 |
import android.support.v4.app.FragmentPagerAdapter; |
|
| 25 |
import android.os.Bundle; |
|
| 26 |
|
|
| 27 |
import org.distorted.examples.R; |
|
| 28 |
|
|
| 29 |
import java.lang.ref.WeakReference; |
|
| 30 |
|
|
| 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 32 |
|
|
| 33 |
public class Effects3DTabViewPager extends FragmentPagerAdapter |
|
| 34 |
{
|
|
| 35 |
private WeakReference<Effects3DActivity2> mAct; |
|
| 36 |
|
|
| 37 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 38 |
|
|
| 39 |
Effects3DTabViewPager(Effects3DActivity2 act, FragmentManager fm) |
|
| 40 |
{
|
|
| 41 |
super(fm); |
|
| 42 |
mAct = new WeakReference<>(act); |
|
| 43 |
} |
|
| 44 |
|
|
| 45 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 46 |
|
|
| 47 |
@Override |
|
| 48 |
public Fragment getItem(int position) |
|
| 49 |
{
|
|
| 50 |
if( position>=0 && position<Effects3DActivity2.NUM_TABS ) |
|
| 51 |
{
|
|
| 52 |
Effects3DTab tab = new Effects3DTab(); |
|
| 53 |
|
|
| 54 |
Bundle bundle = new Bundle(); |
|
| 55 |
bundle.putInt("position", position);
|
|
| 56 |
tab.setArguments(bundle); |
|
| 57 |
|
|
| 58 |
return tab; |
|
| 59 |
} |
|
| 60 |
|
|
| 61 |
return null; |
|
| 62 |
} |
|
| 63 |
|
|
| 64 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 65 |
|
|
| 66 |
@Override |
|
| 67 |
public int getCount() |
|
| 68 |
{
|
|
| 69 |
return Effects3DActivity2.NUM_TABS; |
|
| 70 |
} |
|
| 71 |
|
|
| 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 73 |
|
|
| 74 |
@Override |
|
| 75 |
public CharSequence getPageTitle(int position) |
|
| 76 |
{
|
|
| 77 |
switch (position) |
|
| 78 |
{
|
|
| 79 |
case 0 : return mAct.get().getString(R.string.type_matrix); |
|
| 80 |
case 1 : return mAct.get().getString(R.string.type_vertex); |
|
| 81 |
case 2 : return mAct.get().getString(R.string.type_fragment); |
|
| 82 |
case 3 : return mAct.get().getString(R.string.type_postprocess); |
|
| 83 |
default: return null; |
|
| 84 |
} |
|
| 85 |
} |
|
| 86 |
} |
|
| src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java | ||
|---|---|---|
| 132 | 132 |
for(int j=0; j<NUM_LEAVES; j++) |
| 133 | 133 |
{
|
| 134 | 134 |
mEffects[j] = new DistortedEffects(); |
| 135 |
mEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, center) ); |
|
| 136 | 135 |
mEffects[j].apply(new MatrixEffectMove(moveVector)); |
| 136 |
mEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, center) ); |
|
| 137 | 137 |
} |
| 138 | 138 |
|
| 139 | 139 |
for(int i=0; i<NUM_CIRCLES; i++) |
| 140 | 140 |
{
|
| 141 | 141 |
DistortedEffects effects = new DistortedEffects(); |
| 142 |
effects.apply( new MatrixEffectMove(new Static3D(positions[2*i], positions[2*i+1], 0)) ); |
|
| 143 | 142 |
effects.apply( new MatrixEffectRotate(rot, axis, center) ); |
| 143 |
effects.apply( new MatrixEffectMove(new Static3D(positions[2*i], positions[2*i+1], 0)) ); |
|
| 144 | 144 |
effects.apply( new FragmentEffectChroma(new Static1D(0.5f), new Static3D(colors[3*i],colors[3*i+1], colors[3*i+2])) ); |
| 145 | 145 |
|
| 146 | 146 |
mCircleNode[i] = new DistortedNode( surface, effects, circleMesh); |
| src/main/java/org/distorted/examples/quaternion/QuaternionRenderer.java | ||
|---|---|---|
| 104 | 104 |
|
| 105 | 105 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
| 106 | 106 |
{
|
| 107 |
float w = mTexture.getWidth(); |
|
| 108 |
float h = mTexture.getHeight(); |
|
| 109 |
float factor = 0.5f*(width>height ? height/h:width/w); |
|
| 107 |
float factor = 0.5f*(width>height ? height:width); |
|
| 110 | 108 |
|
| 111 | 109 |
mScale.set(factor,factor,factor); |
| 112 | 110 |
mScreen.resize(width, height); |
| src/main/java/org/distorted/examples/starwars/StarWarsRenderer.java | ||
|---|---|---|
| 214 | 214 |
if( mCrawlBackgroundTexture!=null ) mCrawlBackgroundTexture.markForDeletion(); |
| 215 | 215 |
mCrawlBackgroundTexture = new DistortedTexture(); |
| 216 | 216 |
|
| 217 |
mCrawlBackgroundQuad.setStretch(scrW,(int)(scrH*Math.sin(angleA)/Math.sin(angleB)),0); |
|
| 218 |
|
|
| 217 | 219 |
int randomA, randomX, randomY, randomTime; |
| 218 | 220 |
float randomS, randomAlpha1, randomAlpha2; |
| 219 | 221 |
|
| ... | ... | |
| 230 | 232 |
randomAlpha1 = 0.2f + 0.8f*mRnd.nextFloat(); |
| 231 | 233 |
randomAlpha2 = 0.8f + 0.2f*mRnd.nextFloat(); |
| 232 | 234 |
randomTime = 500+mRnd.nextInt(2000); |
| 233 |
|
|
| 234 |
mStarEffects[i].apply( new MatrixEffectMove(new Static3D(randomX,randomY,0)) ); |
|
| 235 |
mStarEffects[i].apply( new MatrixEffectScale(randomS) ); |
|
| 235 |
|
|
| 236 | 236 |
mStarEffects[i].apply( new MatrixEffectRotate(new Static1D(randomA), axis, center) ); |
| 237 |
|
|
| 237 |
mStarEffects[i].apply( new MatrixEffectScale(randomS) ); |
|
| 238 |
mStarEffects[i].apply( new MatrixEffectMove(new Static3D(randomX,randomY,0)) ); |
|
| 239 |
|
|
| 238 | 240 |
Dynamic1D di = new Dynamic1D(randomTime,0.0f); |
| 239 | 241 |
di.setNoise(alphaNoise); |
| 240 | 242 |
di.add(new Static1D(randomAlpha1)); |
| ... | ... | |
| 245 | 247 |
mScreen.attach(mStarTexture, mStarEffects[i], mStarQuad); |
| 246 | 248 |
} |
| 247 | 249 |
|
| 248 |
float scale = (0.5f*scrW/mGFFATexture.getWidth());
|
|
| 250 |
float scale = (0.5f*scrW/mGFFAQuad.getStretchX());
|
|
| 249 | 251 |
|
| 250 | 252 |
Dynamic1D di = new Dynamic1D(6000,0.5f); |
| 251 | 253 |
di.add(new Static1D(1.0f)); |
| 252 | 254 |
di.add(new Static1D(1.0f)); |
| 253 | 255 |
di.add(new Static1D(0.0f)); |
| 254 |
|
|
| 255 |
mGFFAEffects.apply( new MatrixEffectMove(new Static3D(-scrW/3 + mGFFATexture.getWidth()/2 ,scrH/6,0)) ); |
|
| 256 |
|
|
| 257 |
FragmentEffectAlpha alpha = new FragmentEffectAlpha(di); |
|
| 258 |
alpha.notifyWhenFinished(this); |
|
| 259 |
alphaEffectID = alpha.getID(); |
|
| 260 |
|
|
| 256 | 261 |
mGFFAEffects.apply( new MatrixEffectScale(scale) ); |
| 257 |
mGFFAEffects.apply( new FragmentEffectAlpha(di) ); |
|
| 262 |
mGFFAEffects.apply( new MatrixEffectMove(new Static3D(-scrW/3 + mGFFAQuad.getStretchX()/2 ,scrH/6,0)) ); |
|
| 263 |
mGFFAEffects.apply( alpha ); |
|
| 258 | 264 |
|
| 259 | 265 |
mScreen.attach(mGFFATexture, mGFFAEffects, mGFFAQuad); |
| 260 | 266 |
} |
| ... | ... | |
| 381 | 387 |
mScreen.detach(mGFFAEffects); |
| 382 | 388 |
mGFFATexture.markForDeletion(); |
| 383 | 389 |
|
| 384 |
int screenW=mScreen.getWidth();
|
|
| 390 |
int screenW = mScreen.getWidth();
|
|
| 385 | 391 |
float logoW = mLogoQuad.getStretchX(); |
| 386 | 392 |
int initSize= (int)(3.0f*screenW/logoW); |
| 387 | 393 |
int finaSize= (int)(0.1f*screenW/logoW); |
| ... | ... | |
| 389 | 395 |
Dynamic3D di = new Dynamic3D(10000,0.5f); |
| 390 | 396 |
di.add(new Static3D(initSize,initSize,1)); |
| 391 | 397 |
di.add(new Static3D(finaSize,finaSize,1)); |
| 392 |
|
|
| 393 | 398 |
MatrixEffectScale scale = new MatrixEffectScale(di); |
| 394 | 399 |
scale.notifyWhenFinished(this); |
| 395 | 400 |
scaleEffectID = scale.getID(); |
| ... | ... | |
| 401 | 406 |
mScreen.detach(mLogoEffects); |
| 402 | 407 |
mLogoTexture.markForDeletion(); |
| 403 | 408 |
|
| 404 |
int crawlW = mCrawlTexture.getWidth();
|
|
| 405 |
int crawlH = mCrawlTexture.getHeight();
|
|
| 406 |
int screenW= mScreen.getWidth();
|
|
| 407 |
int screenH= mScreen.getHeight();
|
|
| 408 |
int backW = mCrawlBackgroundTexture.getWidth();
|
|
| 409 |
int backH = mCrawlBackgroundTexture.getHeight();
|
|
| 410 |
float scale= (float)backW/crawlW;
|
|
| 409 |
float crawlW = mCrawlQuad.getStretchX();
|
|
| 410 |
float crawlH = mCrawlQuad.getStretchY();
|
|
| 411 |
float screenW= mScreen.getWidth();
|
|
| 412 |
float screenH= mScreen.getHeight();
|
|
| 413 |
float backW = mCrawlBackgroundQuad.getStretchX();
|
|
| 414 |
float backH = mCrawlBackgroundQuad.getStretchY();
|
|
| 415 |
float scale = backW/crawlW;
|
|
| 411 | 416 |
|
| 412 |
mCrawlBackgroundEffects.apply( new MatrixEffectMove(new Static3D( 0, (backH-screenH)/2, 0)) ); |
|
| 413 | 417 |
mCrawlBackgroundEffects.apply( new MatrixEffectRotate(new Static1D(CRAWL_ANGLE), new Static3D(1,0,0), new Static3D(0,-backH/2,0)) ); |
| 418 |
mCrawlBackgroundEffects.apply( new MatrixEffectMove(new Static3D( 0, (backH-screenH)/2, 0)) ); |
|
| 414 | 419 |
|
| 415 | 420 |
final int transpDist = 5; |
| 416 | 421 |
Static3D center = new Static3D( screenW/2 , transpDist*backH , 0 ); |
| ... | ... | |
| 427 | 432 |
mCrawlEffects.apply( new MatrixEffectScale(new Static3D(scale,scale,scale)) ); |
| 428 | 433 |
mCrawlEffects.apply( move ); |
| 429 | 434 |
|
| 430 |
mBackground = mScreen.attach(mCrawlBackgroundTexture, mCrawlBackgroundEffects,mCrawlBackgroundQuad); |
|
| 431 |
mBackground.attach(mCrawlTexture, mCrawlEffects,mCrawlQuad); |
|
| 435 |
mBackground = mScreen.attach(mCrawlBackgroundTexture, mCrawlBackgroundEffects, mCrawlBackgroundQuad);
|
|
| 436 |
mBackground.attach(mCrawlTexture, mCrawlEffects, mCrawlQuad);
|
|
| 432 | 437 |
mBackground.glDisable(GLES31.GL_DEPTH_TEST); |
| 433 | 438 |
mBackground.glDepthMask(false); |
| 434 | 439 |
} |
| 435 |
else if( effectID==moveEffectID )
|
|
| 440 |
else if( effectID == moveEffectID )
|
|
| 436 | 441 |
{
|
| 437 | 442 |
mScreen.detach(mBackground); |
| 438 | 443 |
mBackground.detach(mCrawlEffects); |
Also available in: Unified diff
Fixes for the merge.