我正试图找出一种方法来查找Point3f是在Hexagons构成的网格内部还是在边缘上(每个都是一个特定的Shape3D对象)。
如果该点在边缘,那么想法就是改变Hexagon的颜色,使其成为Point3f或两个Heaxgons。
要使网格使用此逻辑http://playtechs.blogspot.com/2007/04/hex-grids.html 因此,了解海克斯康是如何彼此定位的应该相当容易。
我的问题与坐标有关,我在SceneGraph中使用了结构:
BranchGroup> TransformGroup> Hexagrid(TransformGroup)> HexaRow(TranformGroup)>六角形(Shape3D)
使用Transform3D(Vector3F)创建每个TransfromGroup以将其定位在3D空间
我想从BranchGroup恢复每个Hexagon的坐标,因为我的Point3f将在SceneGraph的根目录上生成。
我试图将顶点坐标放在HashMap中,其中Point是Hexagon网格中的坐标,Point3f []是Hexagon每个顶点的3d空间坐标。 我在行上添加六边形的时候做了这个,但由于是3个向量放置结构直到该步骤,每个都是一个局部坐标系我不能让它正常工作。
是否有更简单的方法来查找Shape3d对象的坐标而无需添加用于获取它的所有向量?
这是否是实现目标的正确方法? (从我的暗示碰撞检测仅适用于2个对象,我真的需要知道我的Point是否在边缘,制作3个对象)
感谢您的帮助!
答案 0 :(得分:0)
好吧,最后我找到了一个更好的方法,使用Transform3D mul方法
translateRootTG.addChild(hexaGrid);
Polygon myPolygon = hexaGrid.getPolygon(19,1);
// Get the First TransformGroup that containt the first Translation
TransformGroup firstTransform= (TransformGroup)myPolygon.getParent();
// the the Second TransfromGroup that containt the secondary Translation
TransformGroup secondTransform = (TransformGroup)myPolygon.getParent().getParent().getParent().getParent();
// Get the Transform3D from the first TransformGroup
Transform3D firstTranslation = new Transform3D();
firstTransform.getTransform(firstTranslation); // put the Transform in T3D var
// Get the Transform3D from the second TransformGroup
Transform3D secondTranslation = new Transform3D();
secondTransform.getTransform(secondTranslation); // put the Transform in T3D var
// Mul Transform3D to have complete translation
Transform3D t3DTotalPolygon = new Transform3D();
t3DTotalPolygon.mul(firstTranslation, secondTranslation);
TransformGroup tgTest = new TransformGroup(t3DTotalPolygon);
tgTest.addChild(new ColorCube(0.03f));
translateRootTG.addChild(tgTest);
答案 1 :(得分:0)
这可能会有所帮助:
javax.media.j3d.Node/Shape3D.getLocalToVworld(Transform3D t)