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]
16
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.

GUI:
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();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}



public HelloGui() throws Exception {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 800, 600);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);

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

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

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

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

BoxSoft bs = new BoxSoft();
canvas.paint(bs.paint());

}
}

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);
box.build();
world.addObject(box);

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

}
public Graphics paint(){
buffer.clear(java.awt.Color.DARK_GRAY);
world.renderScene(buffer);
world.drawWireframe(buffer, Color.WHITE);
buffer.update();

return buffer.getGraphics();

}


}

17
Ok, thanks.

But how do I manage the loop then?

Is there anywhere an example?

18
Hello,

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!

19
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]