Revision ba9ae2c8
Added by Leszek Koltunski almost 5 years ago
src/main/java/org/distorted/examples/earth/EarthRenderer.java | ||
---|---|---|
50 | 50 |
import org.distorted.library.type.Dynamic3D; |
51 | 51 |
import org.distorted.library.type.DynamicQuat; |
52 | 52 |
import org.distorted.library.type.Static1D; |
53 |
import org.distorted.library.type.Static2D; |
|
54 | 53 |
import org.distorted.library.type.Static3D; |
55 | 54 |
import org.distorted.library.type.Static4D; |
56 | 55 |
import org.distorted.library.type.Static5D; |
... | ... | |
110 | 109 |
mMove = new Static3D(0,0,0); |
111 | 110 |
mScaleFactor= new Static3D(1,1,1); |
112 | 111 |
mPinch = new Static3D(0.5f,0.0f,0.0f); |
113 |
mPinch = new Static3D(0.5f,0.0f,0.0f); |
|
114 | 112 |
mSwirl = new Static1D(45.0f); |
115 | 113 |
|
116 | 114 |
Static3D center = new Static3D(0,0,0); |
... | ... | |
134 | 132 |
quatInt2.add(mQuat2); |
135 | 133 |
|
136 | 134 |
mEffects = new DistortedEffects(); |
137 |
mEffects.apply( new MatrixEffectMove(mMove) ); |
|
138 |
mEffects.apply( new MatrixEffectScale(scale)); |
|
139 |
mEffects.apply( new MatrixEffectQuaternion(quatInt1, center) ); |
|
140 | 135 |
mEffects.apply( new MatrixEffectQuaternion(quatInt2, center) ); |
136 |
mEffects.apply( new MatrixEffectQuaternion(quatInt1, center) ); |
|
137 |
mEffects.apply( new MatrixEffectScale(scale)); |
|
138 |
mEffects.apply( new MatrixEffectMove(mMove) ); |
|
141 | 139 |
|
142 | 140 |
mScreen = new DistortedScreen(); |
143 | 141 |
mScreen.setProjection(FOV, NEAR); |
... | ... | |
167 | 165 |
|
168 | 166 |
void setLevel(int level) |
169 | 167 |
{ |
170 |
final float N=2.2f;
|
|
168 |
final float N=2.0f;
|
|
171 | 169 |
|
172 | 170 |
// MAP: 0--> SCALE/N 50-->SCALE 100->SCALE*N |
173 | 171 |
mLevel = SCALE* (1.0f+ (level>=50 ? N-1 : (N-1)/N) * (level-50)/50.0f); |
src/main/java/org/distorted/examples/meshjoin/MeshJoinRenderer.java | ||
---|---|---|
52 | 52 |
private DistortedTexture mTexture; |
53 | 53 |
private DistortedScreen mScreen; |
54 | 54 |
private DistortedEffects mEffects; |
55 |
private Static3D mMove, mScale, mCenter;
|
|
55 |
private Static3D mScale;
|
|
56 | 56 |
private MeshBase mMesh; |
57 | 57 |
private float mObjHeight, mObjWidth, mObjDepth; |
58 | 58 |
|
... | ... | |
65 | 65 |
{ |
66 | 66 |
mView = v; |
67 | 67 |
mScreen = new DistortedScreen(); |
68 |
mMove = new Static3D(0,0,0); |
|
69 | 68 |
mScale= new Static3D(1,1,1); |
70 |
mCenter=new Static3D(0,0,0);
|
|
69 |
Static3D center=new Static3D(0,0,0);
|
|
71 | 70 |
|
72 | 71 |
mQuat1 = new Static4D(0,0,0,1); // unity |
73 | 72 |
mQuat2 = new Static4D(0,0,0,1); // quaternions |
... | ... | |
79 | 78 |
quatInt2.add(mQuat2); |
80 | 79 |
|
81 | 80 |
mEffects = new DistortedEffects(); |
82 |
mEffects.apply( new MatrixEffectQuaternion(quatInt2, mCenter) );
|
|
83 |
mEffects.apply( new MatrixEffectQuaternion(quatInt1, mCenter) );
|
|
81 |
mEffects.apply( new MatrixEffectQuaternion(quatInt2, center) );
|
|
82 |
mEffects.apply( new MatrixEffectQuaternion(quatInt1, center) );
|
|
84 | 83 |
mEffects.apply( new MatrixEffectScale(mScale)); |
85 |
mEffects.apply( new MatrixEffectMove(mMove) ); |
|
86 | 84 |
} |
87 | 85 |
|
88 | 86 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
100 | 98 |
|
101 | 99 |
mScreenMin = width<height ? width:height; |
102 | 100 |
float factor = ( width*mObjHeight > height*mObjWidth ) ? (SCALE*height)/mObjHeight : (SCALE*width)/mObjWidth; |
103 |
mMove.set( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , -factor*mObjDepth/2 ); |
|
104 | 101 |
mScale.set(factor,factor,factor); |
105 |
mCenter.set( mObjWidth/2, mObjHeight/2, mObjDepth/2 ); |
|
106 | 102 |
mScreen.resize(width, height); |
107 | 103 |
} |
108 | 104 |
|
src/main/java/org/distorted/examples/rubik/RubikCube.java | ||
---|---|---|
69 | 69 |
|
70 | 70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
71 | 71 |
|
72 |
RubikCube(int size, Static3D move, Static3D scale)
|
|
72 |
RubikCube(int size, Static3D scale) |
|
73 | 73 |
{ |
74 | 74 |
mSize = size; |
75 | 75 |
|
... | ... | |
84 | 84 |
|
85 | 85 |
Static3D[][][] cubeVectors = new Static3D[mSize][mSize][mSize]; |
86 | 86 |
|
87 |
Static3D center = new Static3D(STRETCH_SIZE*0.5f, STRETCH_SIZE*0.5f, STRETCH_SIZE*0.5f);
|
|
87 |
Static3D center = new Static3D(0,0,0);
|
|
88 | 88 |
Static4D region = new Static4D(0,0,0, STRETCH_SIZE*0.72f); |
89 | 89 |
|
90 | 90 |
VertexEffectSink sinkEffect = new VertexEffectSink( new Static1D(getSinkStrength()), center, region ); |
91 |
MatrixEffectMove moveEffect = new MatrixEffectMove(move); |
|
92 | 91 |
MatrixEffectScale scaleEffect = new MatrixEffectScale(scale); |
93 | 92 |
MatrixEffectQuaternion quatEffect = new MatrixEffectQuaternion( initializeQuat(), center); |
94 | 93 |
|
... | ... | |
145 | 144 |
mEffects[x][y][z].apply( mRotate[x][y][z] ); |
146 | 145 |
mEffects[x][y][z].apply(quatEffect); |
147 | 146 |
mEffects[x][y][z].apply(scaleEffect); |
148 |
mEffects[x][y][z].apply(moveEffect); |
|
149 | 147 |
mEffects[x][y][z].apply(sinkEffect); |
150 | 148 |
} |
151 | 149 |
} |
src/main/java/org/distorted/examples/rubik/RubikRenderer.java | ||
---|---|---|
41 | 41 |
|
42 | 42 |
private RubikSurfaceView mView; |
43 | 43 |
private DistortedScreen mScreen; |
44 |
private Static3D mMove, mScale;
|
|
44 |
private Static3D mScale; |
|
45 | 45 |
private int mNextCubeSize; |
46 | 46 |
private boolean mChangeCubeSizeNow; |
47 | 47 |
private int mNumCube; |
... | ... | |
59 | 59 |
|
60 | 60 |
mScreenWidth = mScreenHeight = 0; |
61 | 61 |
|
62 |
mMove = new Static3D(0,0,0); |
|
63 | 62 |
mScale = new Static3D(1,1,1); |
64 | 63 |
|
65 | 64 |
mNextCubeSize= MIN_CUBE_SIZE; |
... | ... | |
130 | 129 |
private void createNextCube() |
131 | 130 |
{ |
132 | 131 |
if( mCube!=null ) mCube.releaseResources(); |
133 |
mCube = new RubikCube(mNextCubeSize, mMove, mScale);
|
|
132 |
mCube = new RubikCube(mNextCubeSize, mScale); |
|
134 | 133 |
mCube.createTexture(); |
135 | 134 |
|
136 | 135 |
if( mScreenWidth!=0 ) recomputeScaleFactor(mScreenWidth,mScreenHeight); |
... | ... | |
158 | 157 |
float texSize = mCube.getStretchSize(); |
159 | 158 |
float scaleFactor = cubeSizeInScreenSpace/(texSize*mCube.getSize()); |
160 | 159 |
|
161 |
mMove.set( (screenWidth-scaleFactor*texSize)/2 , (screenHeight-scaleFactor*texSize)/2 , -scaleFactor*texSize/2 ); |
|
162 | 160 |
mScale.set(scaleFactor,scaleFactor,scaleFactor); |
163 | 161 |
} |
164 | 162 |
} |
Also available in: Unified diff
Fixes for the merge.