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

#1
Support / Re: Problem with reinitializing
April 26, 2014, 05:03:51 PM
I solved the problem. Thanks
The Config was the Problem
#2
Support / Re: Problem with reinitializing
April 26, 2014, 03:03:50 PM
Sorry for the delay.

First time:
Loading Texture...from Image
Loading Texture...car.jpg
[ Sat Apr 26 15:01:22 CEST 2014 ] - WARNING: Unsupported Texture width (400)...resizing to a width of 256 pixels!
Loading Texture...carGreen.jpg
[ Sat Apr 26 15:01:22 CEST 2014 ] - WARNING: Unsupported Texture width (400)...resizing to a width of 256 pixels!
Loading Texture...carBlue.jpg
[ Sat Apr 26 15:01:22 CEST 2014 ] - WARNING: Unsupported Texture width (400)...resizing to a width of 256 pixels!
Loading Texture...carYellow.jpg
[ Sat Apr 26 15:01:22 CEST 2014 ] - WARNING: Unsupported Texture width (400)...resizing to a width of 256 pixels!
Loading Texture...carRed.jpg
[ Sat Apr 26 15:01:22 CEST 2014 ] - WARNING: Unsupported Texture width (400)...resizing to a width of 256 pixels!
Loading file car.3ds
File car.3ds loaded...10251 bytes
Processing new material carcar.jpg!
Processing object from 3DS-file: Car
Object 'Car_jPCT0' created using 362 polygons and 316 vertices.
could not load 'loading.png'
[ Sat Apr 26 15:01:34 CEST 2014 ] - ERROR: A texture with the name 'skyDome' has been declared twice!
Loading Texture...car.jpg
[ Sat Apr 26 15:01:34 CEST 2014 ] - WARNING: Unsupported Texture width (400)...resizing to a width of 256 pixels!
[ Sat Apr 26 15:01:34 CEST 2014 ] - ERROR: A texture with the name 'car.jpg' has been declared twice!
Loading Texture...carGreen.jpg
[ Sat Apr 26 15:01:34 CEST 2014 ] - WARNING: Unsupported Texture width (400)...resizing to a width of 256 pixels!
[ Sat Apr 26 15:01:34 CEST 2014 ] - ERROR: A texture with the name 'carGreen' has been declared twice!
Loading Texture...carBlue.jpg
[ Sat Apr 26 15:01:34 CEST 2014 ] - WARNING: Unsupported Texture width (400)...resizing to a width of 256 pixels!
[ Sat Apr 26 15:01:34 CEST 2014 ] - ERROR: A texture with the name 'carBlue' has been declared twice!
Loading Texture...carYellow.jpg
[ Sat Apr 26 15:01:34 CEST 2014 ] - WARNING: Unsupported Texture width (400)...resizing to a width of 256 pixels!
[ Sat Apr 26 15:01:34 CEST 2014 ] - ERROR: A texture with the name 'carYellow' has been declared twice!
Loading Texture...carRed.jpg
[ Sat Apr 26 15:01:34 CEST 2014 ] - WARNING: Unsupported Texture width (400)...resizing to a width of 256 pixels!
[ Sat Apr 26 15:01:34 CEST 2014 ] - ERROR: A texture with the name 'carRed' has been declared twice!
[ Sat Apr 26 15:01:34 CEST 2014 ] - ERROR: A texture with the name 'White' has been declared twice!
[ Sat Apr 26 15:01:34 CEST 2014 ] - ERROR: A texture with the name 'Gray' has been declared twice!
[ Sat Apr 26 15:01:34 CEST 2014 ] - ERROR: A texture with the name 'Black' has been declared twice!
[ Sat Apr 26 15:01:34 CEST 2014 ] - ERROR: A texture with the name 'Blue' has been declared twice!
[ Sat Apr 26 15:01:34 CEST 2014 ] - ERROR: A texture with the name 'Underlay' has been declared twice!
Loading file car.3ds
File car.3ds loaded...10251 bytes
Processing new material carcar.jpg!
Processing object from 3DS-file: Car
Object 'Car_jPCT3' created using 362 polygons and 316 vertices.
Java version is: 1.7.0_17
-> support for BufferedImage
Version helper for 1.5+ initialized!
-> using BufferedImage
Software renderer (OpenGL mode) initialized
Software renderer disposed
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Created new Object3D 8
Created new Object3D 18
Created new Object3D 28
Created new Object3D 39
Created new Object3D 42
Created new Object3D 45
Created new Object3D 51
Created new Object3D 78
Created new Object3D 109
Created new Object3D 131
Created new Object3D 153
Created new Object3D 177
Created new Object3D 180
Created new Object3D 185
Created new Object3D 191
Created new Object3D 199
Created new Object3D 202
Created new Object3D 207
Created new Object3D 215
Created new Object3D 227
Created new Object3D 244
Created new Object3D 264
Created new Object3D 268
Created new Object3D 273
Created new Object3D 278
Created new Object3D 286
Created new Object3D 294
Created new Object3D 302
Software renderer disposed
Current mode:800 x 600 x 32 @30Hz
Driver is: igdumdim64/10.18.10.3412 on Intel / Intel(R) HD Graphics 4000
GL_ARB_texture_env_combine supported and used!
FBO supported and used!
VBO supported and used!
OpenGL renderer initialized (using 4 texture stages)
New WorldProcessor created using 1 thread(s) and granularity of 1!
Creating new world processor buffer for thread Thread-7

