Main Menu
Menu

Show posts

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

Messages - Elvynia

#1
Support / Re: Texture mapping issue
October 28, 2012, 01:27:12 AM
Thanks a lot. I understand know the u/v components and it work now !
#2
Support / Re: Texture mapping issue
October 24, 2012, 10:53:02 PM
Hello Egon,

I understand that calcTextureWrap can't exactly set all the texture coordinates. I thought there was a mistake in my actual addTriangle (in vertex order) calls because only the half of the triangles are correct. I did a test with 4 triangles per face (with the center point) and the up and down triangles are good while left and right are totally fucked.

I've actually built my composeModule method by copying this "create_a_cube" code on the wiki. I've removed the u/v parameters because i don't understand what they represent, and it didn't change anything. I thought they was maybe built by the tileTexture call (taken from the AdvancedExample project in the wiki).

I've read the addTriangle javaDoc a hundred times but my lack of knowledge in 3D and texture stuff don't let me understand the u/v values part :  "the u component of the texture position at the first vertex".
Could you explain or direct me to understand what kind of position do i have to set for each vertex through the u/v components ?

Thank you for your quick support.
Elvynia.
#3
Support / Texture mapping issue
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 :


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;
}



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.