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


Java Vector3.decode方法代码示例

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


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

示例1: getSamples

import org.sunflow.math.Vector3; //导入方法依赖的package包/类
public void getSamples(ShadingState state) {
    if (storedPhotons == 0)
        return;
    NearestPhotons np = new NearestPhotons(state.getPoint(), gatherNum, gatherRadius * gatherRadius);
    locatePhotons(np);
    if (np.found < 8)
        return;
    Point3 ppos = new Point3();
    Vector3 pdir = new Vector3();
    Vector3 pvec = new Vector3();
    float invArea = 1.0f / ((float) Math.PI * np.dist2[0]);
    float maxNDist = np.dist2[0] * 0.05f;
    float f2r2 = 1.0f / (filterValue * filterValue * np.dist2[0]);
    float fInv = 1.0f / (1.0f - 2.0f / (3.0f * filterValue));
    for (int i = 1; i <= np.found; i++) {
        Photon phot = np.index[i];
        Vector3.decode(phot.dir, pdir);
        float cos = -Vector3.dot(pdir, state.getNormal());
        if (cos > 0.001) {
            ppos.set(phot.x, phot.y, phot.z);
            Point3.sub(ppos, state.getPoint(), pvec);
            float pcos = Vector3.dot(pvec, state.getNormal());
            if ((pcos < maxNDist) && (pcos > -maxNDist)) {
                LightSample sample = new LightSample();
                sample.setShadowRay(new Ray(state.getPoint(), pdir.negate()));
                sample.setRadiance(new Color().setRGBE(np.index[i].power).mul(invArea / cos), Color.BLACK);
                sample.getDiffuseRadiance().mul((1.0f - (float) Math.sqrt(np.dist2[i] * f2r2)) * fInv);
                state.addSample(sample);
            }
        }
    }
}
 
开发者ID:d2fn,项目名称:passage,代码行数:33,代码来源:CausticPhotonMap.java

示例2: precomputeRadiance

import org.sunflow.math.Vector3; //导入方法依赖的package包/类
public void precomputeRadiance() {
    if (storedPhotons == 0)
        return;
    // precompute the radiance for all photons that are neither
    // leaves nor parents of leaves in the tree.
    int quadStoredPhotons = halfStoredPhotons / 2;
    Point3 p = new Point3();
    Vector3 n = new Vector3();
    Point3 ppos = new Point3();
    Vector3 pdir = new Vector3();
    Vector3 pvec = new Vector3();
    Color irr = new Color();
    Color pow = new Color();
    float maxDist2 = gatherRadius * gatherRadius;
    NearestPhotons np = new NearestPhotons(p, numGather, maxDist2);
    Photon[] temp = new Photon[quadStoredPhotons + 1];
    UI.taskStart("Precomputing radiance", 1, quadStoredPhotons);
    for (int i = 1; i <= quadStoredPhotons; i++) {
        UI.taskUpdate(i);
        Photon curr = photons[i];
        p.set(curr.x, curr.y, curr.z);
        Vector3.decode(curr.normal, n);
        irr.set(Color.BLACK);
        np.reset(p, maxDist2);
        locatePhotons(np);
        if (np.found < 8) {
            curr.data = 0;
            temp[i] = curr;
            continue;
        }
        float invArea = 1.0f / ((float) Math.PI * np.dist2[0]);
        float maxNDist = np.dist2[0] * 0.05f;
        for (int j = 1; j <= np.found; j++) {
            Photon phot = np.index[j];
            Vector3.decode(phot.dir, pdir);
            float cos = -Vector3.dot(pdir, n);
            if (cos > 0.01f) {
                ppos.set(phot.x, phot.y, phot.z);
                Point3.sub(ppos, p, pvec);
                float pcos = Vector3.dot(pvec, n);
                if ((pcos < maxNDist) && (pcos > -maxNDist))
                    irr.add(pow.setRGBE(phot.power));
            }
        }
        irr.mul(invArea);
        // compute radiance
        irr.mul(new Color(curr.data)).mul(1.0f / (float) Math.PI);
        curr.data = irr.toRGBE();
        temp[i] = curr;
    }
    UI.taskStop();

    // resize photon map to only include irradiance photons
    numGather /= 4;
    maxRadius = 1.4f * (float) Math.sqrt(maxPower * numGather);
    if (gatherRadius > maxRadius)
        gatherRadius = maxRadius;
    storedPhotons = quadStoredPhotons;
    halfStoredPhotons = storedPhotons / 2;
    log2n = (int) Math.ceil(Math.log(storedPhotons) / Math.log(2.0));
    photons = temp;
    hasRadiance = true;
}
 
开发者ID:d2fn,项目名称:passage,代码行数:64,代码来源:GlobalPhotonMap.java


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