jPCT - a 3d engine for Java => Support => Topic started by: raft on February 09, 2005, 06:23:44 pm

Title: visible sides
Post by: raft on February 09, 2005, 06:23:44 pm
hi all,

first of all i must mention jpct really seems great :)

i am just a newbea at computer graphics and toying with it to grasp the basics.

i loaded a 3ds model and rotate the camera around it. for a model with one or two objects it is all-well. but with three, four or more objects, i couldnt manage to draw them properly. they are either not drawn or drawn half like the camera at completely different point.

first i suspected if 3dmax exporting fails. i retried it one object in 3ds file and cloning object or by reloading the file. still couldnt manage it.

stranger enough world.getVisibilityList().getSize() seems to remain constant at 4097.

what may be wrong ? below is the complete source. you may try it with any 3ds file.

Code: [Select]

import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.threed.jpct.*;

public class Test1 {
private final static SimpleVector STARTING_POS = new SimpleVector(0, 2, -150);
private final static SimpleVector CAMERA_TARGET = new SimpleVector(0, 1, 0);

private World world;
private FrameBuffer buffer;
private RenderPanel panel;
private Timer timer;

private Test1(String[] args) throws Exception {
String fileName = args[0];
float scale = args.length >= 2 ? Float.parseFloat(args[1]) : 1f;
int period = args.length >= 3 ? Integer.parseInt(args[2]) : 100;
int copies = args.length >= 4 ? Integer.parseInt(args[3]) : 3;

world = new World();

for (int i = 0; i < copies; i++) {
FileInputStream fis = new FileInputStream(args[0]);
Object3D[] os = Loader.load3DS(fis, scale);
System.out.println("loaded objects size: " + os.length + " scale: " + scale);

for (int oIndex = 0; oIndex < os.length; oIndex++) {
Object3D o = os[oIndex];
o.rotateX((float) (Math.PI / -2f)); // since 3dmax coordinate system differ
o.translate(new SimpleVector(20 * i, 20 * i, 20 * i)); // move this
System.out.println("added object " + o.getName());


Camera camera = world.getCamera();

buffer = new FrameBuffer(600, 400, FrameBuffer.SAMPLINGMODE_NORMAL);

JFrame frame = new JFrame("testing jpct");

panel = new RenderPanel();
panel.setPreferredSize(new Dimension(600, 400));
panel.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e) {
if (timer.isRunning())
else timer.start();


timer = new Timer(period, new ActionListener(){
// no need to synchronize this stuff since paint and this is both called in awt's thread
public void actionPerformed(java.awt.event.ActionEvent e) {
Camera camera = world.getCamera();

SimpleVector v = camera.getPosition();
v.rotateY((float) (Math.PI / 20));




class RenderPanel extends JPanel {
public void paintComponent(Graphics g) {

world.drawWireframe(buffer, Color.ORANGE);

g.drawImage(buffer.getOutputBuffer(), 0, 0, null);
                  g.drawString("running..", 10, 15);

g.drawString("visible size: " + world.getVisibilityList().getSize(), 10, 30);
g.drawString("camera: " + world.getCamera().getPosition(), 10, 45);

public static void main(String[] args) throws Exception {
System.out.println("usage: test1 <3ds file> [scale] [update period im ms] [# copies]");

Test1 test1 = new Test1(args);

r a f t
Title: visible sides
Post by: raft on February 09, 2005, 07:54:53 pm
here is the answer (self service :idea: )

by default Config.maxPolysVisible is 4096 which does not allow any additional polies to be drawn

Code: [Select]
r a f t
Title: visible sides
Post by: EgonOlsen on February 09, 2005, 11:33:00 pm
That's right...but you can set this value to anything your machine permits. Just do that before instanciating the World and you are fine.
Title: Re: visible sides
Post by: EgonOlsen on February 09, 2005, 11:33:46 pm
Quote from: "raft"
first of all i must mention jpct really seems great :)
It is.... :wink: