當前位置: 首頁>>代碼示例>>Java>>正文


Java FastMath.ceil方法代碼示例

本文整理匯總了Java中com.jme3.math.FastMath.ceil方法的典型用法代碼示例。如果您正苦於以下問題:Java FastMath.ceil方法的具體用法?Java FastMath.ceil怎麽用?Java FastMath.ceil使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.jme3.math.FastMath的用法示例。


在下文中一共展示了FastMath.ceil方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: makeBigBlock

import com.jme3.math.FastMath; //導入方法依賴的package包/類
public Node makeBigBlock(String name, float w, float h, float d,
            ColorRGBA color, float unitBlockSize) {
        int wCount = (int) FastMath.ceil(w / unitBlockSize);
        int hCount = (int) FastMath.ceil(h / unitBlockSize);
        int dCount = (int) FastMath.ceil(d / unitBlockSize);
//        System.err.println(wCount + " " + dCount);
        Node bigBlock = new Node(name);
        
        float xMin = -(wCount / 2) * unitBlockSize;
        if (wCount % 2 == 0) {
            xMin += unitBlockSize / 2;
        }
        float yMin = -(hCount / 2) * unitBlockSize;
        if (hCount % 2 == 0) {
            yMin += unitBlockSize / 2;
        }
        float zMin = -(dCount / 2) * unitBlockSize;
        if (dCount % 2 == 0) {
            zMin += unitBlockSize / 2;
        }

        Vector3f c = new Vector3f(xMin, 0f, 0f);
        for (int i = 0; i < wCount; ++i) {
            c.y = yMin;
            for (int j = 0; j < hCount; ++j) {
                c.z = zMin;
                for (int k = 0; k < dCount; ++k) {
                    Spatial unitBlock = makeBlock(
                            name + "(" + i + ", " + j + ")",
                            unitBlockSize, unitBlockSize, unitBlockSize, color);
                    unitBlock.setLocalTranslation(c);
                    bigBlock.attachChild(unitBlock);
                    c.z += unitBlockSize;
                }
                c.y += unitBlockSize;
            }
            c.x += unitBlockSize;
        }
        
        bigBlock.setUserData("obj_shape", "bigblock");
        bigBlock.setUserData("obj_width", w);
        bigBlock.setUserData("obj_height", h);
        bigBlock.setUserData("obj_depth", d);
        bigBlock.setUserData("obj_color", color);
        bigBlock.setUserData("obj_unitBlockSize", unitBlockSize);
        
//        return GeometryBatchFactory.optimize(bigBlock);
        return bigBlock;
    }
 
開發者ID:dwhuang,項目名稱:SMILE,代碼行數:50,代碼來源:Factory.java


注:本文中的com.jme3.math.FastMath.ceil方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。