1
Support / Texture mapping issue
« on: October 24, 2012, 12:33:19 pm »
Hello,
After having searching for a while where is the problem with my texture rendering, i desperately ask for a savior to my issue.
My project : An applet that allow users to draw a house (in fake 2D) and visualize it in 3D. The possibilities are very basic, only horizontal or vertical walls.
The issue : The walls are dynamically constructed to the required size and everything is fine until i try to set a texture on them. I'm using this code to build the 3D object walls :
The result is that, on the "upper" face and "lower" face, only one of the both triangles are (almost) correctly rendered with the texture :
Upper face visible on the screen shot :
Closer image of the wall. I made the red line to show the triangle separation :
The texture used :
Thank you for your support, which has already helped me a lot of times when finding informations in the forum !
Best regards,
Elvynia.
After having searching for a while where is the problem with my texture rendering, i desperately ask for a savior to my issue.
My project : An applet that allow users to draw a house (in fake 2D) and visualize it in 3D. The possibilities are very basic, only horizontal or vertical walls.
The issue : The walls are dynamically constructed to the required size and everything is fine until i try to set a texture on them. I'm using this code to build the 3D object walls :
Code: [Select]
public Object3D composeModule(final float width, final float length,
final float depth) {
final Object3D box = new Object3D(12);
final float x = width / 2;
final float y = length / 2;
final float z = depth / 2;
final SimpleVector upperLeftFront = new SimpleVector(-x, -y, -z);
final SimpleVector upperRightFront = new SimpleVector(x, -y, -z);
final SimpleVector lowerLeftFront = new SimpleVector(-x, y, -z);
final SimpleVector lowerRightFront = new SimpleVector(x, y, -z);
final SimpleVector upperLeftBack = new SimpleVector(-x, -y, z);
final SimpleVector upperRightBack = new SimpleVector(x, -y, z);
final SimpleVector lowerLeftBack = new SimpleVector(-x, y, z);
final SimpleVector lowerRightBack = new SimpleVector(x, y, z);
// Front
box.addTriangle(upperLeftFront, lowerLeftFront, upperRightFront);
box.addTriangle(upperRightFront, lowerLeftFront, lowerRightFront);
// Back
box.addTriangle(upperLeftBack, upperRightBack, lowerLeftBack);
box.addTriangle(upperRightBack, lowerRightBack, lowerLeftBack);
// Upper
// Bad part
box.addTriangle(upperLeftBack, upperLeftFront, upperRightBack);
// Good part
box.addTriangle(upperRightBack, upperLeftFront, upperRightFront);
// Lower
// Good part
box.addTriangle(lowerRightBack, lowerRightFront, lowerLeftFront);
// Bad part
box.addTriangle(lowerLeftBack, lowerRightBack, lowerLeftFront);
// Left
box.addTriangle(upperLeftFront, upperLeftBack, lowerLeftFront);
box.addTriangle(upperLeftBack, lowerLeftBack, lowerLeftFront);
// Right
box.addTriangle(upperRightFront, lowerRightFront, upperRightBack);
box.addTriangle(upperRightBack, lowerRightFront, lowerRightBack);
return box;
}
Code: [Select]
public void composeWall(final Object3D drawFrom, final Object3D drawTo) {
Object3D wall = null;
// Business stuff not touching the Object3D.
wall = composeModule(moduleLength, moduleDepth, moduleHeight);
wall.setUserObject(wallModel);
wall.setOrigin(wallPosition);
wall.setName(Globals.MODEL3D_WALL_PREFIX + wall.getID());
wall.build();
wall.setTexture("white_wall.jpg");
wall.calcTextureWrap();
wall.recreateTextureCoords();
tileTexture(wall, 100);
composer.getWorld().addObject(wall);
The result is that, on the "upper" face and "lower" face, only one of the both triangles are (almost) correctly rendered with the texture :
Upper face visible on the screen shot :
Closer image of the wall. I made the red line to show the triangle separation :
The texture used :
Thank you for your support, which has already helped me a lot of times when finding informations in the forum !
Best regards,
Elvynia.