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

#1
Thanks that worked.
#2
I tried without normalize still I get same result.
#3
import org.lwjgl.opengl.*
Display.setTitle("abc");

Try this.
#4
Hello,

I am do some 2D drawing in bottom of the screen so trying to convert the 2D position into 3D using reproject2D3DWS method and doing some calculations and converting back into 2D using project3D2D method. But I always get the returned 2D values around the middle of the screen.

here is a sample code to reproduce it.

System.out.println("X:"+e.getX() +",Y:"+e.getY());
      SimpleVector v = Interact2D.reproject2D3DWS(jpctPanel.getWorld().getCamera(), jpctPanel.getBuffer(),
            e.getX(), e.getY()).normalize();
      System.out.println(Interact2D.project3D2D(jpctPanel.getCamera(), jpctPanel.getBuffer(), v));

Mouse coord: X:420,Y:458
Output of above code: (904.2925,487.36615,0.0047869836)

X:1480,Y:402
(909.04944,487.11993,0.0047874274)

any help.

Thanks.
#5
Support / Re: getting Indexbuffer from Object 3d
December 22, 2015, 01:23:41 PM
After so many days of trial and error, adding obj.setCenter(new SimpleVector(0, 0, 0)); after build has fixed my problem.
#6
Support / Re: getting Indexbuffer from Object 3d
December 17, 2015, 12:14:13 PM
I tried it but no luck. I tried to set the setCenterOfMassTransform of the RigidBody to 0 still no luck. It is just 3 unit difference in Y axis when I add it manually it messes up for other shapes.
#7
Support / Re: getting Indexbuffer from Object 3d
December 17, 2015, 07:06:43 AM
Just another issue on the same. When I do debug draw of bullet objects there is some difference in Y axis between the Object3D and Shape and this difference only appears for Cone , Pyramid and  Cube, sphere or ellipsoid works fine. See the attachment. Both are having same GImpactShape created using the code in my previous replies.



#8
Support / Re: getting Indexbuffer from Object 3d
December 17, 2015, 06:24:14 AM
Thanks Egon. Got it working now. There were two mistakes
1. Wrong indices
2. Wrong vertex length passed to the TriangleIndexVertexArray Constructor. (Reason for the IndexOutofBoundException).

final code:
private ByteBuffer createIndexBuffer() {
setvController(new VertexController(object3D));

ByteBuffer indexBuffer = BufferUtils.createByteBuffer(object3D.getMesh().getVertexCount() * 4).order(ByteOrder.nativeOrder());
indexBuffer.clear();

PolygonManager pMgr = object3D.getPolygonManager();
SimpleVector vertices[] = vController.getSourceMesh();
SimpleVector vertex;
int index = 0;
for (int i=0; i<pMgr.getMaxPolygonID(); i++) {
vertex = null;
for(int vertexNumber=0; vertexNumber<3; vertexNumber++) {
vertex = pMgr.getTransformedVertex(i, vertexNumber);
index = 0;
for(SimpleVector sourceVertex : vertices){
if(sourceVertex.equals(vertex)) {
indexBuffer.putInt(index);
break;
}
index++;
}
vertexNumber++;
}
}
return indexBuffer;
}



private static TriangleIndexVertexArray createIndexVertexArray(Object3D obj) {
RigidObject ro = RigidObjectManager.getInstance().getRigidObject(obj.getName());


int numTriangles = obj.getMesh().getTriangleCount();
int numVertices = obj.getMesh().getVertexCount();

ByteBuffer indexBuffer = ro.getIndexBuffer();

ByteBuffer vertexBuffer = BufferUtils.createByteBuffer(numVertices * 4).order(ByteOrder.nativeOrder());
vertexBuffer.clear();

SimpleVector[] vertices = ro.getvController().getSourceMesh();
for (int i = 0; i < vertices.length; i++) {
vertexBuffer.putFloat(vertices[i].x);
vertexBuffer.putFloat(vertices[i].y);
vertexBuffer.putFloat(vertices[i].z);
}
vertexBuffer.rewind();
indexBuffer.rewind();

TriangleIndexVertexArray vertexArray = new TriangleIndexVertexArray(numTriangles, indexBuffer, 3*4, vertices.length, vertexBuffer, 3*4);
return vertexArray;
}
#9
Support / Re: getting Indexbuffer from Object 3d
December 16, 2015, 06:14:41 PM
how to iterate over the polygons? pMgr.getTransformedVertex(polyID, vertexNumber)  I just see this method to get the vertex.
#10
Support / getting Indexbuffer from Object 3d
December 16, 2015, 04:25:01 PM
Hello,

I am trying to create a TriangleIndexVertexArray Object from Object3D for GImpactMeshShape (JBullet intergration). How do I get the IndexBuffer? The below code works for BvhTriangleMeshShape but GImpactMeshShape  throws IndexOutOfBoundsException. calculating the indexBuffer is the problem. Please help.

private static TriangleIndexVertexArray createIndexVertexArray(Object3D obj) {
RigidObject ro = RigidObjectManager.getInstance().getRigidObject(obj.getName());

int numTriangles = obj.getMesh().getTriangleCount();
int numVertices = obj.getMesh().getVertexCount();
// int numVertices = obj.getMesh().getUniqueVertexCount();
//4 represents Byte size of Integer
ByteBuffer indexBuffer = BufferUtils.createByteBuffer(numVertices * 4).order(ByteOrder.nativeOrder());
for (int i=0; i<numTriangles; i++) {

indexBuffer.putInt(i);
indexBuffer.putInt(i);
indexBuffer.putInt(i);
}

ByteBuffer vertexBuffer = BufferUtils.createByteBuffer(numVertices * 4).order(ByteOrder.nativeOrder());
vertexBuffer.clear();

SimpleVector[] vertices = ro.getvController().getSourceMesh();
for (int i = 0; i < vertices.length; i++) {
vertexBuffer.putFloat(vertices[i].x);
vertexBuffer.putFloat(vertices[i].y);
vertexBuffer.putFloat(vertices[i].z);
}
vertexBuffer.rewind();
indexBuffer.rewind();

TriangleIndexVertexArray vertexArray = new TriangleIndexVertexArray(numTriangles, indexBuffer, 3*4, obj.getMesh().getVertexCount(), vertexBuffer, 3*4);
return vertexArray;
}


Thanks.
#11
Support / Re: calcMinDistance returns 1.0E12
November 25, 2015, 05:39:10 AM
Thank you.  :)
#12
Support / Re: calcMinDistance returns 1.0E12
November 24, 2015, 03:34:00 PM
Thanks for the quick reply it works. Didn't know subtracting the two vectors gives the direction. Where can I learn such things? any recommendation?

Thanks.
#13
Support / calcMinDistance returns 1.0E12
November 24, 2015, 12:35:31 PM
Hello,

I am new to the forum and new to 3D programming as well. Trying to get good understanding of JPCT. What is wrong with the below code.

float distance = world.calcMinDistance(cam.getPosition(), obj.getTransformedCenter(), 10000 );

The obj is a cube and visible on screen.
Cam position = (0.0,0.0,-170.0)
ob center = (-3.973643E-8,0.0,0.0)

Thanks.