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.


Messages - MarcoBelotti

Pages: [1]
1
Support / Re: Loading an ASC file
« on: March 06, 2015, 09:57:22 am »
So what kind of ASC files does JPCT support?

2
Support / Loading an ASC file
« on: March 06, 2015, 09:22:14 am »
Hi guys, I'm pretty new to the JPCT world and I'm starting a project on DTMs (digital terrain models). Basically what you get is an ASC file with a matrix of coordinates representing the elevation of that point. I saw that JPCT had a function to load these files, so I  tried to write a program, but I can't load thev 3D model
The code is

Code: [Select]
import java.io.ByteArrayInputStream;
import java.io.InputStream;

import com.threed.jpct.*;

import javax.naming.Context;
import javax.swing.*;

public class prova {

private World world;
private FrameBuffer buffer;
private Object3D map;
private JFrame frame;

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

public prova() throws Exception {

frame=new JFrame("Hello world");
frame.setSize(1024, 860);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

world = new World();
world.setAmbientLight(0, 255, 0);

    TextureManager texMan=TextureManager.getInstance();


    Texture rocks=new Texture("rocks.jpg");
    texMan.addTexture("rocks", rocks);
   
map=Loader.loadASC("411140_20_WGS.ASC", 400, false);      
    map.setTexture("rocks");
world.addObject(map);

    map.enableLazyTransformations();
    map.build();
    SimpleVector pos=map.getCenter();
    pos.scalarMul(-1f);
    map.translate(pos);
    map.rotateX((float)-Math.PI/2f);
    map.translateMesh();
    map.rotateMesh();
        map.setTranslationMatrix(new Matrix());
        map.setRotationMatrix(new Matrix());
    map.createTriangleStrips(2);


world.getCamera().setPosition(50, -50, -5);
world.getCamera().lookAt(map.getTransformedCenter());
}

public void loop() throws Exception
{
buffer = new FrameBuffer(1024, 860, FrameBuffer.SAMPLINGMODE_NORMAL);

while (frame.isShowing()) {
map.rotateY(0.01f);
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);
}
}

Note that my code can have many errors, beacuse I'm still learning. Anyone knows why it doesn't work?

Pages: [1]