The X axis in the model I am working on is parallel to the camera. Is there a way to return the visible range of the x-axis in 3D units like [-2,2]?
Greetings, and welcome to the community! I hope that you enjoy your time here!
As to your question: Hmm… Is the visible range not simply the “far-distance” of the camera that you’re using? As acquired by something along these lines:
Or do you want to know where an arbitrary line–in this case the x-axis of your model–exits the region visible to the camera…? Or something else?
Do you mean the X axis range of aspect2d, perhaps, or do you really mean of the 3-D scene / camera frustum?
Hi, yes, I want to know when an arbitrary line–in this case the x-axis enters and exits the region visible to the camera. Generally I need this to calculate later the starting point of an object in pixels. For example: the camera is at x = 1, the object is at position (x= -2, y=0, z=0) the visible image is 1920px wide. What is the starting point of the object in pixels?
Hmm, okay, I see.
Well, as I’m inclined to look at it, there are two parts to that process: First, determining the intersection of an arbitrary line-segment with the camera-frustum, and second, determining the pixel-position of an arbitrary point in the world.
As to the first part, there may be an easier way, but what comes to mind is this: Create six planes, one for each face of the camera-frustum, and then use their “intesectsLine” methods to find the intercepts of your line.
As to the second part, one might initially think that this is easy: The “lens” class (which is used by the camera) provides a set of “project” methods that return the position of a 3D point on the 2D view.
However, according to the API, this is only guaranteed to work for points that are within the view of the lens. When the point is outside of this view, something may be output, but it’s not necessarily something meaningful.
So, what I’d suggest trying instead is this: From the lens, call “getViewMat()” to get the lens’s view-matrix. Then apply this matrix to the point. I’m not sure, but I think that this should give you the position in question.
6 posts were split to a new topic: “Scripting Issues” is turning into “General Discussion”