Camera frustum mesh

I want to obtain a mesh to represent the frustum of a camera. I’ve found in this forum some help and my current code is:



[java]ShadowUtil.updateFrustumPoints2(viewPort.getCamera(), points);

rootNode.attachChild(createFrustum(points, assetManager));[/java]



[java]private Geometry createFrustum(Vector3f[] pts, AssetManager assetManager) {



WireFrustum frustum = new WireFrustum(pts);

Geometry frustumMdl = new Geometry(“f”, frustum);

frustumMdl.setCullHint(Spatial.CullHint.Never);

frustumMdl.setShadowMode(ShadowMode.Off);

frustumMdl.setMaterial(new Material(assetManager, “Common/MatDefs/Misc/WireColor.j3md”));

frustumMdl.getMaterial().setColor(“m_Color”, ColorRGBA.White);



return frustumMdl;

}[/java]



However, the problem is that this code generates only the wire frustum and I need to obtain a “solid” mesh. I have changed the material but this is not enough and the problem is related to the mesh. As there exists a class “Wirefrustum” that extends “Mesh” but not a “Frustum” one, how could I obtain the “solid” mesh?



I think that maybe I could use the “Dome” class to create a pyramid representing the frustum, but I don’t know how to use the points vector returned by ShadowUtil.updateFrustumPoints2(viewPort.getCamera(), points) in this class.



Thank you very much for your time.

Did you look into the WireFrustum code?

copy it, name it PlainFrustum, changeline 66 to

[java]

setMode(Mode.Trangles);

[/java]

then instead of the wireColor material definition use the unshaded…

it should work



also don’t use “m_Color” use “Color” for the material parameter name

Thank you, but I still have a problem. Now the sides of the frustum are missing as you can see in the following picture:



try this

frustumMdl.getMaterial().getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);

I have tried it but sides of the frustum are still missing. It could be related to the following in the PlainFrustum class?



setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(points));