Is that possible using the software engine? If so, how, because the 2D graphics always seem to come out on top?
I just so happen to have done this before:
http://www.paulscode.com/source/jPCTSwingMix/ (http://www.paulscode.com/source/jPCTSwingMix/)
You can get the source code at:
http://www.paulscode.com/source/jPCTSwingMix/jPCTSwingMixSource.zip (http://www.paulscode.com/source/jPCTSwingMix/jPCTSwingMixSource.zip)
Thanks a lot, buddy. I'll have a look.
After looking at it for twenty minutes I finally saw what I needed: FrameBuffer.getGraphics()! Not once had I used that one before. Thanks again, pal.
Okay, you did 2D-3D-2D. That seems easy, in retrospect. But what I need is 3D-2D-3D. I tried making the last 3D object invisible, render and draw, draw 2D, then add that object and make everything else invisible, render and draw, then display(). As I expected, it didn't work (I lost the very first object but the 2D was behind the last object). So now what do I do?
I am not sure. The logic behind your approach seems sound, but it sounds like the buffer is getting cleared between the first 3D layer and the 2D part. Any chance I can see the code you are using for the render loop?
Sure thing. Thanks in advance.
protected void draw() {
bow.rotateX(rotateX);
bow.rotateZ(rotateZ);
rotateX = 0;
rotateZ = 0;
buffer.clear();
scene.setVisibility(true);
arrow.setVisibility(false);
bow.setVisibility(false);
theWorld.renderScene(buffer);
theWorld.draw(buffer);
// buffer.update();
Graphics2D g2 = (Graphics2D) buffer.getGraphics();
java.awt.image.BufferedImage map = thePanther.getCurrentMap();
Polygon current = thePanther.getCurrent();
g2.setPaint(new TexturePaint(map, current.getBounds()));
g2.fill(current);
scene.setVisibility(false);
arrow.setVisibility(true);
bow.setVisibility(true);
theWorld.renderScene(buffer);
theWorld.draw(buffer);
if (adjustLine)
bowTopAndBottom();
SimpleVector point1 = Interact2D.project3D2D(mainCamera, buffer, uppermost);
SimpleVector point2 = Interact2D.project3D2D(mainCamera, buffer, lowermost);
SimpleVector arrowPoint = Interact2D.project3D2D(mainCamera, buffer, arrowBack);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setColor(Color.white);
g2.drawLine((int)point1.x, (int)point1.y, (int)arrowPoint.x, (int)arrowPoint.y);
g2.drawLine((int)arrowPoint.x, (int)arrowPoint.y, (int)point2 .x, (int)point2.y);
buffer.display(g);
}
Looks reasonable to me at the first glance. What happens if you clear the buffer with a specific color instead of black. Is the background still in that color after the method has finished drawing everything?
Just so the both of you know, the code did work. I appreciate both your help. For the record, the reason I wasn't seeing it work is the fact that I had some leftover code from a previous attempt. Thanks again.
Awesome, that is great. I don't know if I will ever need the capability of putting a 2D layer between two 3D layers, but it is nice to know it is possible.