1
Support / problem with uv coordinates
« on: February 06, 2013, 04:47:55 pm »
Hi, first of all, thanks very much for this software. I played a little with this 3d thing with jpct some time ago, but now I started to do a complete game.
I have encountered several (and very basic) problems. Perhaps I must be doing something very wrong. The first problem, is that normally when I use uv coordinates greater than 10 or so, I get strange graphics. I post an example. This example uses one of the textures in tp.zip downloadable from the page.
I'm using the latest jpct (1.26). The same problem happens with previous version.
I have encountered several (and very basic) problems. Perhaps I must be doing something very wrong. The first problem, is that normally when I use uv coordinates greater than 10 or so, I get strange graphics. I post an example. This example uses one of the textures in tp.zip downloadable from the page.
I'm using the latest jpct (1.26). The same problem happens with previous version.
Code: [Select]
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);
}
}
}