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


Java Quaternion.mult方法代碼示例

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


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

示例1: rotateUpTo

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
/**
 * <code>rotateUpTo</code> is a utility function that alters the
 * local rotation to point the Y axis in the direction given by newUp.
 *
 * @param newUp
 *            the up vector to use - assumed to be a unit vector.
 */
public void rotateUpTo(Vector3f newUp) {
    TempVars vars = TempVars.get();

    Vector3f compVecA = vars.vect1;
    Quaternion q = vars.quat1;

    // First figure out the current up vector.
    Vector3f upY = compVecA.set(Vector3f.UNIT_Y);
    Quaternion rot = localTransform.getRotation();
    rot.multLocal(upY);

    // get angle between vectors
    float angle = upY.angleBetween(newUp);

    // figure out rotation axis by taking cross product
    Vector3f rotAxis = upY.crossLocal(newUp).normalizeLocal();

    // Build a rotation quat and apply current local rotation.
    q.fromAngleNormalAxis(angle, rotAxis);
    q.mult(rot, rot);

    vars.release();

    setTransformRefresh();
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:33,代碼來源:Spatial.java

示例2: getRotation

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
/**
 * Get the Rotation into a specific custom space.
 *
 * @param transform the rotation to the custom space (World to Custom
 * space)
 * @return the Rotation in the custom space
 */
public Quaternion getRotation(Quaternion transform) {
    if (startPickLoc == null) {
        Logger.getLogger(this.getClass().getSimpleName()).warning("startPickLoc null in PickManager#getRotation()");
        return transform;
    } else if (finalPickLoc == null) {
        Logger.getLogger(this.getClass().getSimpleName()).warning("finalPickLoc null in PickManager#getRotation()");
        return transform;
    }
    
    Vector3f v1, v2;
    v1 = transform.mult(startPickLoc.subtract(startSpatialLocation).normalize());
    v2 = transform.mult(finalPickLoc.subtract(startSpatialLocation).normalize());
    Vector3f axis = v1.cross(v2);
    float angle = v1.angleBetween(v2);
    return new Quaternion().fromAngleAxis(angle, axis);
}
 
開發者ID:jMonkeyEngine,項目名稱:sdk,代碼行數:24,代碼來源:PickManager.java

示例3: create

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
private void create() {
    if (haloRoot != null) {
        haloRoot.removeFromParent();
    }
    
    // -- 初始化創建所有光暈
    haloRoot = new Node("CircleHalo_root");
    float angle = FastMath.TWO_PI / haloTotal;
    TempVars tv = TempVars.get();
    Vector3f lookAt = tv.vect1.set(0, incline, 0);
    Vector3f pos = tv.vect2;
    Vector3f size = tv.vect3.set(1,1,1).multLocal(haloSize);
    Quaternion rot = tv.quat1;
    for (int i = 0; i < haloTotal; i++) {
        pos.zero().setX(radius);
        if (i == 0) {
            haloRoot.attachChild(createHaloOne(texture, pos, size, lookAt));
        } else {
            MathUtils.createRotation(angle * i, Vector3f.UNIT_Y, rot);
            rot.mult(pos, pos);
            haloRoot.attachChild(createHaloOne(texture, pos, size, lookAt));
        }
    }
    tv.release();
    this.animNode.attachChild(haloRoot);
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:27,代碼來源:HaloEffect.java

示例4: onRotationUpdated

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
protected void onRotationUpdated(Quaternion rotation) {
    rotation.toAngles(tempAngles);
    // 去掉x和z軸的旋轉
    tempAngles[0] = 0;
    tempAngles[2] = 0;
    TempVars tv = TempVars.get();
    Quaternion qua = tv.quat1;
    qua.fromAngles(tempAngles);
    target.getSpatial().setLocalRotation(qua);
    
    Vector3f windDir = tv.vect1.set(0,0,1);
    qua.mult(windDir, windDir);
    target.setWindDirection(new Vector2f(windDir.x, windDir.z).normalizeLocal());
    tv.release();
    
    target.updateDatas();
    notifyPropertyChanged("rotation", qua);
    notifyPropertyChanged("windDirection", target.getWindDirection());
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:21,代碼來源:AdvanceWaterEntityControlTile.java

示例5: onEntityEachTick

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
protected void onEntityEachTick(Entity e) {
	Spatial s = SpatialPool.models.get(e.getId());
	if(s == null) {
		return;
	}

	PlanarStance stance = e.get(PlanarStance.class);

	// translation
	s.setLocalTranslation(TranslateUtil.toVector3f(stance.getCoord().get3D(stance.getElevation())));
	// rotation
	Quaternion r = new Quaternion();
	Point3D pu = stance.getUpVector();
	Point3D pv = Point3D.UNIT_X.getRotationAroundZ(stance.getOrientation().getValue());
	Vector3f u = TranslateUtil.toVector3f(pu).normalize();
	Vector3f v = TranslateUtil.toVector3f(pv).normalize();
	r.lookAt(v, u);
	double angle = Math.acos(pu.getDotProduct(pv) / (pu.getNorm() * pv.getNorm()));
	r = r.mult(new Quaternion().fromAngles((float) (-angle), 0, 0));

	s.setLocalRotation(r);
}
 
開發者ID:meltzow,項目名稱:supernovae,代碼行數:24,代碼來源:SpritePlacingProc.java

示例6: tick

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
public AirfoilResponse tick(float airDensity, Vector3f flow, Vector3f angV) {
    Quaternion damp = damp(angV);
    flow = damp.mult(flow);
    float aoa = calcAoa(flow);
    Vector3f lift = lift(airDensity, flow,aoa);
    Vector3f inducedDrag = inducedDrag(airDensity, flow,lift);
    Vector3f linear =  lift.add(inducedDrag);
    Vector3f torque = cog.cross(linear);      
    return new AirfoilResponse(damp, aoa, lift, inducedDrag, linear, torque);
}
 
開發者ID:ZoltanTheHun,項目名稱:SkyHussars,代碼行數:12,代碼來源:SymmetricAirfoil.java

示例7: setPhysicsRotation

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
public void setPhysicsRotation(Quaternion rotation) {
    super.setPhysicsRotation(rotation);
    
    TempVars tv = TempVars.get();
    rotation.mult(localForward, tv.vect1);
    setViewDirection(tv.vect1);
    
    tv.release();
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:11,代碼來源:ActorModule.java

示例8: convertWaypointToWorld

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
/**
 * 將本地中間路徑點轉化為Bullet坐標係下的世界坐標點.
 * @param startPos
 * @param endPos
 * @param localWaypoint
 * @return 
 */
private void convertWaypointToWorld(Vector3f startPos, Vector3f endPos, Vector3f localWaypoint) {
    TempVars tv = TempVars.get();
    Vector3f dir = tv.vect1;
    Quaternion rot = tv.quat1;
    endPos.subtract(startPos, dir).normalizeLocal();
    rot.lookAt(dir, up);
    rot.mult(localWaypoint, localWaypoint);
    localWaypoint.addLocal(startPos);
    tv.release();
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:18,代碼來源:CurveBullet.java

示例9: loadAnimModel

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
private Spatial loadAnimModel() {
    // 生成路徑點
    if (fixedPoints == null) {
        fixedPoints = new Vector3f[randomPoints.length];
        for (int i = 0; i < randomPoints.length; i++) {
            Vector3f point = new Vector3f();
            ((Position)Loader.load(randomPoints[i])).getPoint(point);
            fixedPoints[i] = point;
        }
    }
    MySpline spline = createSpline(fixedPoints, tension, cycle);
    if(dimension > 1) {
        // 計算出實際的維度旋轉軸
        TempVars tv = TempVars.get();
        Vector3f nextPoint = tv.vect1;
        Vector3f forward = tv.vect2;
        Vector3f left = tv.vect3;
        Vector3f rotAxis = tv.vect4;
        spline.getSplinePoint(spline.getTotalLength() / segments, nextPoint);
        nextPoint.subtract(spline.getControlPoints().get(0), forward).normalizeLocal();
        up.cross(forward, left).normalizeLocal();
        left.cross(up, rotAxis).normalizeLocal();
        
        Quaternion qua = new Quaternion();
        Vector3f tempUp = tv.vect5;
        float angle = FastMath.PI / dimension;
        Node animNode = new Node();
        for (int i = 0; i < dimension; i++) {
            qua.fromAngleAxis(angle * i, rotAxis);
            qua.mult(up, tempUp);
            animNode.attachChild(createSurface(spline, tempUp));
        }
        tv.release();
        return animNode;
    } else {
        return createSurface(spline, up);
    }
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:39,代碼來源:SlideColorIOSplineEffect.java

示例10: onRotationUpdated

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
protected void onRotationUpdated(Quaternion rotation) {
    Vector3f dir = target.getLight().getDirection().set(Vector3f.UNIT_Z);
    rotation.mult(dir, dir);
    target.getLight().setDirection(dir);
    target.updateDatas();
    notifyPropertyChanged("direction", dir);
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:9,代碼來源:SpotLightEntityControlTile.java

示例11: onRotationUpdated

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
protected void onRotationUpdated(Quaternion rotation) {
    Vector3f dir = target.getDirection().set(Vector3f.UNIT_Z);
    rotation.mult(dir, dir);
    target.setDirection(dir);
    target.updateDatas();
    notifyPropertyChanged("direction", dir);
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:9,代碼來源:DirectionalLightEntityControlTile.java

示例12: getRotation

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
/**
 * Get the Rotation into a specific custom space.
 * @param transforme the rotation to the custom space (World to Custom space)
 * @return the Rotation in the custom space
 */
public Quaternion getRotation(Quaternion transforme) {
    Vector3f v1, v2;
    v1 = transforme.mult(startPickLoc.subtract(startSpatialLocation).normalize());
    v2 = transforme.mult(endPickLoc.subtract(startSpatialLocation).normalize());
    Vector3f axis = v1.cross(v2);
    float angle = v1.angleBetween(v2);
    return new Quaternion().fromAngleAxis(angle, axis);
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:14,代碼來源:Picker.java

示例13: getRotation

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
/**
 * Get the Rotation into a specific custom space.
 *
 * @param transforme the rotation to the custom space (World to Custom
 * space)
 * @return the Rotation in the custom space
 */
public Quaternion getRotation(Quaternion transforme) {
    Vector3f v1, v2;
    v1 = transforme.mult(startPickLoc.subtract(startSpatialLocation).normalize());
    v2 = transforme.mult(finalPickLoc.subtract(startSpatialLocation).normalize());
    Vector3f axis = v1.cross(v2);
    float angle = v1.angleBetween(v2);
    return new Quaternion().fromAngleAxis(angle, axis);
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:16,代碼來源:PickManager.java

示例14: onEntityUpdated

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
protected void onEntityUpdated(Entity e) {
	Model model = e.get(Model.class);
	Spatial s = SpatialPool.models.get(e.getId());

	if(s == null) {
		return;
	}

	PlanarStance stance = e.get(PlanarStance.class);

	// translation
	s.setLocalTranslation(TranslateUtil.toVector3f(stance.getCoord().get3D(stance.getElevation())));

	// rotation
	Quaternion r = new Quaternion();
	Point3D pu = stance.getUpVector();
	Point3D pv = Point3D.UNIT_X.getRotationAroundZ(stance.getOrientation().getValue());
	Vector3f u = TranslateUtil.toVector3f(pu).normalize();
	Vector3f v = TranslateUtil.toVector3f(pv).normalize();
	r.lookAt(v, u);

	// we correct the pitch of the unit because the direction is always flatten
	// this is only to follow the terrain relief
	double angle = Math.acos(pu.getDotProduct(pv) / (pu.getNorm() * pv.getNorm()));
	r = r.mult(new Quaternion().fromAngles((float) (-angle+AngleUtil.RIGHT+model.pitchFix.getValue()), (float) (model.rollFix.getValue()), (float) (model.yawFix.getValue())));

	s.setLocalRotation(r);
}
 
開發者ID:meltzow,項目名稱:supernovae,代碼行數:30,代碼來源:ModelPlacingProc.java

示例15: loadAnimModel

import com.jme3.math.Quaternion; //導入方法依賴的package包/類
@Override
protected final Spatial loadAnimModel() {
    fixedPoints = data.getAsVector3fArray("fixedPoints");
    randomPoints = data.getAsArray("randomPoints");
    width = data.getAsFloat("width", width);
    segments = data.getAsInteger("segments", segments);
    tension = data.getAsFloat("tension", tension);
    cycle = data.getAsBoolean("cycle", cycle);
    up = data.getAsVector3f("up", up).normalizeLocal();
    dimension = data.getAsInteger("dimension", dimension);
    
    if (fixedPoints == null && randomPoints == null)
        throw new NullPointerException("need fixedPoints or randomPoints");
    
    // 生成路徑點
    if (fixedPoints == null) {
        fixedPoints = new Vector3f[randomPoints.length];
        for (int i = 0; i < randomPoints.length; i++) {
            Vector3f point = new Vector3f();
            ((Position)Loader.load(randomPoints[i])).getPoint(point);
            fixedPoints[i] = point;
        }
    }
    MySpline spline = createSpline(fixedPoints, tension, cycle);
    if(dimension > 1) {
        // 計算出實際的維度旋轉軸
        TempVars tv = TempVars.get();
        Vector3f nextPoint = tv.vect1;
        Vector3f forward = tv.vect2;
        Vector3f left = tv.vect3;
        Vector3f rotAxis = tv.vect4;
        spline.getSplinePoint(spline.getTotalLength() / segments, nextPoint);
        nextPoint.subtract(spline.getControlPoints().get(0), forward).normalizeLocal();
        up.cross(forward, left).normalizeLocal();
        left.cross(up, rotAxis).normalizeLocal();
        
        Quaternion qua = new Quaternion();
        Vector3f tempUp = tv.vect5;
        float angle = FastMath.PI / dimension;
        Node animObject = new Node();
        for (int i = 0; i < dimension; i++) {
            qua.fromAngleAxis(angle * i, rotAxis);
            qua.mult(up, tempUp);
            animObject.attachChild(createSurface(spline, tempUp));
        }
        tv.release();
        return animObject;
    } else {
        return createSurface(spline, up);
    }
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:52,代碼來源:SlideColorSplineEffect.java


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