X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Ftools%2FNodeTools.java;h=be778dc367b4bf2d4b0f332f6c5dfc1b6eae95e0;hb=53d55c24c779745f188bdb18d32f71d20acb61b2;hp=233fbacd60199de85c13e430c60e7c268fe2cbbb;hpb=87b3241ec277ba3d8e414b26186a032c9cdcaeed;p=simantics%2F3d.git diff --git a/org.simantics.g3d/src/org/simantics/g3d/tools/NodeTools.java b/org.simantics.g3d/src/org/simantics/g3d/tools/NodeTools.java index 233fbacd..be778dc3 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/tools/NodeTools.java +++ b/org.simantics.g3d/src/org/simantics/g3d/tools/NodeTools.java @@ -1,3 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2012, 2013 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ package org.simantics.g3d.tools; import javax.vecmath.Matrix4d; @@ -49,22 +60,22 @@ public class NodeTools { public static Vector3d getLocalPosition(IG3DNode node, Vector3d worldCoord) { - + IG3DNode parent = (IG3DNode)node.getParent(); - if (parent == null) {// this is a root node ( has no transformation) - return worldCoord; - } + if (parent == null) {// this is a root node ( has no transformation) + return worldCoord; + } - Vector3d local = getLocalPosition(parent,worldCoord); - local.sub(node.getPosition()); - - Quat4d q = new Quat4d(); - q.set(node.getOrientation()); - q.inverse(); - MathTools.rotate(q, local, local); - - return local; - } + Vector3d local = getLocalPosition(parent,worldCoord); + local.sub(node.getPosition()); + + Quat4d q = new Quat4d(); + q.set(node.getOrientation()); + q.inverse(); + MathTools.rotate(q, local, local); + + return local; + } public static Quat4d getLocalOrientation(IG3DNode node, Quat4d worldRot) {