当前位置: 首页>>代码示例>>Java>>正文


Java Vec3D.x方法代码示例

本文整理汇总了Java中toxi.geom.Vec3D.x方法的典型用法代码示例。如果您正苦于以下问题:Java Vec3D.x方法的具体用法?Java Vec3D.x怎么用?Java Vec3D.x使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在toxi.geom.Vec3D的用法示例。


在下文中一共展示了Vec3D.x方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: projectPointer

import toxi.geom.Vec3D; //导入方法依赖的package包/类
@Override
    public PVector projectPointer(Screen screen, float px, float py) {

        ReadonlyVec3D inter = projectPointer3DVec3D(screen, px, py);
        // It may not intersect.
        if (inter == null) {
            return TouchInput.NO_INTERSECTION;
        }

        // Get the normalized coordinates in Paper coordinates
        Vec3D res = screen.getWorldToScreen().applyTo(inter);
//        PVector out = new PVector(res.x(), res.y(), res.z());
        PVector out = new PVector(res.x() / res.z(),
                res.y() / res.z(), 1);
        out.y = 1 - out.y;

        // Second possiblity... (WORKING)  Use directly the 3D location instead of the plane.
//     PVector interP = new PVector(inter.x(), inter.y(), inter.z());
//        PVector out3 = new PVector();
//        PMatrix3D posInv = screen.getPos().get();
//        posInv.invert();
//        posInv.mult(interP, out3);
//        out3.x /= screen.getSize().x;
//        out3.y /= screen.getSize().y;
//
//        PVector diff = PVector.sub(out, out3);
//        System.out.println("Diff " + diff);
//        out3.y = 1 - out3.y;
        return out;
    }
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:31,代码来源:ProjectorDisplay.java

示例2: projectPointer

import toxi.geom.Vec3D; //导入方法依赖的package包/类
@Override
    public PVector projectPointer(Screen screen, float px, float py) {
//        double[] undist = proj.undistort(px * getWidth(), py * getHeight());
//
//        // go from screen coordinates to normalized coordinates  (-1, 1) 
//        float x = (float) undist[0] / getWidth() * 2 - 1;
//        float y = (float) undist[1] / getHeight() * 2 - 1;

        PVector originP = new PVector(0, 0, 0);
        PVector viewedPtP = projectiveDeviceP.pixelToWorldNormP((int) (px * frameWidth), (int) (py * frameHeight));

        Ray3D ray
                = new Ray3D(new Vec3D(originP.x,
                        originP.y,
                        originP.z),
                        new Vec3D(viewedPtP.x,
                                viewedPtP.y,
                                viewedPtP.z));

        // 3D intersection with the screen plane. 
        ReadonlyVec3D inter = screen.getPlane().getIntersectionWithRay(ray);
//        dist = screen.plane.intersectRayDistance(ray);

        if (inter == null) {
            return TouchInput.NO_INTERSECTION;
        }

        // 3D -> 2D transformation
        Vec3D res = screen.getWorldToScreen().applyTo(inter);
        PVector out = new PVector(res.x() / res.z(),
                1f - (res.y() / res.z()), 1);
        return out;
    }
 
开发者ID:poqudrof,项目名称:PapARt,代码行数:34,代码来源:ARDisplay.java


注:本文中的toxi.geom.Vec3D.x方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。