[SOLVED] Problem displaying field of sight [NEWBIE QUESTION]

Hi everyone,

I have an agent (a sphere in my case) and I’ m trying to depict the field of sight with just two lines to show the bounds.

Here what I’ve done so far:

    Ray ray= new Ray(pursuer.getLocalTranslation(), pursuer.getLocalRotation().getRotationColumn(2));
  
    Quaternion rotation = new Quaternion();
    rotation.fromAngleAxis((float) Math.toRadians(degreeField),Vector3f.UNIT_Y);
    Vector3f firstLimit = rotation.mult(ray.getDirection());
    rotation.fromAngleAxis((float) Math.toRadians(-degreeField),Vector3f.UNIT_Y);
    Vector3f secondLimit = rotation.mult(ray.getDirection());
    
    Geometry l1 = new Geometry("l1", new Line(ray.getOrigin(), firstLimit.mult(10)));
    Geometry l2 = new Geometry("l2", new Line(ray.getOrigin(), secondLimit.mult(10)));
    Geometry line1 = new Geometry("line1", new Line(ray.getOrigin(), ray.getDirection().mult(10)));

And it works until I translate the agent (pursuer), indeed when I do the lines still point to the same position as the agent haven’ t moved.

So my question is, how can I move the origin of the rotation together with the translation?

Thanks in advance for any hint.

Use a node.

https://jmonkeyengine.github.io/wiki/tutorials/scenegraph/assets/fallback/index.html

Rotate/move the node.

1 Like

Oh I see… I tried to use it but I didn’t attach the lines to it before…
That worked thanks a lot !