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


Java Vector3.negate方法代码示例

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


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

示例1: drawLiquidSpiral

import codechicken.lib.vec.Vector3; //导入方法依赖的package包/类
private void drawLiquidSpiral(CCRenderState ccrs, int src, int dst, FluidStack stack, double start, double end, double time, double theta0, double x, double y, double z) {

        RenderUtils.preFluidRender();
        TextureAtlasSprite tex = RenderUtils.prepareFluidRender(stack, 255);

        VertexBuffer vertexBuffer = ccrs.startDrawing(7, DefaultVertexFormats.POSITION_TEX);
        vertexBuffer.setTranslation(x, y, z);

        Vector3[] last = new Vector3[] { new Vector3(), new Vector3(), new Vector3(), new Vector3() };
        Vector3[] next = new Vector3[] { new Vector3(), new Vector3(), new Vector3(), new Vector3() };
        double tess = 0.05;

        Vector3 a = getPerp(src, dst);
        boolean rev = sum(a.copy().crossProduct(getPathNormal(src, dst, 0))) != sum(sideVec[src]);

        for (double di = end; di <= start; di += tess) {
            Vector3 b = getPathNormal(src, dst, di);
            Vector3 c = getPath(src, dst, di);

            if (rev) {
                b.negate();
            }

            double r = (2 * di - time / 10 + theta0 + dst / 6) * 2 * Math.PI;
            double sz = 0.1;
            Vector3 p = c.add(a.copy().multiply(MathHelper.sin(r) * sz)).add(b.copy().multiply(MathHelper.cos(r) * sz));

            double s1 = 0.02;
            double s2 = -0.02;
            next[0].set(p).add(a.x * s1 + b.x * s1, a.y * s1 + b.y * s1, a.z * s1 + b.z * s1);
            next[1].set(p).add(a.x * s2 + b.x * s1, a.y * s2 + b.y * s1, a.z * s2 + b.z * s1);
            next[2].set(p).add(a.x * s2 + b.x * s2, a.y * s2 + b.y * s2, a.z * s2 + b.z * s2);
            next[3].set(p).add(a.x * s1 + b.x * s2, a.y * s1 + b.y * s2, a.z * s1 + b.z * s2);

            if (di > end) {
                double u1 = tex.getInterpolatedU(Math.abs(di) * 16);
                double u2 = tex.getInterpolatedU(Math.abs(di - tess) * 16);
                for (int i = 0; i < 4; i++) {
                    int j = (i + 1) % 4;
                    Vector3 axis = next[j].copy().subtract(next[i]);
                    double v1 = tex.getInterpolatedV(Math.abs(next[i].scalarProject(axis)) * 16);
                    double v2 = tex.getInterpolatedV(Math.abs(next[j].scalarProject(axis)) * 16);

                    vertexBuffer.pos(next[i].x, next[i].y, next[i].z).tex(u1, v1).endVertex();
                    vertexBuffer.pos(next[j].x, next[j].y, next[j].z).tex(u1, v2).endVertex();
                    vertexBuffer.pos(last[j].x, last[j].y, last[j].z).tex(u2, v2).endVertex();
                    vertexBuffer.pos(last[i].x, last[i].y, last[i].z).tex(u2, v1).endVertex();
                }
            }

            Vector3[] tmp = last;
            last = next;
            next = tmp;
        }

        ccrs.draw();
        vertexBuffer.setTranslation(0, 0, 0);

        RenderUtils.postFluidRender();
    }
 
开发者ID:TheCBProject,项目名称:Translocators,代码行数:61,代码来源:TileTranslocatorRenderer.java


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