]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d/src/org/simantics/proconf/g3d/shapes/GridShape.java
Naming fixes.
[simantics/3d.git] / org.simantics.g3d / src / org / simantics / proconf / g3d / shapes / GridShape.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007- VTT Technical Research Centre of Finland.\r
3  * All rights reserved. This program and the accompanying materials\r
4  * are made available under the terms of the Eclipse Public License v1.0\r
5  * which accompanies this distribution, and is available at\r
6  * http://www.eclipse.org/legal/epl-v10.html\r
7  *\r
8  * Contributors:\r
9  *     VTT Technical Research Centre of Finland - initial API and implementation\r
10  *******************************************************************************/\r
11 package org.simantics.proconf.g3d.shapes;\r
12 \r
13 import com.jme.renderer.ColorRGBA;\r
14 import com.jme.renderer.Renderer;\r
15 import com.jme.scene.Geometry;\r
16 import com.jme.scene.Line;\r
17 import com.jme.scene.state.MaterialState;\r
18 import com.jme.util.geom.BufferUtils;\r
19 \r
20 public class GridShape {\r
21     \r
22  \r
23         public static Geometry getShape(Renderer renderer, int lineCount, float delta) {\r
24             \r
25         float[] coords = new float[lineCount*lineCount*2*3];\r
26         float size = delta * lineCount;\r
27         float halfSize = size * 0.5f;\r
28         \r
29         for (int i = 0 ; i <= lineCount; i++) {\r
30             int index = i*3*2;\r
31             coords[index++] = -halfSize + i * delta;\r
32             coords[index++] = 0.f;\r
33             coords[index++] = -halfSize;\r
34             coords[index++] = -halfSize + i * delta;\r
35             coords[index++] = 0.f;\r
36             coords[index++] = +halfSize;\r
37         }\r
38         for (int i = 0 ; i <= lineCount; i++) {\r
39             int index = (i + lineCount + 1)*3*2;\r
40             coords[index++] = -halfSize;\r
41             coords[index++] = 0.f;\r
42             coords[index++] = -halfSize + i * delta;\r
43             coords[index++] = +halfSize;\r
44             coords[index++] = 0.f;\r
45             coords[index++] = -halfSize + i * delta;\r
46         }\r
47 \r
48         Line shape = new Line("",BufferUtils.createFloatBuffer(coords),null,null,null);\r
49         MaterialState ms = renderer.createMaterialState();\r
50         ms.setEmissive(new ColorRGBA(1.f,1.f,1.f,0.f));\r
51         shape.setRenderState(ms);\r
52         shape.setCullMode(Geometry.CULL_NEVER);\r
53         return shape;\r
54        \r
55     }\r
56 \r
57 }\r