Thanks for the precise information. Maybe it's somewhere else, I didn't see it.
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.
Show posts Menu
import com.threed.jpct.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.imageio.ImageIO;
public class Prueba extends JFrame implements Runnable
{
private World world;
private FrameBuffer buffer;
private boolean finish = false;
public static void main(String[] args)throws Exception
{
Prueba p = new Prueba();
p.setSize(800, 600);
p.initWorld(800, 600);//new MyPanel());//(JPanel)p.getContentPane().getComponent(0));
p.setVisible(true);
new Thread(p).start();
}
public Prueba()
{
getContentPane().add(new MyPanel(), java.awt.BorderLayout.CENTER);
setUndecorated(true);
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent ev) {
finish = true;
}
});
}
public void initWorld(int sizeX, int sizeY)throws Exception//JPanel panel)throws Exception
{
world = new World();
world.setAmbientLight(255, 255, 255);
File f = new File("expo_stones2.png");
System.out.println(f.getAbsolutePath());
BufferedImage img = ImageIO.read(f);
TextureManager.getInstance().addTexture("stones", new Texture(img));
Object3D grass = new Object3D(2);
float factorX = 20;
float factorY = 20;
grass.addTriangle(getSV(0, 0, 0), 0, factorY, getSV(50, 0, 0), factorX, factorY, getSV(50, 50, 0), factorX, 0,
TextureManager.getInstance().getTextureID("stones"));
grass.addTriangle(getSV(50, 50, 0), factorX, 0, getSV(0, 50, 0), 0, 0, getSV(0, 0, 0), 0, factorY,
TextureManager.getInstance().getTextureID("stones"));
grass.build();
world.addObject(grass);
world.getCamera().setPosition(getSV(-3, -3, 10));
world.getCamera().lookAt(getSV(10, 10, 0));
buffer = new FrameBuffer(sizeX, sizeY, FrameBuffer.SAMPLINGMODE_NORMAL);
buffer.enableRenderer(IRenderer.RENDERER_SOFTWARE);
}
public void run()
{
while (!finish)
{
buffer.clear(new Color(0, 100, 255));
world.renderScene(buffer);
world.draw(buffer);
buffer.update();
repaint();//buffer.display(getContentPane().getGraphics());
try
{ Thread.sleep(10); }
catch (Exception e) {}
}
setVisible(false);
dispose();
System.exit(0);
}
public SimpleVector getSV (float x, float y, float z)
{
return new SimpleVector(x, -z, y);
}
class MyPanel extends JPanel
{
public void paintComponent(Graphics g)
{
buffer.display(g);
}
}
}
Page created in 0.020 seconds with 13 queries.