Working with JME and a computational geometry library

Hi,



I need to do some computationnal geometry and I would like to know what is the best way to work with JME and another library.



I’m creating some procedural content and work with the jme.math Vector2f and vector3f. I need to implement some piece of code to manage things like monotone or delaunay triangulations, 2d polygon managment, oriented bounding bob… but these libraries work with their own vector class.



For exemple, Computational Geometry have a Point class, and JST have a Coordinate class, wich are very similar to Vector2f class, but uncastable.



What’s the best solution to make the bridge?



thanks in advance.



PS : If you know a good and open source geometry library, I take it.

Well, its also just vectors and Matrices most probably, so you only have to copy the xyz values…

Thanks fo you answer.



Of course I could copy the x,z values, but I would like to know a way to pass Vector2f and Vector3f directly to the library. I thought to create some MyPoint class extending cg.Point class with some MyPoint(Vector2f) constructor but i don’t know how to do that.



What must I do to make two classes with the same attributes (three floats) automaticaly castable, that is the question.

It doesn’t work. You’d need to implement an interface, which would basically be another (third) type that unifies both.

methusalah said:
What must I do to make two classes with the same attributes (three floats) automaticaly castable, that is the question.

You can't, objects must be of the same class for a successful cast (most of the time, but I won't go into details)

methusalah said:
Of course I could copy the x,z values

yes

methusalah said:
but I would like to know a way to pass Vector2f and Vector3f directly to the library.

You can't

methusalah said:
I thought to create some MyPoint class extending cg.Point class with some MyPoint(Vector2f) constructor but i don't know how to do that.

Why not that would be a way of doing it.

class MyPoint extends Point {

public MyPoint(Vector2f v){
this.x=v.x;
this.y=v.y
}
}

thanks for your answers.



I decided to do a very little and very adapted geometry api that makes the interface between the two APIs by using methods like Vector2f Point.toJME(); or Point(Vector2f); constructors.



Thanks again and see you