Main Menu
Menu

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.

Show posts Menu

Messages - tony-kun

#1
Support / Re: problem with uv coordinates
February 06, 2013, 10:21:49 PM
Thanks for the precise information. Maybe it's somewhere else, I didn't see it.
#2
Support / Re: problem with uv coordinates
February 06, 2013, 05:02:50 PM
Note, I called in the example, buffer.display() inside the paintComponent() method, because the wiki says "It seems that there is no other way than extending a swing component" and also do it that way. Normally I prefer to use panel.getGraphics instead and draw somewhere else. I guess there is actually no difference? I checked one of the demos and it uses getGraphics also.

Note the wiki has a mistake in the picking section, it says:

Object3D picked=world.getObject(res[1]);

but off course it should say Object3D picked=world.getObject(res[0]);
#3
Support / problem with uv coordinates
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.


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);
    }
}

}
#4
Support / Re: how to obtain selected triangle
February 23, 2009, 04:33:43 AM
am sorry the flood already. Actually I can use what you said too.

the polygons used by jpct are always convex? or not?

thanks.
#5
Support / Re: how to obtain selected triangle
February 22, 2009, 03:52:33 PM
Aaah may be I can do really exactly what I said, great. Anyway thanks for any aditional help.
#6
Support / Re: how to obtain selected triangle
February 22, 2009, 03:34:29 PM
Hi, as I understand polygon is what get displayed at the end, a portion of the triangle, and may be even all of his vertices are new.
May be if I had a function that tell me if a polygon is aproximately inside the coords I give... that could suffice, altough would be a bit inexact. Is there something like that?

I suposse you don't give the id of the original triangles because some optimization.

Thanks.
#7
Support / how to obtain selected triangle
February 22, 2009, 12:00:57 AM
Hi! I will get fun starting a 3d game project. jcpt is the first engine am trying and looks very nice all this. Not worrying about the 3d stuff and filling textures so easly is so great.. But one thing I miss is obtaining the original triangle of a 2d position in the screen. Something like:

int idTriangle = Interact2D.getTriangleID(r);

off course triangles when adding them they should have an unique global id in addittion to just a local to the object.

May be am missing something. Otherwise, how do you know which face of an object the user points to?

A drastic solution could be definind an object for every face. But I don't think that's normal.

Many thanks for any help.