posted 12 years ago
Hello guys,
I am newbie in Java3D and I am facing some problems while designing a 3d shape. Actually I have to design a 3d shape of a 'Carpet' placed on the ground in such a way, it looks like a Road or Pathway from "First-Person-View". That is, like a Trapezoid. The Carpet itself is made up of several segments or pieces, each of different color, width and height. Finally, exporting the final Carpet-shape as Buffered Image. Though I am able to do the later part very easily, that is, creating an image using BufferdImage from JFrame, On & Off Screen Canvas but the designing part is where I am facing some difficulties.
I am creating a Group (carpetShapeGroup) of Polygons (with QuadArray: 4) for each segment/piece and place them one over another. so it looks like Rectangular Boxes placed one over another. Then with the Transformation3D (rot), I rotate this carpetShapeGroup with rot.rotX(-Math.PI/4) to make it like a Trapezoid shape. However, I am able to draw the image but there are several problems which I am not able to solve anymore and I need some help. I had uploaded the code on Pastie and attached it here as well with inline comments to illustrate the details. Following are the problems I am facing;
1. I can create a Carpet with 3 segments/pieces successfully but as soon as I add fourth segment, the image gets distorted and the segments overlaps each other. I don't know why is it happening and how to resolve this issue. (Uncomment line:227)
2. In order to display the Carpet from the bottom of the Screen i am setting a constant factor (*Transformation_Vector_Y*) but I am not able to derive it as Constant for different screen resolutions. I mean I had to make slight changes in Transformation_Vector_Y each time the Screen width and height is modified. (line:132)
Please let me know if something is unclear here, I will try to explain my problem again. Looking forward to see your replies.
thanks and regards