Revision edafb4a7
Added by Leszek Koltunski almost 8 years ago
src/main/java/org/distorted/examples/fragment3d/Fragment3DRenderer.java | ||
---|---|---|
61 | 61 |
|
62 | 62 |
private DynamicQuat mQuatInt1, mQuatInt2; |
63 | 63 |
|
64 |
private EffectNames[] order; |
|
65 |
|
|
66 |
private Dynamic2D mCenterInter; |
|
67 |
private Dynamic3D mChromaInter, mMoveInter; |
|
68 |
private Dynamic1D mChromaLevelInter, mAlphaInter, mBrightnessInter, mSaturationInter; |
|
69 |
|
|
70 |
private Static2D mCenterPoint; |
|
71 |
private Static3D mChromaPoint, mMovePoint; |
|
72 |
private Static1D mChromaLevel, mAlphaPoint, mBrightnessPoint, mSaturationPoint; |
|
73 |
|
|
74 | 64 |
Static4D mQuat1, mQuat2; |
75 | 65 |
int mScreenMin; |
76 | 66 |
|
77 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
78 |
|
|
79 |
public void setChroma(float level, float r, float g, float b) |
|
80 |
{ |
|
81 |
mChromaLevel.set(level); |
|
82 |
mChromaPoint.set(r, g, b); |
|
83 |
} |
|
84 |
|
|
85 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
86 |
|
|
87 |
public void setAlpha(float level) |
|
88 |
{ |
|
89 |
mAlphaPoint.set(level); |
|
90 |
} |
|
91 |
|
|
92 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
93 |
|
|
94 |
public void setBrightness(float level) |
|
95 |
{ |
|
96 |
mBrightnessPoint.set(level); |
|
97 |
} |
|
98 |
|
|
99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
100 |
|
|
101 |
public void setSaturation(float level) |
|
102 |
{ |
|
103 |
mSaturationPoint.set(level); |
|
104 |
} |
|
105 |
|
|
106 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
107 |
|
|
108 |
public void setCenter(float x, float y) |
|
109 |
{ |
|
110 |
x = (0.012f*x-0.1f)*mObjWidth; |
|
111 |
y = (0.012f*y-0.1f)*mObjHeight; |
|
112 |
|
|
113 |
mCenterPoint.set(x,y); |
|
114 |
mMovePoint.set(mFactorObj*x,mFactorObj*y,0); |
|
115 |
} |
|
116 |
|
|
117 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
118 |
|
|
119 |
public void setOrder(EffectNames[] effects) |
|
120 |
{ |
|
121 |
order = effects; |
|
122 |
setFragmentEffects(); |
|
123 |
} |
|
124 |
|
|
125 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
126 |
|
|
127 |
private void setFragmentEffects() |
|
128 |
{ |
|
129 |
mObject.abortEffects(EffectTypes.FRAGMENT); |
|
130 |
|
|
131 |
for( int i=0; i<=order.length-1 ; i++ ) |
|
132 |
{ |
|
133 |
switch(order[i]) |
|
134 |
{ |
|
135 |
case CHROMA : mObject.chroma ( mChromaLevelInter , mChromaInter) ; break; |
|
136 |
case ALPHA : mObject.alpha ( mAlphaInter ) ; break; |
|
137 |
case BRIGHTNESS: mObject.brightness( mBrightnessInter ) ; break; |
|
138 |
case SATURATION: mObject.saturation( mSaturationInter ) ; break; |
|
139 |
} |
|
140 |
} |
|
141 |
} |
|
142 |
|
|
143 | 67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
144 | 68 |
|
145 | 69 |
public Fragment3DRenderer(GLSurfaceView v) |
... | ... | |
147 | 71 |
mView = v; |
148 | 72 |
|
149 | 73 |
mObject = ((Fragment3DActivity)v.getContext()).getObject(); |
150 |
mCenter = new DistortedBitmap(SIZE, SIZE, 1); |
|
151 | 74 |
|
152 | 75 |
mObjWidth = mObject.getWidth(); |
153 | 76 |
mObjHeight= mObject.getHeight(); |
154 | 77 |
|
155 |
mCenterPoint = new Static2D(0,0); |
|
156 |
mMovePoint = new Static3D(0,0,0); |
|
157 |
mChromaPoint = new Static3D(0,0,0); |
|
158 |
mChromaLevel = new Static1D(0); |
|
159 |
mAlphaPoint = new Static1D(1); |
|
160 |
mBrightnessPoint= new Static1D(1); |
|
161 |
mSaturationPoint= new Static1D(0.5f); |
|
162 |
|
|
163 |
mCenterInter = new Dynamic2D(); |
|
164 |
mMoveInter = new Dynamic3D(); |
|
165 |
mChromaInter = new Dynamic3D(); |
|
166 |
mChromaLevelInter= new Dynamic1D(); |
|
167 |
mAlphaInter = new Dynamic1D(); |
|
168 |
mBrightnessInter = new Dynamic1D(); |
|
169 |
mSaturationInter = new Dynamic1D(); |
|
170 |
|
|
171 |
mCenterInter.add(mCenterPoint); |
|
172 |
mMoveInter.add(mMovePoint); |
|
173 |
mChromaInter.add(mChromaPoint); |
|
174 |
mChromaLevelInter.add(mChromaLevel); |
|
175 |
mAlphaInter.add(mAlphaPoint); |
|
176 |
mBrightnessInter.add(mBrightnessPoint); |
|
177 |
mSaturationInter.add(mSaturationPoint); |
|
178 |
|
|
179 | 78 |
mQuat1 = new Static4D(0,0,0,1); // unity |
180 | 79 |
mQuat2 = new Static4D(0,0,0,1); // quaternions |
181 | 80 |
|
... | ... | |
196 | 95 |
long time = System.currentTimeMillis(); |
197 | 96 |
|
198 | 97 |
mObject.draw(time); |
98 |
|
|
99 |
mCenter = mView. |
|
100 |
|
|
199 | 101 |
mCenter.draw(time); |
200 | 102 |
} |
201 | 103 |
|
... | ... | |
221 | 123 |
mFactorCen = (0.15f*width)/centerSize; |
222 | 124 |
} |
223 | 125 |
|
126 |
|
|
127 |
Static3D rotateObj = new Static3D(mObjWidth/2,mObjHeight/2, 0); |
|
128 |
|
|
129 |
mObject.move( new Static3D( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , 0) ); |
|
130 |
mObject.scale(mFactorObj); |
|
131 |
mObject.quaternion(mQuatInt1, rotateObj); |
|
132 |
mObject.quaternion(mQuatInt2, rotateObj); |
|
133 |
|
|
224 | 134 |
Fragment3DActivity act = (Fragment3DActivity)mView.getContext(); |
225 | 135 |
float cX = act.getCenterX(); |
226 | 136 |
float cY = act.getCenterY(); |
... | ... | |
230 | 140 |
|
231 | 141 |
mMovePoint.set(cX*mFactorObj,cY*mFactorObj,0); |
232 | 142 |
|
233 |
Static3D rotateObj = new Static3D(mObjWidth/2,mObjHeight/2, 0); |
|
234 |
|
|
235 |
mObject.move( new Static3D( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , 0) ); |
|
236 |
mObject.scale(mFactorObj); |
|
237 |
mObject.quaternion(mQuatInt1, rotateObj); |
|
238 |
mObject.quaternion(mQuatInt2, rotateObj); |
|
239 |
|
|
240 | 143 |
Static3D rotateCen = new Static3D(width/2,height/2, 0); |
241 | 144 |
|
242 | 145 |
mCenter.quaternion(mQuatInt1, rotateCen); |
Also available in: Unified diff
Some progress with Fragment3D app - doesn't compile yet!