Second time:

[ Sat Apr 26 15:03:18 CEST 2014 ] - ERROR: A texture with the name 'skyDome' has been declared twice!
Loading Texture...car.jpg
[ Sat Apr 26 15:03:18 CEST 2014 ] - WARNING: Unsupported Texture width (400)...resizing to a width of 256 pixels!
[ Sat Apr 26 15:03:18 CEST 2014 ] - ERROR: A texture with the name 'car.jpg' has been declared twice!
Loading Texture...carGreen.jpg
[ Sat Apr 26 15:03:18 CEST 2014 ] - WARNING: Unsupported Texture width (400)...resizing to a width of 256 pixels!
[ Sat Apr 26 15:03:18 CEST 2014 ] - ERROR: A texture with the name 'carGreen' has been declared twice!
Loading Texture...carBlue.jpg
[ Sat Apr 26 15:03:18 CEST 2014 ] - WARNING: Unsupported Texture width (400)...resizing to a width of 256 pixels!
[ Sat Apr 26 15:03:18 CEST 2014 ] - ERROR: A texture with the name 'carBlue' has been declared twice!
Loading Texture...carYellow.jpg
[ Sat Apr 26 15:03:18 CEST 2014 ] - WARNING: Unsupported Texture width (400)...resizing to a width of 256 pixels!
[ Sat Apr 26 15:03:18 CEST 2014 ] - ERROR: A texture with the name 'carYellow' has been declared twice!
Loading Texture...carRed.jpg
[ Sat Apr 26 15:03:18 CEST 2014 ] - WARNING: Unsupported Texture width (400)...resizing to a width of 256 pixels!
[ Sat Apr 26 15:03:18 CEST 2014 ] - ERROR: A texture with the name 'carRed' has been declared twice!
[ Sat Apr 26 15:03:18 CEST 2014 ] - ERROR: A texture with the name 'White' has been declared twice!
[ Sat Apr 26 15:03:18 CEST 2014 ] - ERROR: A texture with the name 'Gray' has been declared twice!
[ Sat Apr 26 15:03:18 CEST 2014 ] - ERROR: A texture with the name 'Black' has been declared twice!
[ Sat Apr 26 15:03:18 CEST 2014 ] - ERROR: A texture with the name 'Blue' has been declared twice!
[ Sat Apr 26 15:03:18 CEST 2014 ] - ERROR: A texture with the name 'Underlay' has been declared twice!
Loading file car.3ds
File car.3ds loaded...10251 bytes
Processing new material carcar.jpg!
Processing object from 3DS-file: Car
Object 'Car_jPCT313' created using 362 polygons and 316 vertices.
Java version is: 1.7.0_17
-> support for BufferedImage
Version helper for 1.5+ initialized!
-> using BufferedImage
Software renderer (OpenGL mode) initialized
Software renderer disposed
Created new Object3D 318
Created new Object3D 328
Created new Object3D 338
Created new Object3D 349
Created new Object3D 352
Created new Object3D 355
Created new Object3D 361
Created new Object3D 388
Created new Object3D 419
Created new Object3D 441
Created new Object3D 463
Created new Object3D 487
Created new Object3D 490
Created new Object3D 495
Created new Object3D 501
Created new Object3D 509
Created new Object3D 512
Created new Object3D 517
Created new Object3D 525
Created new Object3D 537
Created new Object3D 554
Created new Object3D 574
Created new Object3D 578
Created new Object3D 583
Created new Object3D 588
Created new Object3D 596
Created new Object3D 604
Created new Object3D 612
Visibility lists disposed!
Software renderer disposed
Current mode:800 x 600 x 32 @30Hz
Driver is: igdumdim64/10.18.10.3412 on Intel / Intel(R) HD Graphics 4000
GL_ARB_texture_env_combine supported and used!
FBO supported and used!
VBO supported and used!
OpenGL renderer initialized (using 4 texture stages)
New WorldProcessor created using 1 thread(s) and granularity of 1!
Creating new world processor buffer for thread Thread-8
java.lang.NullPointerException
   at org.lwjgl.util.glu.MipMap.gluScaleImage(MipMap.java:235)
   at org.lwjgl.util.glu.MipMap.gluBuild2DMipmaps(MipMap.java:142)
   at org.lwjgl.util.glu.GLU.gluBuild2DMipmaps(GLU.java:384)
   at com.threed.jpct.GLBase.convertTexture(GLBase.java:1738)
   at com.threed.jpct.GLRenderer.setTextures(GLRenderer.java:1438)
   at com.threed.jpct.GLRenderer.drawVertexArray(GLRenderer.java:1051)
   at com.threed.jpct.World.draw(World.java:2100)
   at com.threed.jpct.World.draw(World.java:2011)
   at com.threed.jpct.World.draw(World.java:1607)
   at at.fhhooe.mc.trafficsim.threeDPerspective.DDDInit$2.run(DDDInit.java:247)
   at java.lang.Thread.run(Unknown Source)
