Revision 641ea00c
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/examples/predeform/PredeformRenderer.java | ||
|---|---|---|
| 27 | 27 |
import org.distorted.library.effect.MatrixEffectScale; |
| 28 | 28 |
import org.distorted.library.effect.VertexEffect; |
| 29 | 29 |
import org.distorted.library.effect.Effect; |
| 30 |
import org.distorted.library.effect.VertexEffectScale; |
|
| 31 | 30 |
import org.distorted.library.main.DistortedEffects; |
| 32 | 31 |
import org.distorted.library.main.DistortedLibrary; |
| 33 | 32 |
import org.distorted.library.main.DistortedScreen; |
| ... | ... | |
| 54 | 53 |
private DistortedEffects mEffects1, mEffects2; |
| 55 | 54 |
private MeshBase mMesh1, mMesh2; |
| 56 | 55 |
private DistortedScreen mScreen; |
| 57 |
private float mObjWidth, mObjHeight, mObjDepth; |
|
| 58 | 56 |
private Static3D mScale, mMove1, mMove2; |
| 59 | 57 |
|
| 60 | 58 |
Static4D mQuat1, mQuat2; |
| ... | ... | |
| 78 | 76 |
mMesh1 = act.getMesh(); |
| 79 | 77 |
mMesh2 = mMesh1.deepCopy(); |
| 80 | 78 |
|
| 81 |
mObjWidth = act.getCols(); |
|
| 82 |
mObjHeight= act.getRows(); |
|
| 83 |
mObjDepth = act.getSlic(); |
|
| 84 |
|
|
| 85 | 79 |
mQuat1 = new Static4D(0,0,0,1); // unity |
| 86 | 80 |
mQuat2 = new Static4D(0,0,0,1); // quaternions |
| 87 | 81 |
|
| ... | ... | |
| 100 | 94 |
} |
| 101 | 95 |
|
| 102 | 96 |
mEffects1 = new DistortedEffects(); |
| 103 |
mEffects1.apply( new VertexEffectScale(new Static3D(mObjWidth,mObjHeight,mObjDepth) ) ); |
|
| 104 | 97 |
|
| 105 | 98 |
for(int i=0; i<numEffects; i++) |
| 106 | 99 |
{
|
| ... | ... | |
| 113 | 106 |
mEffects1.apply( new MatrixEffectMove(mMove1)); |
| 114 | 107 |
|
| 115 | 108 |
mEffects2 = new DistortedEffects(); |
| 116 |
mEffects2.apply( new VertexEffectScale(new Static3D(mObjWidth,mObjHeight,mObjDepth) ) ); |
|
| 117 | 109 |
mEffects2.apply( new MatrixEffectScale(mScale)); |
| 118 | 110 |
mEffects2.apply( new MatrixEffectQuaternion(quatInt2, center) ); |
| 119 | 111 |
mEffects2.apply( new MatrixEffectQuaternion(quatInt1, center) ); |
| ... | ... | |
| 139 | 131 |
|
| 140 | 132 |
if( width<height ) |
| 141 | 133 |
{
|
| 142 |
float factor = SCALE*(Math.min(width/mObjWidth, 0.5f*height/mObjHeight));
|
|
| 134 |
float factor = SCALE*(Math.min(width, 0.5f*height));
|
|
| 143 | 135 |
mScale.set(factor,factor,factor); |
| 144 | 136 |
mMove1.set(0,+height*0.25f,0); |
| 145 | 137 |
mMove2.set(0,-height*0.25f,0); |
| 146 | 138 |
} |
| 147 | 139 |
else |
| 148 | 140 |
{
|
| 149 |
float factor = SCALE*(Math.min( 0.5f*width/mObjWidth, height/mObjHeight));
|
|
| 141 |
float factor = SCALE*(Math.min( 0.5f*width, height));
|
|
| 150 | 142 |
mScale.set(factor,factor,factor); |
| 151 | 143 |
mMove1.set(+width*0.25f,0,0); |
| 152 | 144 |
mMove2.set(-width*0.25f,0,0); |
Also available in: Unified diff
1 more fix for the Predefrom app and preapplying Vertex Effects to a 1-component Mesh works :)