SDK : the probe radius is now a dashed lines cirle
This commit is contained in:
parent
aa067ef60d
commit
667afa9ef3
@ -0,0 +1,23 @@
|
|||||||
|
ShaderNodeDefinitions{
|
||||||
|
ShaderNodeDefinition Dashed {
|
||||||
|
Type: Fragment
|
||||||
|
|
||||||
|
Shader GLSL100: com/jme3/gde/scenecomposer/gizmo/light/mat/dashed/Dashed100.frag
|
||||||
|
|
||||||
|
Documentation{
|
||||||
|
Renders dashed lines
|
||||||
|
@input vec2 texCoord The texture coordinates
|
||||||
|
@input float size the size of the dashes
|
||||||
|
@input vec4 inColor the color of the fragment so far
|
||||||
|
@outColor vec4 color the output color
|
||||||
|
}
|
||||||
|
Input {
|
||||||
|
vec2 texCoord
|
||||||
|
vec4 inColor
|
||||||
|
float size
|
||||||
|
}
|
||||||
|
Output {
|
||||||
|
vec4 outColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
void main(){
|
||||||
|
//@input vec2 texCoord The texture coordinates
|
||||||
|
//@input float size the size of the dashes
|
||||||
|
//@output vec4 color the output color
|
||||||
|
|
||||||
|
//insert glsl code here
|
||||||
|
outColor = inColor;
|
||||||
|
outColor.a = step(1.0 - size, texCoord.x);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
MaterialDef Simple {
|
||||||
|
MaterialParameters {
|
||||||
|
Float DashSize
|
||||||
|
}
|
||||||
|
Technique {
|
||||||
|
WorldParameters {
|
||||||
|
WorldViewProjectionMatrix
|
||||||
|
}
|
||||||
|
VertexShaderNodes {
|
||||||
|
ShaderNode CommonVert {
|
||||||
|
Definition : CommonVert : Common/MatDefs/ShaderNodes/Common/CommonVert.j3sn
|
||||||
|
InputMappings {
|
||||||
|
worldViewProjectionMatrix = WorldParam.WorldViewProjectionMatrix
|
||||||
|
modelPosition = Global.position.xyz
|
||||||
|
texCoord1 = Attr.inTexCoord
|
||||||
|
vertColor = Attr.inColor
|
||||||
|
}
|
||||||
|
OutputMappings {
|
||||||
|
Global.position = projPosition
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FragmentShaderNodes {
|
||||||
|
ShaderNode Dashed {
|
||||||
|
Definition : Dashed : com/jme3/gde/scenecomposer/gizmo/light/mat/dashed/Dashed.j3sn
|
||||||
|
InputMappings {
|
||||||
|
texCoord = CommonVert.texCoord1
|
||||||
|
inColor = CommonVert.vertColor
|
||||||
|
size = MatParam.DashSize
|
||||||
|
}
|
||||||
|
OutputMappings {
|
||||||
|
Global.color = outColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -33,8 +33,10 @@ package com.jme3.gde.scenecomposer.gizmo.light.shape;
|
|||||||
|
|
||||||
import com.jme3.asset.AssetManager;
|
import com.jme3.asset.AssetManager;
|
||||||
import com.jme3.material.Material;
|
import com.jme3.material.Material;
|
||||||
|
import com.jme3.material.RenderState;
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.math.FastMath;
|
import com.jme3.math.FastMath;
|
||||||
|
import com.jme3.renderer.queue.RenderQueue;
|
||||||
import com.jme3.scene.Geometry;
|
import com.jme3.scene.Geometry;
|
||||||
import com.jme3.scene.Mesh;
|
import com.jme3.scene.Mesh;
|
||||||
import com.jme3.scene.VertexBuffer.Type;
|
import com.jme3.scene.VertexBuffer.Type;
|
||||||
@ -54,7 +56,7 @@ public class ProbeRadiusShape extends Mesh {
|
|||||||
|
|
||||||
protected int vertCount;
|
protected int vertCount;
|
||||||
protected int triCount;
|
protected int triCount;
|
||||||
protected int radialSamples = 64;
|
protected int radialSamples = 256;
|
||||||
protected boolean useEvenSlices;
|
protected boolean useEvenSlices;
|
||||||
protected boolean interior;
|
protected boolean interior;
|
||||||
/**
|
/**
|
||||||
@ -79,9 +81,12 @@ public class ProbeRadiusShape extends Mesh {
|
|||||||
|
|
||||||
FloatBuffer posBuf = BufferUtils.createVector3Buffer((radialSamples + 1));
|
FloatBuffer posBuf = BufferUtils.createVector3Buffer((radialSamples + 1));
|
||||||
FloatBuffer colBuf = BufferUtils.createFloatBuffer((radialSamples + 1) * 4);
|
FloatBuffer colBuf = BufferUtils.createFloatBuffer((radialSamples + 1) * 4);
|
||||||
|
FloatBuffer texBuf = BufferUtils.createVector2Buffer(radialSamples + 1);
|
||||||
|
|
||||||
|
|
||||||
setBuffer(Type.Position, 3, posBuf);
|
setBuffer(Type.Position, 3, posBuf);
|
||||||
setBuffer(Type.Color, 4, colBuf);
|
setBuffer(Type.Color, 4, colBuf);
|
||||||
|
setBuffer(Type.TexCoord, 2, texBuf);
|
||||||
|
|
||||||
// generate geometry
|
// generate geometry
|
||||||
float fInvRS = 1.0f / radialSamples;
|
float fInvRS = 1.0f / radialSamples;
|
||||||
@ -106,26 +111,10 @@ public class ProbeRadiusShape extends Mesh {
|
|||||||
.put(ColorRGBA.Orange.g)
|
.put(ColorRGBA.Orange.g)
|
||||||
.put(ColorRGBA.Orange.b)
|
.put(ColorRGBA.Orange.b)
|
||||||
.put(ColorRGBA.Orange.a);
|
.put(ColorRGBA.Orange.a);
|
||||||
|
texBuf.put(iR % 2f)
|
||||||
|
.put(iR % 2f);
|
||||||
|
|
||||||
}
|
}
|
||||||
// for (int iR = 0; iR <= radialSamples; iR++) {
|
|
||||||
// posBuf.put(afCos[iR])
|
|
||||||
// .put(0)
|
|
||||||
// .put(afSin[iR]);
|
|
||||||
// colBuf.put(ColorRGBA.Green.r)
|
|
||||||
// .put(ColorRGBA.Green.g)
|
|
||||||
// .put(ColorRGBA.Green.b)
|
|
||||||
// .put(ColorRGBA.Green.a);
|
|
||||||
// }
|
|
||||||
// for (int iR = 0; iR <= radialSamples; iR++) {
|
|
||||||
// posBuf.put(0)
|
|
||||||
// .put(afCos[iR])
|
|
||||||
// .put(afSin[iR]);
|
|
||||||
// colBuf.put(ColorRGBA.Yellow.r)
|
|
||||||
// .put(ColorRGBA.Yellow.g)
|
|
||||||
// .put(ColorRGBA.Yellow.b)
|
|
||||||
// .put(ColorRGBA.Yellow.a);
|
|
||||||
// }
|
|
||||||
|
|
||||||
updateBound();
|
updateBound();
|
||||||
setStatic();
|
setStatic();
|
||||||
@ -148,10 +137,6 @@ public class ProbeRadiusShape extends Mesh {
|
|||||||
idxBuf.put((short) (idx + 1));
|
idxBuf.put((short) (idx + 1));
|
||||||
idx++;
|
idx++;
|
||||||
segDone++;
|
segDone++;
|
||||||
// if (segDone == radialSamples || segDone == radialSamples * 2) {
|
|
||||||
// idx++;
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -166,9 +151,13 @@ public class ProbeRadiusShape extends Mesh {
|
|||||||
ProbeRadiusShape b = new ProbeRadiusShape();
|
ProbeRadiusShape b = new ProbeRadiusShape();
|
||||||
Geometry geom = new Geometry("BoundingDebug", b);
|
Geometry geom = new Geometry("BoundingDebug", b);
|
||||||
|
|
||||||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
Material mat = new Material(assetManager, "com/jme3/gde/scenecomposer/gizmo/light/mat/dashed/dashed.j3md");
|
||||||
mat.setBoolean("VertexColor", true);
|
|
||||||
mat.getAdditionalRenderState().setWireframe(true);
|
mat.getAdditionalRenderState().setWireframe(true);
|
||||||
|
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
|
||||||
|
mat.getAdditionalRenderState().setDepthWrite(false);
|
||||||
|
mat.getAdditionalRenderState().setDepthTest(false);
|
||||||
|
mat.setFloat("DashSize", 0.5f);
|
||||||
|
geom.setQueueBucket(RenderQueue.Bucket.Transparent);
|
||||||
geom.addControl(new BillboardControl());
|
geom.addControl(new BillboardControl());
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user