#3
Support / Re: Problem with reinitializing
April 25, 2014, 12:28:46 PM
Which logs do you mean? The jpct console statments or a specific exception log or ...?
#4
Support / Re: Problem with reinitializing
April 25, 2014, 11:16:19 AM
After I used Display.destroy() the Exception changed:

java.lang.IllegalStateException: Only one LWJGL context may be instantiated at any one time.
   at org.lwjgl.opengl.Display.create(Display.java:819)
   at org.lwjgl.opengl.Display.create(Display.java:757)
   at com.threed.jpct.GLHelper.init(GLHelper.java:208)
   at com.threed.jpct.GLRenderer.init(GLRenderer.java:24)
   at com.threed.jpct.FrameBuffer.enableRenderer(FrameBuffer.java:1134)
   at com.threed.jpct.FrameBuffer.enableRenderer(FrameBuffer.java:753)
   at com.threed.jpct.FrameBuffer.enableRenderer(FrameBuffer.java:700)
   at at.fhhooe.mc.trafficsim.threeDPerspective.DDDInit$2.run(DDDInit.java:234)
   at java.lang.Thread.run(Unknown Source)

But still no clue why
#5
Support / Problem with reinitializing
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:
public class TestCommand implements IHandler {
DDDInit window = new DDDInit();

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

}

@Override
public void dispose() {

}

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

@Override
public boolean isEnabled() {
return true;
}

@Override
public boolean isHandled() {
return true;
}

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

}

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

