Glad you like it, and thanks a lot again for your precious help !
It's just the begining, we'll use our concept for other projects.
It's just the begining, we'll use our concept for other projects.

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
float reductionPercent; // example : 0.9f if the original image has been reduced at 90% to solve side effects (and then cut into 4)
float ratio = 2 * reductionPercent;
float margin = 1 - ratio/2;
[...]
for(int i=0; i<nbTriangles; i++) {
// read polygon UV :
SimpleVector uv1 = polygonMgr.getTextureUV(i, 0);
SimpleVector uv2 = polygonMgr.getTextureUV(i, 1);
SimpleVector uv3 = polygonMgr.getTextureUV(i, 2);
u1 = uv1.x;
v1 = uv1.y;
u2 = uv2.x;
v2 = uv2.y;
u3 = uv3.x;
v3 = uv3.y;
boolean west = u1 < 0.5;
boolean south = v1 < 0.5;
if(west) {
u1bis = u1 * ratio;
u2bis = u2 * ratio;
u3bis = u3 * ratio;
}
else {
u1bis = (u1 - 0.5f) * ratio + margin;
u2bis = (u2 - 0.5f) * ratio + margin;
u3bis = (u3 - 0.5f) * ratio + margin;
}
if(south) {
v1bis = v1 * ratio;
v2bis = v2 * ratio;
v3bis = v3 * ratio;
}
else {
v1bis = (v1 - 0.5f) * ratio + margin;
v2bis = (v2 - 0.5f) * ratio + margin;
v3bis = (v3 - 0.5f) * ratio + margin;
}
if(west && south) texID = textureID1;
else if(west && !south) texID = textureID2;
else if(!west && south) texID = textureID3;
else if(!west && !south) texID = textureID4;
polygonMgr.setPolygonTexture(i, new TextureInfo(texID, u1bis, v1bis, u2bis, v2bis, u3bis, v3bis));
}
protected Camera cam;
protected SimpleVector lookAt = new SimpleVector();
protected SimpleVector camPos;
protected static final float angle2Max = (float) (Math.PI / 2 - 0.001);
protected static final float angle2Min = 0;
protected float angle1 = 0; // angle around y-axis, as measured from positive x-axis
protected float angle2 = angle2Max; // angle up from x-z plane, clamped to [0:Pi/2]
protected static final float dragGain = 0.01f;
protected void leftButtonDragged(float dx, float dy) {
angle1 += dx * dragGain;
angle2 = Math.min(angle2 + dy * dragGain, angle2Max);
angle2 = Math.max(angle2, angle2Min);
cameraChange();
}
protected void rightButtonDragged(float dx, float dy) {
cameraShift(dx * dragGain, dy * dragGain);
cameraChange();
}
private void cameraShift(float screen_dx, float screen_dy) {
if(screen_dx ==0 && screen_dy == 0) return;
float distRatio = (camDist/camDistMin);
screen_dx *= distRatio;
screen_dy *= distRatio;
camPos = cam.getPosition();
cam.moveCamera(Camera.CAMERA_MOVERIGHT, screen_dx);
cam.moveCamera(Camera.CAMERA_MOVEDOWN, screen_dy);
SimpleVector shift = cam.getPosition().calcSub(camPos);
lookAt.sub(shift);
if(lookAt.y > lookAtYMax) lookAt.y = lookAtYMax;
else if(lookAt.y < lookAtYMin) lookAt.y = lookAtYMin;
}
public void cameraChange() {
camPos = cam.getPosition();
updateCamPosition(camPos, lookAt, camDist, angle1, angle2, camYMax);
cam.setPosition(camPos);
cam.lookAt(lookAt);
}
public void updateCamPosition(SimpleVector camPos, SimpleVector lookAt, float camDist, float angle1, float angle2, float camYMax) {
double t = camDist*Math.cos(angle2); // distance to y-axis after being rotated up
camPos.x = (float) ((t*Math.sin(angle1)) + lookAt.x);
camPos.y = (float) - (camDist*Math.sin(angle2)) + lookAt.y;
camPos.z = (float) ((t*Math.cos(angle1)) + lookAt.z);
}
Page created in 0.016 seconds with 9 queries.