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


Java FastMath.DEG_TO_RAD屬性代碼示例

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


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

示例1: zoomCamera

protected void zoomCamera(float value){
    // derive fovY value
    float h = cam.getFrustumTop();
    float w = cam.getFrustumRight();
    float aspect = w / h;

    float near = cam.getFrustumNear();

    float fovY = FastMath.atan(h / near)
              / (FastMath.DEG_TO_RAD * .5f);
    fovY += value * 0.1f;

    h = FastMath.tan( fovY * FastMath.DEG_TO_RAD * .5f) * near;
    w = h * aspect;

    cam.setFrustumTop(h);
    cam.setFrustumBottom(-h);
    cam.setFrustumLeft(-w);
    cam.setFrustumRight(w);
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:20,代碼來源:FlyByCamera.java

示例2: controlUpdate

@Override
protected void controlUpdate(float f) {
    refreshLightDirection();
    if (!lightDir.equals(lastDir)) {
        lastDir.set(lightDir);

        Vector3f axis = Vector3f.UNIT_Y.cross(lastDir);
        float angle = Vector3f.UNIT_Y.angleBetween(lastDir);
        //Quaternion rotation = gizmo.getWorldRotation().inverse().mult(new Quaternion().fromAngleAxis(angle, axis));
        
        if (angle > 1f * FastMath.DEG_TO_RAD) { // Anti Flickering
            Quaternion rotation = new Quaternion().fromAngleAxis(angle, axis);
            gizmo.silentLocalRotation(rotation); /* silent, because otherwise
            the gizmo would call light.setDirection() and update the property */
        }
    }
}
 
開發者ID:jMonkeyEngine,項目名稱:sdk,代碼行數:17,代碼來源:LightDirectionUpdate.java

示例3: doToggleOrthoPerspMode

protected boolean doToggleOrthoPerspMode() {

        float aspect = (float) cam.getWidth() / cam.getHeight();
        if (!cam.isParallelProjection()) {
            cam.setParallelProjection(true);
            float h = cam.getFrustumTop();
            float w;
            float dist = cam.getLocation().distance(focus);
            float fovY = FastMath.atan(h) / (FastMath.DEG_TO_RAD * .5f);
            h = FastMath.tan(fovY * FastMath.DEG_TO_RAD * .5f) * dist;
            w = h * aspect;
            cam.setFrustum(-1000, 1000, -w, w, h, -h);
            return true;
        } else {
            cam.setParallelProjection(false);
            cam.setFrustumPerspective(45f, aspect, 1, 1000);
            return false;
        }
    }
 
開發者ID:jMonkeyEngine,項目名稱:sdk,代碼行數:19,代碼來源:AbstractCameraController.java

示例4: setData

@Override
public void setData(T data) {
    super.setData(data);
    
    String tempPlane = data.getAsString("plane");
    if (tempPlane != null) {
        plane = Plane.identify(tempPlane);
    }
    minRadius = data.getAsFloat("minRadius", minRadius);
    maxRadius = data.getAsFloat("maxRadius", maxRadius);
    minOffset = data.getAsVector3f("minOffset");
    maxOffset = data.getAsVector3f("maxOffset");
    order = data.getAsBoolean("order", order);
    orderSize = data.getAsInteger("orderSize", orderSize);
    orderInvert = data.getAsBoolean("orderInvert", orderInvert);
    Float orderStartDegree = data.getAsFloat("orderStartDegree"); // 注意是:degree角度,需要轉換為弧度
    if (orderStartDegree != null) {
        orderStartAngle = orderStartDegree * FastMath.DEG_TO_RAD;
    }
    
    // ---- inner
    avgAngle = FastMath.TWO_PI / orderSize;
    hasOffset = (minOffset != null || maxOffset != null);
    radius = MathUtils.getRandomFloat(minRadius, maxRadius);
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:25,代碼來源:RandomCirclePosition.java

示例5: tryDetour

@Override
protected void tryDetour(int count) {
    if (count == 0) {
        direction = MathUtils.randomPON();
    }
    
    TempVars tv = TempVars.get();
    float angle = 30 * (count + 1) * FastMath.DEG_TO_RAD * direction;
    tv.vect1.set(actorService.getWalkDirection(actor));
    MathUtils.rotate(tv.vect1.normalizeLocal(), angle, Vector3f.UNIT_Y, tv.vect2);
    
    detour(tv.vect2);
    
    tv.release();
    
    float lockTime = count * 0.25f + 0.25f;
    action.lock(lockTime);
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:18,代碼來源:TimeDetour.java

示例6: doToggleOrthoPerspMode

public boolean doToggleOrthoPerspMode() {
    float aspect = (float) cam.getWidth() / cam.getHeight();
    if (!cam.isParallelProjection()) {
        cam.setParallelProjection(true);
        float h = cam.getFrustumTop();
        float w;
        float dist = cam.getLocation().distance(focus);
        float fovY = FastMath.atan(h) / (FastMath.DEG_TO_RAD * .5f);
        h = FastMath.tan(fovY * FastMath.DEG_TO_RAD * .5f) * dist;
        w = h * aspect;
        cam.setFrustum(orthoNear, orthoFar, -w, w, h, -h);
        return true;
    } else {
        cam.setParallelProjection(false);
        cam.setFrustumPerspective(45f, aspect, perspNear, perspFar);
        return false;
    }
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:18,代碼來源:BestEditCamera.java

示例7: rotate

public BufferedImage rotate(BufferedImage image, float deg, int w, int h) {
    AffineTransform xform = new AffineTransform();
    float rad = FastMath.DEG_TO_RAD * deg;
    xform.rotate(rad, w / 2, h / 2);
    AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BILINEAR);
    return op.filter(image, null);
}
 
開發者ID:rockfireredmoon,項目名稱:iceclient,代碼行數:7,代碼來源:MiniMap.java

示例8: RadialLayoutInfo

public RadialLayoutInfo(String constraints) {
	for (String attr : constraints.split(",")) {
		if (attr.endsWith("rad")) {
			angle = Float.parseFloat(attr.substring(0, attr.length() - 3));
		} else if (attr.endsWith("deg")) {
			angle = Float.parseFloat(attr.substring(0, attr.length() - 3)) * FastMath.DEG_TO_RAD;
		} else if (attr.endsWith("px")) {
			inset = Float.parseFloat(attr.substring(0, attr.length() - 2));
		} else
			angle = Float.parseFloat(attr);
	}
}
 
開發者ID:rockfireredmoon,項目名稱:icetone,代碼行數:12,代碼來源:RadialLayoutInfo.java

示例9: tryDetour

@Override
protected void tryDetour(int count) {
    if (count == 0) {
        direction = MathUtils.randomPON();
    }
    
    float angle = 30 * (count + 1) * FastMath.DEG_TO_RAD * direction;
    tempDir.set(actorService.getWalkDirection(actor)).normalizeLocal();
    MathUtils.rotate(tempDir, angle, Vector3f.UNIT_Y, tempDir);
    detour(tempDir);
    
    float lockTime = count * 0.25f + 0.25f;
    action.lock(lockTime); 
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:14,代碼來源:RayDetour.java

示例10: setData

@Override
public void setData(AnimData data) {
    super.setData(data);
    
    // 在xml的配置上是角度,需要轉為弧度
    minAngle = data.getAsFloat("minDegree", 0) * FastMath.DEG_TO_RAD;
    maxAngle = data.getAsFloat("maxDegree", 0) * FastMath.DEG_TO_RAD;
    // 旋轉軸
    axis = data.getAsVector3f("axis");
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:10,代碼來源:RandomRotationAnim.java

示例11: setData

@Override
public void setData(AnimData data) {
    super.setData(data);
    this.axis = data.getAsVector3f("axis", axis);
    Float degree = data.getAsFloat("degree");
    if (degree != null) {
        angle = degree * FastMath.DEG_TO_RAD;
    }
    this.invert = data.getAsBoolean("invert", invert);
    this.restore = data.getAsBoolean("restore", restore);
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:11,代碼來源:RotationAnim.java

示例12: doOrthoMode

public void doOrthoMode() {
    if (!cam.isParallelProjection()) {
        float aspect = (float) cam.getWidth() / cam.getHeight();
        cam.setParallelProjection(true);
        float h = cam.getFrustumTop();
        float w;
        float dist = cam.getLocation().distance(focus);
        float fovY = FastMath.atan(h) / (FastMath.DEG_TO_RAD * .5f);
        h = FastMath.tan(fovY * FastMath.DEG_TO_RAD * .5f) * dist;
        w = h * aspect;
        cam.setFrustum(orthoNear, orthoFar, -w, w, h, -h);
    }
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:13,代碼來源:BestEditCamera.java

示例13: CopyOfPlayerAnimControl

public CopyOfPlayerAnimControl(IcesceneApp app, AbstractSpawnEntity entity) {
	super(entity, app.getStateManager());
	this.app = app;
	tiltForward = new Quaternion(new float[] { FastMath.DEG_TO_RAD * 35f, 0f, 0f });
	tiltBackward = new Quaternion(new float[] { -FastMath.QUARTER_PI, 0f, 0f });
}
 
開發者ID:rockfireredmoon,項目名稱:iceclient,代碼行數:6,代碼來源:CopyOfPlayerAnimControl.java

示例14: PlayerAnimControl

public PlayerAnimControl(EntityContext app, Biped entity) {
	this.context = app;
	this.entity = entity;
	tiltForward = new Quaternion(new float[] { FastMath.DEG_TO_RAD * 35f, 0f, 0f });
	tiltBackward = new Quaternion(new float[] { -FastMath.QUARTER_PI, 0f, 0f });
}
 
開發者ID:rockfireredmoon,項目名稱:iceclient,代碼行數:6,代碼來源:PlayerAnimControl.java

示例15: processToggleSwitchElement

private Spatial processToggleSwitchElement(Element elm, boolean isWhole) {
	String id = getUniqueId(elm.getAttribute("id"));
       boolean pointable = Boolean.parseBoolean(elm.getAttribute("pointable"));
	Vector3f location = parseVector3(elm.getAttribute("location"));
	Vector3f rotation = parseVector3(elm.getAttribute("rotation"));
	float xspan = Float.parseFloat(elm.getAttribute("xspan"));
	float zspan = Float.parseFloat(elm.getAttribute("yspan"));
	float yspan = Float.parseFloat(elm.getAttribute("zspan"));
	float angle = Float.parseFloat(elm.getAttribute("angle")) * FastMath.DEG_TO_RAD;
	ColorRGBA color = parseColor(elm.getAttribute("color"));
	boolean leftPressed = Boolean.parseBoolean(elm.getAttribute("leftPressed"));
	int numStates = Integer.parseInt(elm.getAttribute("numStates"));
	int initState = Integer.parseInt(elm.getAttribute("initState"));
	if (initState < 0) {
	    initState = 0;
	} else if (initState >= numStates) {
	    initState = numStates - 1;
	}

	float btxspan = xspan / (1.0f + FastMath.cos(angle));

	Node s = new Node(id);
	s.setLocalTranslation(location);
	s.setLocalRotation(new Quaternion().fromAngles(
			rotation.x * FastMath.DEG_TO_RAD,
			rotation.y * FastMath.DEG_TO_RAD,
			rotation.z * FastMath.DEG_TO_RAD));
	// button 1
	Spatial b1 = factory.makeBlock(id + "-b1", btxspan, yspan, zspan, color);
	b1.setLocalTranslation(-btxspan / 2, yspan / 2, 0);
	s.attachChild(b1);
	// button 2
	Spatial b2 = factory.makeBlock(id + "-b2", btxspan, yspan, zspan, color);
	b2.setLocalRotation(new Quaternion().fromAngles(0, 0, angle));
	float hypoLen = FastMath.sqr(btxspan * btxspan + yspan * yspan); // hypotenues
	float cosine = (btxspan / hypoLen) * FastMath.cos(angle) - (yspan / hypoLen) * FastMath.sin(angle);
	float sine = (yspan / hypoLen) * FastMath.cos(angle) + (btxspan / hypoLen) * FastMath.sin(angle);
	b2.setLocalTranslation(hypoLen / 2f * cosine, hypoLen / 2f * sine, 0);
	s.attachChild(b2);

	// get <downstream> and <state> elements
	LinkedList<String> dsIds = new LinkedList<>();
	for (org.w3c.dom.Node child = elm.getFirstChild(); child != null; child = child.getNextSibling()) {
		if (child.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE
		        && child.getNodeName().equals("downstream")) {
			dsIds.add(((Element) child).getAttribute("id"));
		}
	}

	ToggleSwitchControl c = new ToggleSwitchControl(inventory, s, angle, leftPressed, numStates, initState);

	for (String dsId : dsIds) {
		c.addDownstreamId(dsId);
	}
	inventory.registerControl(s, c);
	
	if (isWhole) {
	    float mass = Float.parseFloat(elm.getAttribute("mass"));
	    inventory.addItem(s, mass);
        processDescriptionElements(elm, s, "toggleSwitch");
	}
       if (pointable) {
           s.setUserData("pointable", "" + pointable);
       }

	return s;
}
 
開發者ID:dwhuang,項目名稱:SMILE,代碼行數:67,代碼來源:Table.java


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