本文整理了Java中com.jme3.scene.Spatial.getWorldRotation()
方法的一些代码示例,展示了Spatial.getWorldRotation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Spatial.getWorldRotation()
方法的具体详情如下:
包路径:com.jme3.scene.Spatial
类名称:Spatial
方法名:getWorldRotation
[英]getWorldRotation
retrieves the absolute rotation of the Spatial.
[中]getWorldRotation
检索空间对象的绝对旋转。
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Access whichever spatial rotation corresponds to the physics rotation.
*
* @return the pre-existing quaternion (in physics-space coordinates, not
* null)
*/
protected Quaternion getSpatialRotation() {
if (applyLocal) {
return spatial.getLocalRotation();
}
return spatial.getWorldRotation();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Access whichever spatial rotation corresponds to the physics rotation.
*
* @return the pre-existing quaternion (not null)
*/
private Quaternion getSpatialRotation() {
if (applyLocal) {
return spatial.getLocalRotation();
}
return spatial.getWorldRotation();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Access whichever spatial rotation corresponds to the physics rotation.
*
* @return the pre-existing quaternion (in physics-space coordinates, not
* null)
*/
protected Quaternion getSpatialRotation() {
if (applyLocal) {
return spatial.getLocalRotation();
}
return spatial.getWorldRotation();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Access whichever spatial rotation corresponds to the physics rotation.
*
* @return the pre-existing quaternion (not null)
*/
private Quaternion getSpatialRotation() {
if (applyLocal) {
return spatial.getLocalRotation();
}
return spatial.getWorldRotation();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Access whichever spatial rotation corresponds to the physics rotation.
*
* @return the pre-existing quaternion (not null)
*/
private Quaternion getSpatialRotation(){
if(motionState.isApplyPhysicsLocal()){
return spatial.getLocalRotation();
}
return spatial.getWorldRotation();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
private Quaternion getSpatialRotation(){
if(motionState.isApplyPhysicsLocal()){
return spatial.getLocalRotation();
}
return spatial.getWorldRotation();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Access whichever spatial rotation corresponds to the physics rotation.
*
* @return the pre-existing quaternion (not null)
*/
private Quaternion getSpatialRotation(){
if(motionState.isApplyPhysicsLocal()){
return spatial.getLocalRotation();
}
return spatial.getWorldRotation();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
private Quaternion getSpatialRotation(){
if(motionState.isApplyPhysicsLocal()){
return spatial.getLocalRotation();
}
return spatial.getWorldRotation();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Get the observer final rotation within the scene.
* @return the observer final rotation within the scene.
* @see #getFinalObserverPosition()
*/
public Quaternion getFinalObserverRotation() {
if( viewmanager == null ) {
if( observer == null ) {
return getCamera().getRotation();
} else return observer.getWorldRotation();
}
if( observer == null ) {
tempq.set(dummyCam.getRotation());
} else {
tempq.set(observer.getWorldRotation());
}
return tempq.multLocal(VRhardware.getOrientation());
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void setSpatial(Spatial spatial) {
this.spatial = spatial;
setUserObject(spatial);
if (spatial == null) {
return;
}
setPhysicsLocation(spatial.getWorldTranslation());
setPhysicsRotation(spatial.getWorldRotation().toRotationMatrix());
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public Quaternion getFinalObserverRotation(int index) {
OSVRViewManager vrvm = (OSVRViewManager)environment.getVRViewManager();
if( vrvm == null || isInputDeviceTracking(index) == false ) return null;
Object obs = environment.getObserver();
if( obs instanceof Camera ) {
tempq.set(((Camera)obs).getRotation());
} else {
tempq.set(((Spatial)obs).getWorldRotation());
}
return tempq.multLocal(getOrientation(index));
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Get the observer final rotation within the scene.
* @return the observer final rotation within the scene.
* @see #getFinalObserverPosition()
*/
public Quaternion getFinalObserverRotation() {
if( environment.getVRViewManager() == null ) {
if( environment.getObserver() == null ) {
return environment.getCamera().getRotation();
} else {
return ((Spatial)environment.getObserver()).getWorldRotation();
}
}
if( environment.getObserver() == null ) {
tempq.set(environment.getDummyCamera().getRotation());
} else {
tempq.set(((Spatial)environment.getObserver()).getWorldRotation());
}
return tempq.multLocal(environment.getVRHardware().getOrientation());
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public Quaternion getFinalObserverRotation(int index) {
// Copied from OpenVRInput
VREnvironment env = hardware.getEnvironment();
OculusViewManager vrvm = (OculusViewManager) hardware.getEnvironment().getVRViewManager();
Object obs = env.getObserver();
Quaternion tempq = new Quaternion(); // TODO move to class scope?
if (obs instanceof Camera) {
tempq.set(((Camera) obs).getRotation());
} else {
tempq.set(((Spatial) obs).getWorldRotation());
}
return tempq.multLocal(getOrientation(index));
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public Vector3f getFinalObserverPosition(int index) {
OSVRViewManager vrvm = (OSVRViewManager) environment.getVRViewManager();
if( vrvm == null || isInputDeviceTracking(index) == false ) return null;
Object obs = environment.getObserver();
Vector3f pos = getPosition(index);
if( obs instanceof Camera ) {
((Camera)obs).getRotation().mult(pos, pos);
return pos.addLocal(((Camera)obs).getLocation());
} else {
((Spatial)obs).getWorldRotation().mult(pos, pos);
return pos.addLocal(((Spatial)obs).getWorldTranslation());
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public Vector3f getFinalObserverPosition(int index) {
// Copied from OpenVRInput
VREnvironment env = hardware.getEnvironment();
OculusViewManager vrvm = (OculusViewManager) hardware.getEnvironment().getVRViewManager();
Object obs = env.getObserver();
Vector3f pos = getPosition(index);
if (obs instanceof Camera) {
((Camera) obs).getRotation().mult(pos, pos);
return pos.addLocal(((Camera) obs).getLocation());
} else {
((Spatial) obs).getWorldRotation().mult(pos, pos);
return pos.addLocal(((Spatial) obs).getWorldTranslation());
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Get the observer final position within the scene.
* @return the observer position.
* @see #getFinalObserverRotation()
*/
public Vector3f getFinalObserverPosition() {
if( viewmanager == null ) {
if( observer == null ) {
return getCamera().getLocation();
} else return observer.getWorldTranslation();
}
Vector3f pos = VRhardware.getPosition();
if( observer == null ) {
dummyCam.getRotation().mult(pos, pos);
return pos.addLocal(dummyCam.getLocation());
} else {
observer.getWorldRotation().mult(pos, pos);
return pos.addLocal(observer.getWorldTranslation());
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Alter the transforms of a rigidBody to match the transforms of a bone.
* This is used to make the ragdoll follow animated motion in Kinematic mode
*
* @param link the bone link connecting the bone and the rigidBody
* @param position temporary storage used in calculations (not null)
* @param tmpRot1 temporary storage used in calculations (not null)
*/
protected void matchPhysicObjectToBone(PhysicsBoneLink link, Vector3f position, Quaternion tmpRot1) {
//computing position from rotation and scale
targetModel.getWorldTransform().transformVector(link.bone.getModelSpacePosition(), position);
//computing rotation
tmpRot1.set(link.bone.getModelSpaceRotation()).multLocal(link.bone.getModelBindInverseRotation());
targetModel.getWorldRotation().mult(tmpRot1, tmpRot1);
tmpRot1.normalizeLocal();
//updating physics location/rotation of the physics bone
link.rigidBody.setPhysicsLocation(position);
link.rigidBody.setPhysicsRotation(tmpRot1);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Alter the transforms of a rigidBody to match the transforms of a bone.
* This is used to make the ragdoll follow animated motion in Kinematic mode
*
* @param link the bone link connecting the bone and the rigidBody
* @param position temporary storage used in calculations (not null)
* @param tmpRot1 temporary storage used in calculations (not null)
*/
protected void matchPhysicObjectToBone(PhysicsBoneLink link, Vector3f position, Quaternion tmpRot1) {
//computing position from rotation and scale
targetModel.getWorldTransform().transformVector(link.bone.getModelSpacePosition(), position);
//computing rotation
tmpRot1.set(link.bone.getModelSpaceRotation()).multLocal(link.bone.getModelBindInverseRotation());
targetModel.getWorldRotation().mult(tmpRot1, tmpRot1);
tmpRot1.normalizeLocal();
//updating physics location/rotation of the physics bone
link.rigidBody.setPhysicsLocation(position);
link.rigidBody.setPhysicsRotation(tmpRot1);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
private void spatialToLight(Light light) {
final Vector3f worldTranslation = spatial.getWorldTranslation();
if (light instanceof PointLight) {
((PointLight) light).setPosition(worldTranslation);
return;
}
final TempVars vars = TempVars.get();
final Vector3f vec = vars.vect1;
if (light instanceof DirectionalLight) {
((DirectionalLight) light).setDirection(vec.set(worldTranslation).multLocal(-1.0f));
}
if (light instanceof SpotLight) {
final SpotLight spotLight = (SpotLight) light;
spotLight.setPosition(worldTranslation);
spotLight.setDirection(spatial.getWorldRotation().multLocal(vec.set(Vector3f.UNIT_Y).multLocal(-1)));
}
vars.release();
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public void update(float tpf) {
// update VR pose & cameras
if( environment.getVRViewManager() != null ) {
environment.getVRViewManager().update(tpf);
} else if( environment.getObserver() != null ) {
environment.getCamera().setFrame(((Spatial)environment.getObserver()).getWorldTranslation(), ((Spatial)environment.getObserver()).getWorldRotation());
}
if( environment.isInVR() == false || environment.getVRGUIManager().getPositioningMode() == VRGUIPositioningMode.MANUAL ) {
// only update geometric state here if GUI is in manual mode, or not in VR
// it will get updated automatically in the viewmanager update otherwise
// TODO isn't this done by SimpleApplication?
for (Spatial spatial : application.getGuiViewPort().getScenes()) {
//spatial.updateLogicalState(tpf);
spatial.updateGeometricState();
}
}
// use the analog control on the first tracked controller to push around the mouse
environment.getVRMouseManager().updateAnalogAsMouse(0, null, null, null, tpf);
}
内容来源于网络,如有侵权,请联系作者删除!