public DDDInit() {

Config();
// 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
world.setFogging(World.FOGGING_ENABLED);
// 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
TextureManager.getInstance().addTexture("skyDome",
new Texture(10, 10, Color.blue));

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

TextureManager.getInstance().addTexture("White",
new Texture(8, 8, Color.white));
TextureManager.getInstance().addTexture("Gray",
new Texture(8, 8, new Color(200, 200, 200)));
TextureManager.getInstance().addTexture("Black",
new Texture(8, 8, Color.BLACK));
TextureManager.getInstance().addTexture("Blue",
new Texture(8, 8, Color.BLUE));
TextureManager.getInstance().addTexture("Underlay",
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);

SimulationKernel.getInstance().addInputChangedListener(
new ModelInputChangedListener() {

@Override
public void inputChanged(SimulationModel newModel) {
world.removeAllObjects();
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() {

@Override
public void run() {
// window size
buffer = new FrameBuffer(800, 600,
FrameBuffer.SAMPLINGMODE_NORMAL);
// hardware renderer
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
buffer.enableRenderer(IRenderer.RENDERER_OPENGL);
// draw loop
while (!org.lwjgl.opengl.Display.isCloseRequested()) {
// background color
buffer.clear(java.awt.Color.WHITE);
world.renderScene(buffer);
world.draw(buffer);
buffer.update();

// draw HUD
blitString();

buffer.displayGLOnly();
// check for mouse or key event
move();
poll();

if (world != null) {
updateRoadnetwork();
updateVehicles();

}
}
buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
buffer.dispose();
}
}

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:
Exception in thread "Thread-9" java.lang.NullPointerException
   at org.lwjgl.util.glu.MipMap.gluScaleImage(MipMap.java:235)
   at org.lwjgl.util.glu.MipMap.gluBuild2DMipmaps(MipMap.java:142)
   at org.lwjgl.util.glu.GLU.gluBuild2DMipmaps(GLU.java:384)
   at com.threed.jpct.GLBase.convertTexture(GLBase.java:1738)
   at com.threed.jpct.GLRenderer.setTextures(GLRenderer.java:1438)
   at com.threed.jpct.GLRenderer.drawVertexArray(GLRenderer.java:1051)
   at com.threed.jpct.World.draw(World.java:2100)
   at com.threed.jpct.World.draw(World.java:2011)
   at com.threed.jpct.World.draw(World.java:1607)
   at at.fhhooe.mc.trafficsim.threeDPerspective.DDDInit$2.run(DDDInit.java:238)
   at java.lang.Thread.run(Unknown 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.
#6
Support / Picking
March 08, 2014, 10:08:06 AM
Hello,
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:


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];
System.out.println();
}


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:

    obj.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
    obj.setCollisionOptimization(true);
#7
Support / Re: Camera rotation span
March 02, 2014, 12:28:32 PM
Well I tried to implement your approach but it just didn t work. So I implemented a different version which rotates my camera correctly.

private void orbitalRotationVertical(float delta) {
   float dist = getCamDistance();
   camera.moveCamera(Camera.CAMERA_MOVEIN, dist);
   camera.rotateCameraAxis(new SimpleVector(1, 0, 0), -delta);
        camera.moveCamera(Camera.CAMERA_MOVEOUT, dist);
}

But now I want to implement an if which should check the current rotation of the camera. If this rotation is above 90 Degree or below 0 Degree the camera shouldn t rotate at all.
My question now is which angle do I need for this if and how do I calc it?.

Pseudo:
if(camera.getRotation() < Math.pi/2 - 0.001 & camera.getRotation > 0){
        camera.rotate()
}
#8
Support / Re: Camera rotation span
March 01, 2014, 01:52:39 PM
Yesterday I tried you implementation and I ran into a few question. Specificly a few of your variables:

camDist; camYMax; lookAtYMax, lookAtYMin.

I didnt realy understand what these values should represent. Could you explain it?
#9
Support / Re: Camera rotation span
February 27, 2014, 02:06:48 PM
Sounds correct but my problem is that I dont have a specific point to look at. So I get the distance through a while loop which moves my camera in til the z coord. is 0. the it rotates and moves out again.
Based on this I want to rotate my camera based on its postion which works at the moment but I want to implement a limit how far the camera can rotate. Cause if I rotate the camera more than 90 degrees it stands on its head. If i rotate below 0 degrees the camera looks at my world from below.
I want to calc its current rotation and if its between 1 and 90 degrees its correct else rotate back.
#10
Support / Camera rotation span
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.
#11
Support / Re: Object3D possiblities
January 16, 2014, 11:21:37 PM
Explanation:
RoadSegment is one road of my road network,
The lanesegments are part of these roadsegment -> so every roadsegment can contain one or multiple lanesegments,
The vector contains all points of my lanesegment, first index is the first point of the polygon, then the second, when i
come to half of the vector the points are the mirrored points from before. So each part of the lanesegment is an rectangle.

I tried to construct a for loop which moves through my vector and creates a triangle. At the end it should contain vector.length / 2 triangles +
the mirrored version of these triangles. Because of that I skipped the case when i and j are equal. Now it should create multiple rectangle based
on triangles and the correct position of the vector points.

Concerning the pen and paper advice:
I already did that and i thought my logic was correct. Here is a quick png which I used for my case:
https://www.dropbox.com/sh/hyvk3wha4akoxok/0kpYjcglKa

I hope you can help :)
#12
Support / Re: Object3D possiblities
January 16, 2014, 02:52:07 PM
Today I tried it again but it doesn t look right. It doesn t look like the 2d right polygon.
My code today:

public static void drawRoadSegment(RoadSegment seg, Matrix matrix) {
for (LaneSegment ls : seg.getLaneSegments()) {
List leftEdge = ls.getLeftEdge();
List rightEdge = ls.getRightEdge();
leftEdge = matrix.multiply(leftEdge);
rightEdge = matrix.multiply(rightEdge);

Vector<Point> tmp = new Vector<Point>();
for (int i = 0; i < leftEdge.size() - 1; i++) {
int x11 = (int) leftEdge.get(i).x;
int y11 = (int) leftEdge.get(i).y;
int x21 = (int) leftEdge.get(i + 1).x;
int y21 = (int) leftEdge.get(i + 1).y;
tmp.add(new Point(x11, y11));
tmp.add(new Point(x21, y21));
}
for (int i = rightEdge.size() - 1; i > 0; i--) {
int x12 = (int) rightEdge.get(i).x;
int y12 = (int) rightEdge.get(i).y;
int x22 = (int) rightEdge.get(i - 1).x;
int y22 = (int) rightEdge.get(i - 1).y;
tmp.add(new Point(x12, y12));
tmp.add(new Point(x22, y22));
}
                        //the tmp vector contains the correct x/y points for the polygon

int j = tmp.size() - 1;
                        //loop to create the correct triangles
for (int i = 0; i < tmp.size() - 1; i++) {
if (j != i + 1) {
SimpleVector s1 = new SimpleVector(tmp.get(i).getX(), tmp
.get(i).getY(), 0);
SimpleVector s2 = new SimpleVector(tmp.get(i + 1).getX(),
tmp.get(i + 1).getY(), 0);
SimpleVector s3 = new SimpleVector(tmp.get(j).getX(), tmp
.get(j).getY(), 0);

Object3D obj = new Object3D(tmp.size() - 1);
obj.addTriangle(s1, s2, s3);
obj.build();
world.addObject(obj);
j--;
}
}
}
}


But it displays something, but just not entirly correct.
Now I would like to know if my logic is correct or if i made a mistake.

Here: https://www.dropbox.com/sh/hyvk3wha4akoxok/0kpYjcglKa
are two screen shots, one 2d and one 3d;
#13
Support / Re: Object3D possiblities
January 16, 2014, 09:46:34 AM
Here is a picture of how the polygon looks like:
https://www.dropbox.com/sh/hyvk3wha4akoxok/0kpYjcglKa

I just want to display the same polygon in my jpct world. I don t necessarily need to add a z value, cause the roadsegments has no real hight.
I drew the polygon like this: g2d.draw(lane);

Before that i created the Polygon with 2 for loops:

Polygon lane = new Polygon();
for (int i = 0; i < leftEdge.size() - 1; i++) {
   int x11 = (int) leftEdge.get(i).x;
   int y11 = (int) leftEdge.get(i).y;
   int x21 = (int) leftEdge.get(i + 1).x;
   int y21 = (int) leftEdge.get(i + 1).y;
   lane.addPoint(x11, y11);
   lane.addPoint(x21, y21);
}
for (int i = rightEdge.size() - 1; i > 0; i--) {
   int x12 = (int) rightEdge.get(i).x;
   int y12 = (int) rightEdge.get(i).y;
   int x22 = (int) rightEdge.get(i - 1).x;
   int y22 = (int) rightEdge.get(i - 1).y;
   lane.addPoint(x12, y12);
   lane.addPoint(x22, y22);
}

The rightEdge and leftEdge Vector contains the roadsegment points.


#14
Support / Re: Object3D possiblities
January 15, 2014, 05:44:24 PM
Hello again.
This last week i tried to create a custom Object3D with addTriangle() but it didn't work as I expected.
I have a 2D polygon of a road segment which contains two int arrays:

int xPoly[] = { 468, 551, 551, 606, 606, 676, 678, 609, 609, 608, 608,
               608, 608, 607, 607, 607, 607, 606, 606, 605, 605, 551, 551, 468 };
int yPoly[] = { 424, 419, 419, 426, 426, 358, 362, 429, 429, 430, 430,
               430, 430, 430, 430, 430, 430, 430, 430, 430, 430, 423, 423, 428 };

Now my question is, how to create a Object3D based on these two arrays. Can I use the constructor: public Object3D(float[] coordinates, float[] uvs, int[] indices, int textureId). If that's possible, can someone post a example how to use this constructor in my case?

Thanks in advance
#15
Support / Object3D possiblities
January 10, 2014, 09:54:48 PM
Hello
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);
         t.add(0.0f);
      }
      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
      obj.setVisibility(true);
      obj.build();

      box = Primitives.getBox(13f, 2f);
      box.setTexture("box");
      box.setEnvmapped(Object3D.ENVMAP_ENABLED);
      box.build();

      world.addObject(box);
      world.getCamera().lookAt(box.getTransformedCenter());
    }
   }

Please help