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

Pages: [1]
Support / Problem with reinitializing
« on: April 25, 2014, 11:01:27 am »
Hallo I have a problem if I want to run my jpct world two times. My initializiation looks like this:
Code: [Select]
public class TestCommand implements IHandler {
DDDInit window = new DDDInit();

public void addHandlerListener(IHandlerListener handlerListener) {
// TODO Auto-generated method stub


public void dispose() {


public Object execute(ExecutionEvent event) throws ExecutionException {
if (!window.isRunning()) {
return null;

public boolean isEnabled() {
return true;

public boolean isHandled() {
return true;

public void removeHandlerListener(IHandlerListener handlerListener) {
// TODO Auto-generated method stub


and my jpct class looks like this:
Code: [Select]
private void Config() {
// window name
Config.glWindowName = "3D Perspective";
Config.glAvoidTextureCopies = true;
// Config.useMultipleThreads = true;

public DDDInit() {

// is camera positioned
cameraSet = false;

world = new World();
// world light values
world.setAmbientLight(255, 255, 255);
// set init postion of camera
world.getCamera().setPosition(0, 0, distance);

// set fogging
// fog distance
world.setFogParameters(FOGGING_DISTANCE, FOG_COLOR.getRed(),
FOG_COLOR.getGreen(), FOG_COLOR.getBlue());
// render objects which are within 10000 range
world.setClippingPlanes(0, CLIPPING_DISTANCE);

camera = world.getCamera();

Bundle bundle = FrameworkUtil.getBundle(SimulationView.class);

URL url = FileLocator.find(bundle, new Path("texture"), null);

// load textures
new Texture(10, 10,;

new Texture(url, "car.jpg"));
new Texture(url, "carGreen.jpg"));
new Texture(url, "carBlue.jpg"));
new Texture(url, "carYellow.jpg"));
new Texture(url, "carRed.jpg"));

new Texture(8, 8, Color.white));
new Texture(8, 8, new Color(200, 200, 200)));
new Texture(8, 8, Color.BLACK));
new Texture(8, 8, Color.BLUE));
new Texture(8, 8, Color.GREEN));
// load 3ds file once
url = FileLocator.find(bundle, new Path("3dsObjects"), null);
ThreedsObjects = Loader.load3DS(url, "car.3ds", 1);

new ModelInputChangedListener() {

public void inputChanged(SimulationModel newModel) {
listOfRoadSegments = new Vector<RoadSegment>();
listOfAbstractJunctions = new Vector<AbstractJunction>();
vehicleMapping = new TreeMap<Vehicle, Object3D>();
firstTime = true;
worldOffsetX = 0;
worldOffsetY = 0;
underlayPlane = null;

* Initialize the 3D world
public void init3D() {
// app is running
isRunning = true;
// run in seperate thread
try {
Thread run = new Thread(new Runnable() {

public void run() {
// window size
buffer = new FrameBuffer(800, 600,
// hardware renderer
// draw loop
while (!org.lwjgl.opengl.Display.isCloseRequested()) {
// background color

// draw HUD

// check for mouse or key event

if (world != null) {

If I run my code for the first time I have no Problems but if I close my window and want to reinitialize the same way I get a NullPointerException at world.draw(buffer).

Exception in thread "Thread-9" java.lang.NullPointerException
   at org.lwjgl.util.glu.MipMap.gluScaleImage(
   at org.lwjgl.util.glu.MipMap.gluBuild2DMipmaps(
   at org.lwjgl.util.glu.GLU.gluBuild2DMipmaps(
   at com.threed.jpct.GLBase.convertTexture(
   at com.threed.jpct.GLRenderer.setTextures(
   at com.threed.jpct.GLRenderer.drawVertexArray(
   at com.threed.jpct.World.draw(
   at com.threed.jpct.World.draw(
   at com.threed.jpct.World.draw(
   at Source)

I dont know why this is happening because I initialize each time a completely new Instance of the DDDInit class. Or does jpct use a seperate thread which doesn t close?
Please help.

Support / Picking
« on: March 08, 2014, 10:08:06 am »
I m working on a 3D world and Im trying to translate my camera position but i want to attach the mouse cursor at the clicked position. If I move my camera my mouse cursor stays at the position where I first clicked. My problem now is that I implemented an orbital camera. cause of that I cant calc a factor based on the camera hight( camera.getPostion().z) but I need postion in the world where I clicked with the mouse.
I tried to implement the picking methods in the forum but I never got a correct object.
My code:

Code: [Select]
private static void getObject3DatMouse(int x, int y) {
SimpleVector dir = Interact2D.reproject2D3DWS(camera, buffer, x, y).normalize();
Object[] res = world.calcMinDistanceAndObject3D(camera.getPosition(),dir, 10000 /* or whatever */);
int[] res1 = Interact2D.pickPolygon(world.getVisibilityList(), camera.getPosition(), dir);
if (res1 != null) {
Object3D picked = world.getObject(res1[1]);
Object3D pciked = (Object3D) res[1];

I just tried to get an object based on the Mouse.getX() and Mouse.getY() positon but I always res:
  • = 1.0E12 and [1]= null

the res1 array is always empty.
So my question is, if I do the picking incorrectly or I have to improve it somehow.
Of cause I included:


Support / Camera rotation span
« on: February 27, 2014, 01:01:45 pm »
Hello Im currently working on a project which needs an orbital camera movement. I want to rotate my camera vertically around a point. At the moment I tried it like this:

camera.moveCamera(Camera.CAMERA_MOVEIN, dist); //dist to rotation point
//-delta to invert camera
camera.rotateCameraAxis(new SimpleVector(1, 0, 0), -delta* cameraRotationFactor);
camera.moveCamera(Camera.CAMERA_MOVEOUT, dist);

Now I want to limit the range of the camera rotation. So I want the the camera can rotate between 1 and 90 Degrees.
My question is how can I limit the camera rotation to a specific rotation degree?.
I tried to calc the angle based on the rotation matrix and based on the methods in this forum but I didnt get the correct values.
Please help.

Support / Object3D possiblities
« on: January 10, 2014, 09:54:48 pm »
I'm working now on a 3D perspectiv of a roadnetwork. I have Geodatas where and how each road segment has to be drawn. My problem at the moment is the following:
I'm trying to create a Object3D object for each road segment but I don t know how to initialize this object correctly. Cause the roadsegments are polygons and i tried to initialize the
object with all points of the polygon, an uvs array, a  normals array and an empty texture, (TextureManager.TEXTURE_NOTFOUND ). But when I try to render the world(road segment included)
nothing is shown. Of course i changed the camera position and I always look at the object but there just isn't anything.
My question now is: if its better to draw polylines and create a custom polygon or have i done something wrong with the object3d?
Hopefully my english is understandable.

Code snip:
public static void drawRoadSegment(RoadSegment seg) {

      float[] tmp = new float[((seg.getBounds().xpoints.length) * 3)];

      int[] x = seg.getBounds().xpoints;
      int[] y = seg.getBounds().ypoints;
      Vector<Float> t = new Vector<Float>();

      for (int i = 0; i < seg.getBounds().xpoints.length; i++) {
         t.add((float) x);
         t.add((float) y);
      for (int i = 0; i < t.size(); i++) {
         tmp = t.elementAt(i);

      Object3D obj = new Object3D(tmp, null, null, TextureManager.TEXTURE_NOTFOUND); //in this case I tried to use null for uvs and normals but I tried it also with initialized arrays

      box = Primitives.getBox(13f, 2f);


Please help

Support / Rounded Cube
« on: September 17, 2012, 10:38:32 am »
I have a small problem. In the last 4 month i tried to create a cube with rounded edges. First I tried OpenGl ES and finally I found my way to jpct-ae. Now its a imported obj file.
Problem: I try to start new Activities based on the cube side the user is looking at, but I don t want to check for all 4 rotation matrices of each cube side. So I wanted to ask if someone knows a better solution. I heard Quaternion are a good way to go, but I don t realy have a clue how they work.
Code: [Select]
public class MyMath {

public static int getVisibleCubeSide(SimpleVector vector){
int vectorX = (int) Math.round(vector.x);
int vectorY = (int) Math.round(vector.y);
int vectorZ = (int) Math.round(vector.z);
    int[][] posibilities = new int[6][4];

posibilities[0][0] = 0;
posibilities[0][1] = 0;
posibilities[0][2] = 1;
posibilities[0][3] = 2;

posibilities[1][0] = 0;
posibilities[1][1] = 1;
posibilities[1][2] = 0;
posibilities[1][3] = 1;

posibilities[2][0] = 0;
posibilities[2][1] = 0;
posibilities[2][2] = -1;
posibilities[2][3] = 0;

posibilities[3][0] = 0;
posibilities[3][1] = -1;
posibilities[3][2] = 0;
posibilities[3][3] = 5;

posibilities[4][0] = 1;
posibilities[4][1] = 0;
posibilities[4][2] = 0;
posibilities[4][3] = 4;

//new termine
posibilities[5][0] = -1;
posibilities[5][1] = 0;
posibilities[5][2] = 0;
posibilities[5][3] = 3;

//checks if the parameter vector equals one of the vectors above
for(int i = 0; i < 6; i++){
if(vectorX == posibilities[i][0] && vectorY == posibilities[i][1] && vectorZ == posibilities[i][2]){
Log.i("side", "v" + vector.toString());
Log.i("side", "s: " + posibilities[i][3]);
return posibilities[i][3];

Log.i("side", "" + -1);
return -1;
Thats how i calculate my cube side atm. but it s not always correct cause i only check for one rotation matrix for each side but each side has 4 rotation matrices.
So I hope somebody has a good idea how to calculate the cube side based on matrices.

Pages: [1]