【发布时间】:2018-11-28 18:09:18
【问题描述】:
我正在使用 ARCore 和 Sceneform 构建棋盘游戏应用。我的 3D 模型需要捕捉到网格而不是放置在任何地方。想象一个棋盘。
我该怎么做?
我复制了 TransformableNode 和 TranslationController 类来修改它们。在TranslationController 中,使用Vector3 在变量desiredLocalPosition 中设置坐标。
据我了解,我应该能够对坐标进行整数除法,以便我的对象只能跳跃特定距离。
this.desiredLocalPosition = new Vector3(pose.tx(), pose.ty(), pose.tz());
float X = (int) (pose.tx()/0.05f) * 0.05f;
float Y = pose.ty(); //i don't care about vertical
float Z = (int) (pose.tz()/0.05f) * 0.05f;
this.desiredLocalPosition.set(X,Y,Z);
遗憾的是,这仅在我拖动对象时起作用,而当它们实际放置时会忽略它。
虽然我是一名学生,但我几乎是一个菜鸟程序员。有人有想法吗?
【问题讨论】:
-
嘿,欢迎来到 StackOverflow!您能否添加您所看到行为的简短视频/ gif?看看你是如何修改
TranslationController类的也很有帮助;您是否更改了onContinueTransformation()或updatePosition()方法? -
感谢您的回复!我用我的问题中的代码更新了
onContinueTransformation()。我也尝试制作视频,对于糟糕的质量感到抱歉。 youtube.com/watch?v=EAAkYcDBlnw&list=WL 所以代码似乎在我实际拖动模型时有效,但是当我放开它们时,它们仍然会跳到最后一个手指接触位置,如果你明白我的意思的话。 -
不错的一个!我想我明白发生了什么。
标签: java android arcore sceneform