www.jpct.net
jPCT - a 3d engine for Java => Support => Topic started by: aZen on May 16, 2013, 12:57:06 pm
-
When I use
object3D.setAdditionalColor(SOME_COLOR);
object3D.setShadingMode(Object3D.SHADING_FAKED_FLAT);
object3D.setTransparency(0);
object3D.setCulling(false);
in software mode, everything is rendered transparent, but just black. Is this something that could be fixed without too much effort?
Thank you,
aZen
Edit: Edited the title to reflect the problem better.
-
And without transparency being used...?
-
Oh... it's also black.
So the culling is the problem?
-
It might be, if you are looking into the model. But then you should get the same effect without flat shading. Do you?
-
I've created a minimal test cast:
package vitco;
import com.threed.jpct.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
/**
* Testing problem where object is rendered black.
*/
public class BlackJPCT extends WindowAdapter implements MouseMotionListener {
static FrameBuffer buffer;
static World world;
Object3D box;
JFrame frame;
public BlackJPCT() {
// set up frame
frame = new JFrame("Hello Black!");
frame.setSize(800, 600);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
// set up world
world = new World();
world.setAmbientLight(0, 0, 0);
world.addLight( new SimpleVector(500,-500,500), new Color(20,20,20) );
Config.fadeoutLight = false;
// ==========================
box = Primitives.getBox(10f, 1f);
box.setAdditionalColor(Color.RED);
// ###############################
// ###############################
// if I comment out either of these two lines
// the object is no longer rendered as black
box.setShadingMode(Object3D.SHADING_FAKED_FLAT);
box.setCulling(false);
// ###############################
// ###############################
box.build();
world.addObject(box);
// ==========================
// set up camera
world.getCamera().setPosition(50, -50, -5);
world.getCamera().lookAt(SimpleVector.ORIGIN);
// set up frame buffer
buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_NORMAL);
// set up event handler
frame.addMouseMotionListener(this);
frame.addWindowListener(this);
}
@Override
public void windowClosing(WindowEvent e) {
// clean up when closing
buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
buffer.dispose();
frame.dispose();
System.exit(0);
}
@Override
public void mouseDragged(MouseEvent e) {}
@Override
public void mouseMoved(MouseEvent e) {
box.rotateY(0.01f);
// animate and redraw
buffer.clear(Color.LIGHT_GRAY);
world.renderScene(buffer);
world.draw(buffer);
buffer.update();
buffer.display(frame.getGraphics());
}
// constructor
public static void main (String[] args) {
new BlackJPCT();
}
}
The essence from that test case:
// if I comment out either of these two lines
// the object is no longer rendered as black
box.setShadingMode(Object3D.SHADING_FAKED_FLAT);
box.setCulling(false);
Thank you for your help!
-
It's a bug, thank you for the test case. This jar should fix it: http://jpct.de/download/beta/jpct.jar (http://jpct.de/download/beta/jpct.jar)
-
It's fixed! Thank you!