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 - Yatoom

#1
Support / Moving textures in the Hello World example
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 / Re: Semi-transparency
February 03, 2013, 11:14:41 PM
I am using a merge-call I think.


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


I think I can figure the rest out myself. Thank you very much for your help!
#3
Support / Re: Semi-transparency
February 03, 2013, 10:43:38 PM
Quote from: EgonOlsen on February 03, 2013, 10:39:27 PM
If it's another object,

The terrain and the water are two separate objects in Blender, but I export it as one 3ds model. So, just to make sure... I guess this counts as one object?
#4
Support / Semi-transparency
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.
#5
Support / Re: getting started...
February 01, 2013, 08:32:10 PM
From what I understand, you are making a splash screen and have not started to create the actual game. And for this splash screen, you want to make an animation. So, this animation consists of several textures which are put in an array or something, which then are applied on the background. But that does not work for some reason. So, it is best if you copy-paste your code here so we can check what went wrong.

Furthermore, you might want to use wild-cards in your imports, so when you do for example: import com.threed.jpct.*;, then you don't need to import every class apart. The stuff you import is indeed a package (or namespace) with more classes. Sometimes, it is also nice to use a static import: import static com.threed.jpct.Camera.*;. Then, you can write CAMERA_MOVOUT instead of Camera.CAMERA_MOVEOUT.
#6
Support / Re: Texturing blender models
January 31, 2013, 10:33:18 PM
Quote from: EgonOlsen on January 31, 2013, 08:07:14 PM
Make sure that the export from blender exports them properly.

Thanks! This was the problem. It took me quite some time to figure out what I did wrong and how to fix it. I will explain what I did in short (for people with the same problem).

Initially, I tried to select an object, then in the material-tab (Properties Window), I applied a standard surface-material on it and then, in the texture-tab, select type: Image or Movie and load the desired image file. Then in the Mapping section, I took Coordinates: Global and Projection: Cube. But this when you export the 3ds model, the coordinates are not exported with it.

Fix Coordinates:
Set coordinates to UV and get to the UV-editor in edit mode. Select all faces of the object (press A), then go to mesh --> UV-unwrap --> unwrap. In the UV-editor, scale until you have a nice mapping. Make sure that you apply the scaling you did in object mode to editing mode: select in Object Mode, Object --> Apply --> Scale.

Fix Normals:
Go to view-->properties (or press N), then scroll down to Mesh Display and then under normals, click on the buttons to show the normals of the faces and the normals of the vertices. Then, fix the normals that are incorrect by ctrl-f --> flip normals.

Fix Transparancy:
Continue here: http://www.jpct.net/forum2/index.php/topic,3203.0.html
#7
Support / Re: Texturing blender models
January 31, 2013, 07:13:03 PM
Quote from: EgonOlsen on January 31, 2013, 05:42:47 PM
You enable environment mapping on the obj. Don't do that... ;)

Thanks. But I don't think that is the real problem in my case.
When I disable it, it still does not look good.

But, I also experienced a difference between the software renderer and the OpenGL renderer.

Software Renderer:


OpenGL Renderer:
#8
Support / Texturing blender models
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.


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.