freespace in camera model placement on click

I am creating an environment where the user can “fly” the camera around the scene. I am trying to figure out how to place new models under the mouse when they click on the screen. The specific issue I cannot figure out is the coordinates to assign to the newly created model. I am trying to use a collisionray which has been set from lens. I’m thinking I should be able to somehow combine the origin and direction of the collision ray with the location of the camera to compute the location to assign the new object, but, the best I’ve been able to do is get the object to appear near the camera’s location. I suspect I need to convert the ray’s origin to world coordinates, but I have no idea how to do that. Any thoughts or suggestions would be most appreciated.

I figured it out. I just got the relative point of the click in render coordinates by using:


render.get_relative_point( camera, pickerRay.getOrigin() * OFFSET_DISTANCE )
1 Like