--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007- VTT Technical Research Centre of Finland.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.proconf.g3d.shapes;\r
+\r
+import com.jme.renderer.ColorRGBA;\r
+import com.jme.renderer.Renderer;\r
+import com.jme.scene.Geometry;\r
+import com.jme.scene.Line;\r
+import com.jme.scene.state.MaterialState;\r
+import com.jme.util.geom.BufferUtils;\r
+\r
+public class GridShape {\r
+ \r
+ \r
+ public static Geometry getShape(Renderer renderer, int lineCount, float delta) {\r
+ \r
+ float[] coords = new float[lineCount*lineCount*2*3];\r
+ float size = delta * lineCount;\r
+ float halfSize = size * 0.5f;\r
+ \r
+ for (int i = 0 ; i <= lineCount; i++) {\r
+ int index = i*3*2;\r
+ coords[index++] = -halfSize + i * delta;\r
+ coords[index++] = 0.f;\r
+ coords[index++] = -halfSize;\r
+ coords[index++] = -halfSize + i * delta;\r
+ coords[index++] = 0.f;\r
+ coords[index++] = +halfSize;\r
+ }\r
+ for (int i = 0 ; i <= lineCount; i++) {\r
+ int index = (i + lineCount + 1)*3*2;\r
+ coords[index++] = -halfSize;\r
+ coords[index++] = 0.f;\r
+ coords[index++] = -halfSize + i * delta;\r
+ coords[index++] = +halfSize;\r
+ coords[index++] = 0.f;\r
+ coords[index++] = -halfSize + i * delta;\r
+ }\r
+\r
+ Line shape = new Line("",BufferUtils.createFloatBuffer(coords),null,null,null);\r
+ MaterialState ms = renderer.createMaterialState();\r
+ ms.setEmissive(new ColorRGBA(1.f,1.f,1.f,0.f));\r
+ shape.setRenderState(ms);\r
+ shape.setCullMode(Geometry.CULL_NEVER);\r
+ return shape;\r
+ \r
+ }\r
+\r
+}\r