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.


Topics - Yatoom

Pages: [1]
1
Support / Moving textures in the Hello World example
« on: September 03, 2014, 01:05:54 pm »
Hi, it has been a while since I used jpct. Now, I forgot how to fix this problem that I had before in the Hello World example. When I load in a texture and add it to a box, the texture starts rotating and stretching when the box rotates.

Texture:


Output:

Note: gif is at 6 fps.

2
Support / Semi-transparency
« on: February 03, 2013, 10:37:21 pm »
I have made a terrain mesh as one object and added one water-plane as another object. I want the water to be transparent.

How it turns out to be:
http://i.troll.ws/8e76be95.png

How I want it to be:
http://i.troll.ws/3c3e930d.png

I tried using setTransparency, but when I put for example value 0 in, then the terrain also becomes transparent, and when I put value 255 in, nothing is transparent, except for the black spots I left on the map. I also tried setting useAlpha to true in Texture(java.awt.Image image, boolean useAlpha), but I didn't see any effect.

I don't know if I did something wrong in Blender or in jPCT. You can see all the settings (or most of) I used in the second screenshot.

3
Support / Texturing blender models
« on: January 31, 2013, 05:15:55 pm »
Hello, I am new to jPCT. I have some experience with LWJGL and JOGL though.

I am trying to load a house with an animated door, created with Blender into a world.

Rendered with Blender:


When imported by the object-loader:


I think something goes wrong with the back-face culling and the coordinates of the textures, and I'm not sure what to do with setEnvmapped() and  setEnvmapMode(). Furthermore, when I try to enable blending (thing.setBlending(true);), I get an ArrayIndexOutOfBoundsException at the world.draw(buffer); line.

Code: [Select]
import com.threed.jpct.*;
import javax.swing.*;


public class HouseTest {

    private String[] textures = {"door", "wall", "roof", "tile2"};
    private String thingName = "hous1";
    private int thingScale = 1;
    private World world;
    private FrameBuffer buffer;
    private Object3D thing;
    private JFrame frame;
    private int an = 2;//do a walk animation
    private float ind = 0;
    public int height = 600;
    public int width = 800;

    public static void main(String[] args) throws Exception {
        new HouseTest().loop();
    }

    public HouseTest() throws Exception {
        frame = new JFrame("Blender Model Loading");
        frame.setSize(width, height);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
        world = new World();
        world.setAmbientLight(150, 150, 150);
        for (int i = 0; i < textures.length; ++i) {
            TextureManager.getInstance().addTexture(textures[i] + ".jpg", new Texture("res/" + textures[i] + ".jpg"));
        }

        thing = loadModel("res/" + thingName + ".3ds", thingScale);

        Animation anim = new Animation(4);
        anim.createSubSequence("idle");
        anim.addKeyFrame(thing.getMesh());
       
        anim.createSubSequence("house");
        anim.addKeyFrame(loadModel("res/" + "hous1.3ds", 1).getMesh());
        anim.addKeyFrame(loadModel("res/" + "hous2.3ds", 1).getMesh());
        anim.addKeyFrame(loadModel("res/" + "hous3.3ds", 1).getMesh());
 
        thing.setAnimationSequence(anim);
        world.addObject(thing);     
        world.getCamera().setPosition(0, 0, -20);
        world.getCamera().lookAt(thing.getTransformedCenter());

        thing.setEnvmapped(true);
        thing.setEnvmapMode(false);
    }

    private void loop() throws Exception {
        buffer = new FrameBuffer(width, height, FrameBuffer.SAMPLINGMODE_NORMAL);

        while (frame.isShowing()) {
            doAnim(); 
            buffer.clear(java.awt.Color.BLUE);           
            world.renderScene(buffer);
         
            world.draw(buffer);
            buffer.update();
            buffer.display(frame.getGraphics());
            Thread.sleep(10);
        }
        buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
        buffer.dispose();
        frame.dispose();
        System.exit(0);
    }

    private Object3D loadModel(String filename, float scale) {
        Loader.setVertexOptimization(false);
        Object3D[] model = Loader.load3DS(filename, scale);

        Object3D o3d = new Object3D(0);

        Object3D temp = null;

        for (int i = 0; i < model.length; i++) {
            temp = model[i];
            temp.setCenter(SimpleVector.ORIGIN);
            temp.rotateX((float)( -.5*Math.PI));
            temp.rotateMesh();
            temp.setRotationMatrix(new Matrix());
            o3d = Object3D.mergeObjects(o3d, temp);
            o3d.build();
        }
        return o3d;
    }
    public void doAnim() {
        {
            ind += 0.018f;
            if (ind > 1f) {
                ind -= 1f;
            }
        }
        thing.animate(ind, an);
    }
}

EDIT: Don't mind the door. I forgot the texture.

Pages: [1]