]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d/src/org/simantics/g3d/shape/Cylinder.java
Mesh API to use Tuple3d instead of Vector3d
[simantics/3d.git] / org.simantics.g3d / src / org / simantics / g3d / shape / Cylinder.java
1 /*******************************************************************************
2  * Copyright (c) 2012, 2013 Association for Decentralized Information Management in
3  * Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.g3d.shape;
13
14 import java.util.ArrayList;
15 import java.util.List;
16
17 import javax.vecmath.Tuple3d;
18 import javax.vecmath.Vector3d;
19
20 public class Cylinder {
21         
22         public static Mesh create(Vector3d start, Vector3d dir, double r, int s) {
23                 Tube tube = new Tube();
24                 tube.setResolution(s);
25                 tube.setRadius(r);
26                 List<Tuple3d> vertices = new ArrayList<Tuple3d>();
27                 vertices.add(start);
28                 Vector3d t = new Vector3d(start);
29                 t.add(dir);
30                 vertices.add(dir);
31                 tube.setVertices(vertices);
32                 return tube.create();
33         }
34
35 }