#Get Camera's Frustum.
1 messages · Page 1 of 1 (latest)
probbably
What?
im sorry what? i just want the lines, not the planes.
a frustum is the 3d triangle bit.
Through good ol' trigonometry, yeah
Not sure what you mean by "each line", though
This is a formula I developed to scale a part to the prism's bounds given the depth of X from the camera's origin
Theta represents the camera's FOV angle
That same output used to scale the part represents the dimensions of the cutting plane at depth X
It's not a fun as scaling the FOV to capture the object's dimensions ;)
I should probably change + z to + 2z 🤔
Only the triangle bit, sorry
But, wow this helps
Define "trinagle bit"
A triangle is defined by its base and height. That doesn't change in the third dimension
This formula determines the base of an arbitrary portion of the triangular prism resulting from the camera
The height of the triangular prism is equivalent to the depth of the cutting plane (base), so you have all the tools to determine the dimensions of your desired cut
Be it volume, surface area, yada yada
i want the frustum, without the planes in the image i showed, which is near clipping and far clipping
the reason i want the frustum is because im making a viewfinder type game. and i would cut all the objects that arent in a camera, which means i should probably use planes.= instead of lines, but this still helps.
Just check if the angle between the object and the camera is <= to its FOV angle
That isn't what I said
That's how you cut out objects that aren't in its FOV
The camera's view frustum isn't a tangible object in Roblox; it virtually extends forever
The only way to materialize the triangular prism is to set an arbitrary rear cutting plane
oh, i get it, how would i do this exactly though?
around 1000 - 500, as long as i can materialize it, i really dont mind the length
the levels in my game are designed to be small
local degreeAngle = math.deg(cameraLookVector:Angle(object.Position.Unit))
oh ok, but where would i cut it, and at what angle?
^
my head is still scratching
In reality, it's not that simple
You can expect this to be slow, lol
You can try by getting all the objects within a certain radius of the camera, then working on that group
but when the object isnt even supposed to be touching the frustum, it still reports <= camerafov
which isnt really the best but iguess it still works
and when it is touching, it also doesnt even report <= camerafov, sometimes 80, sometimes 60.
This approach views objects through a cone rather than a triangular prism
ah
i could add some error? making the cone pretty much bigger
but the problem still comes with: (how to cut)
well i know how to cut, just where
^
It will be a curved cutting plane
uh
You'll need to keep track of the objects that were in the last frame to see if they're no longer in the current group
I do
have you seen viewfinder?
Oh, that game. Yeah, I don't think you should be working with the frustum for that effect
oh, how else?
It's just some clever positioning as far as I'm aware
There's an image and a separate model containing the bounds of the replacing structure
you can freeze viewports.
Use the CSG engine to cut out the shape of the replacing structure
as for the picture effect. sorry
that is what im doing
what i was gonna do if i had the frustum is clone the objects, cut them, delete the objects outside the frustum, when the player desides to put the picture, delete all the parts IN the frustum and paste the parts with positioning relative to the camera. all of which i know how to do besides the frustum bit
i already know how that works.
That wouldn't work
The frustum being a trinagular prism would cause tons of objects outside of the image to be removed
You need to remove the surrounding space based on the bounding-box of the replacing space
That doesn't change this fact
You're cutting the space based on the geometry of the frustum, not the image
what?
"delete the objects outside the frustum"
delete the unused cutted up objects. since they wont be needed
what else should i use?
i know about that as well
Then use it
thats what im trying to do>
im not talking about manually cutting it up, if thats what your thinking
No. Obviously not. You have to use the CSG engine via code to dynamically cut the space
that is what im saying
You should already have the bounding-box of the replacing space through the Model that contains its parts. It's as simple as Model:GetExtentsSize
Figure out the depth and rotation of where to lay that bounding box from the camera, then use the CSG engine to cut out the space
(This is all done through a script)
but isnt it just a rectangle? it isnt really what i need if it just returns sizes only for rectangles and stuff
A rectangle is all you need
Viewfinder does the same thing
If you cut the space based on the overall geometry of the space, you wouldn't be able to walk into it
It's like a perfect puzzle piece fitted into the ground or wall
That's why most replacing structures are rooms
The image itself is a dammed rectangle, lol
You're replacing the space with the entire image
The cut should match the dimensions of the image, and its unobservable depth
That is all found here
you want me to go from this, to this?:
This is what I was referring to earlier:
oh
In the third dimesnion, it evolves to a cone with a hemispherical base
its still a little difficult to wrap my head around but i think i get it
because all i want to do is just take a "screenshot" and put it somewhere else. if its slightly off, i really dont mind
This is how that's gonna happen
Taking a snapshot of the scene is another story
i mean you can freeze viewports, get camera's position, only problem is the sky.
I have not seen the full extent of the view-finder game; however, I have seen a copy that had a feature where you could take a picture of a scene. It used a black backdrop for the sky
That's probably the only way to get around it
true
not sure how egomoose did it in his teleportation demo
Experimenting with portals, for science.
The project is available here: https://github.com/SebLague/Portals/tree/master
If you'd like to get early access to new projects, or simply want to support me in creating more videos, please visit https://www.patreon.com/SebastianLague
Resources I used:
http://tomhulton.blogspot.com/2015/08/portal-rende...
Roblox doesn't support half the methods used to achieve this effect in Unity
It's likely that there is a sensor in front of the portal that is used to start relaying objects within it to a ViewportFrame
Actually, you can look at the code, lol
His test place is copyable
What you should take from this is the camera's movement
Also the idea of cloning a copy of the object on the other side
Look's like he didn't account for death, lol
I'm not trying to make portals.