Camera Debug cone drawing

   public  void  createCameraFrustum(Camera cam) {
        Vector3f[] points = new Vector3f[8];
	for (int i = 0; i < 8; i++) {
		points[i] = new Vector3f();
	Camera frustumCam = cam.clone();
//	frustumCam.setLocation(new Vector3f(0, 0, 0));
//	frustumCam.lookAt(Vector3f.UNIT_Z, Vector3f.ZERO);
	ShadowUtil.updateFrustumPoints2(frustumCam, points);
	Mesh mesh = WireFrustum.makeFrustum(points);
	Geometry frustumGeo = new Geometry("Viewing.Frustum", mesh);
	Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
	mat.setColor("Color", ColorRGBA.Red);

This is the literature

I want to draw the camera for debug.
But when I put the createCameraFrustum(Camera CAM) in the Update() I drew a lot of Camera wireframes on the screen.
How can I change this code so that it doesn’t draw too many camera wireframes when it goes into update().
Problem description
Effect of target

update() is called every frame. Don’t do things on update unless you want them done every frame.

initialize() is called once. Do things on initialize() that you only want done once.

Probably you want to create the frustumGeo on initialize and then only move it on update.

1 Like

Thank you for your advice and guidance

	Spatial.lookAt(Vector3f position, Vector3f upVector)
        Spatial.move(Vector3f offset)
        Spatial.rotateUpTo(Vector3f newUp)

I didn’t move frustumGeo correctly. I tried these methods. They didn’t move like a camera moves…

What did I miss?? :pensive: :pensive:


…which is also exactly what a CameraControl would do…

This is the initial position of the camera.

When running to this location in update the camera changes and this causes the initialization of frustumGeo to be in the wrong location.
FrustumGeo is now initialized
How do I change the location where frustumGeo has been initialized

First you were asking about getting the camera debug cone in the right place. Now you seem to be asking about something totally different.

updateLogicalState() is what JME calls on the scene graph to make EVERYTHING WORK. It’s what updates all the stuff. It updates the controls. It updates and dirty state. It updates all the stuff.

It is unrelated to any issue that you could be possibly having except for execution order (things may be a frame behind).

Get the simple things working first. Then worry about the hard stuff.

Yes, I was wondering how to put the camera debug cone in the right place

When I deleted frustumGeo from update(), there would only be one frustumGeo in the wrong place. I started to find out what caused frustumGeo to appear in the wrong place

This is my debug(I found myself going further and further along in my mistakes :pensive:)
The camera does not return the correct value until the update() is run the first time
Any suggestions for getting FrustumGeo initialized in the right place

Initialize frustumGeo once in initialize().
Initialize frustumGeo once in initialize().
Initialize frustumGeo once in initialize().
Initialize frustumGeo once in initialize().
Just the one time.
Only once.
just once.
In initialize.
So that it is only created once. So there is just one of them. Not 5,000,246,262,216 of them.
Just one.
In initialize().

Attach it to the root node just once in initialize(). Just the one time.

Update it’s location every frame in update().
By setting its world location to the same as the camera’s world location.
By settings its world rotation to the same as the camera’s world rotation.

OR: just adding a CameraControl to frustumGeo

1 Like

Yes I initialized it once .
used it in update()


simpleApp.getRootNode().getChild("Viewing.Frustum").setLocalTranslation(new Vector3f(0,0,0));

I set up setLocalTranslation(new Vector3f(0,0,0)) cone box Not in the right place
The cone box is not displayed at position (0,0,0)


SetLocalTranslation (cam.getLocation()) will also not appear in the correct position

I made it

When I find that I can’t initialize the cone frame position correctly
I revisited this link to see if I missed anything

When I see cam.clone() browsed through the API and found that this was a copy camera
Copy the camera and modify the value so that the cone box is displayed in the correct position

I’m going to start the experiment of the collision between the X-ray camera and the wall :laughing: :laughing: :laughing: :laughing: :laughing: :laughing: :laughing: :laughing: :laughing: :laughing: :laughing: :laughing: :laughing:

1 Like

Thank you for your help and reply :kissing_heart: :kissing_heart: :kissing_heart:

1 Like