/******************************************************************************* * 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.jme.shape; import javax.vecmath.AxisAngle4d; import javax.vecmath.Vector3d; import org.simantics.g3d.math.MathTools; import org.simantics.g3d.shape.Color4d; import org.simantics.g3d.shape.Cone; import org.simantics.g3d.shape.Cylinder; import org.simantics.g3d.shape.Sphere; import com.jme3.app.Application; public class AxesActor2 extends MeshNode { public AxesActor2(Application app, double size) { super(app); int res = 16; org.simantics.g3d.shape.Mesh cone_x = Cone.create(size*0.3, res); org.simantics.g3d.shape.Mesh cone_y = Cone.create(size*0.3, res); org.simantics.g3d.shape.Mesh cone_z = Cone.create(size*0.3, res); cone_x.rotate(MathTools.getQuat(new AxisAngle4d(0,0,-1,Math.PI*0.5))); cone_z.rotate(MathTools.getQuat(new AxisAngle4d(1,0,0,Math.PI*0.5))); cone_x.translate(new Vector3d(size,0,0)); cone_y.translate(new Vector3d(0,size,0)); cone_z.translate(new Vector3d(0,0,size)); org.simantics.g3d.shape.Mesh tube_x = Cylinder.create(MathTools.ORIGIN, new Vector3d(size,0,0), size*0.1, res); org.simantics.g3d.shape.Mesh tube_y = Cylinder.create(MathTools.ORIGIN, new Vector3d(0,size,0), size*0.1, res); org.simantics.g3d.shape.Mesh tube_z = Cylinder.create(MathTools.ORIGIN, new Vector3d(0,0,size), size*0.1, res); org.simantics.g3d.shape.Mesh sphere = Sphere.create(size*0.3, res, res*2/3); Color4d x_col = new Color4d(1,0,0,1); Color4d y_col = new Color4d(1,1,0,1); Color4d z_col = new Color4d(0,1,0,1); Color4d o_col = new Color4d(0,0,1,1); cone_x.setColor(x_col); tube_x.setColor(x_col); cone_y.setColor(y_col); tube_y.setColor(y_col); cone_z.setColor(z_col); tube_z.setColor(z_col); sphere.setColor(o_col); sphere.add(cone_x); sphere.add(tube_x); sphere.add(cone_y); sphere.add(tube_y); sphere.add(cone_z); sphere.add(tube_z); setMesh(sphere); } }