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.

Messages - Knuffi

Pages: 1 [2]
I had a look at the bones examples, but it did not get very clear to me. This is my first try, but when starting the app, nothing is rendered.
I initialize the BoxSoft Class to create the world, the camera  and the framebuffer and give it as a Graphics to the canvas. I thought a loop is not necessary as the scene does not change or has any movement in it.

Code: [Select]
package jPCT;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import java.awt.Canvas;

public class HelloGui extends JFrame {

private JPanel contentPane;

* Launch the application.
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
HelloGui frame = new HelloGui();
} catch (Exception e) {

public HelloGui() throws Exception {
setBounds(100, 100, 800, 600);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

JButton btnTest = new JButton("Test 1");
btnTest.setBounds(10, 11, 89, 23);

JButton btnTest_1 = new JButton("Test 2");
btnTest_1.setBounds(10, 45, 89, 23);

JButton btnTest_2 = new JButton("Test 3");
btnTest_2.setBounds(10, 79, 89, 23);

Canvas canvas = new Canvas();
canvas.setBounds(105, 10, 669, 542);

BoxSoft bs = new BoxSoft();


The "jPCT Class":
Code: [Select]
package jPCT;

import java.awt.Color;
import java.awt.Graphics;

import com.threed.jpct.FrameBuffer;
import com.threed.jpct.Object3D;
import com.threed.jpct.Primitives;
import com.threed.jpct.World;

public class BoxSoft {
private World world;
private FrameBuffer buffer;
private Object3D box;

public BoxSoft() {

world = new World();
// world.setAmbientLight(200, 255, 200);

// TextureManager.getInstance().addTexture("box", new Texture("box.jpg"));

box = Primitives.getBox(3f, 2f);
// box.setTexture("box");
// box.setEnvmapped(Object3D.ENVMAP_ENABLED);;

world.getCamera().setPosition(50, -50, -5);
buffer = new FrameBuffer(660, 540, FrameBuffer.SAMPLINGMODE_NORMAL);

public Graphics paint(){
world.drawWireframe(buffer, Color.WHITE);

return buffer.getGraphics();



Ok, thanks.

But how do I manage the loop then?

Is there anywhere an example?


I searched this site, but did not find any hint. I read the examples which render the "Hello World" in software, OpenGL and AWTGL, but I don't get the clue.
I have two problems:
1. I want to render a scene in a JPanel. As it is not very GPU demanding, software renderer will be enough - as I read, it is the only one really working with SWING components. Can someone give me an example? I thought, I've seen one somewhere in the wiki, but I can't find it anymore.

2. Is it possible to swap the HelloWorld class out of the "GUI class"?
As the GUI of the programme I want to write is very complex, I use WindowsBuilder in Eclipse, so I want to write a jPCT class and then just call it in the GUI. Is this possible?

Thanks in advance!

Projects / 3D Geometry Programme
« on: April 05, 2012, 12:45:29 am »
Hi, I'm about to write a 3D geometry programme. It is supposed to help teachers and older students with vectors, points, lines, planes and squares and their intersections.
Most work is done in Java Swing (entering the objects, calculating and checking their intersections), I will try to get the visualisation done with jPCT. I hope I will be good enough to do so.

Pages: 1 [2]