當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。