#Get Camera's Frustum.

1 messages · Page 1 of 1 (latest)

full halo
#

Is there a way to get a cameras Frustum? im talking about each line, image provided on what a Frustum is.

shy root
#

probbably

full halo
#

What?

full halo
#

im sorry what? i just want the lines, not the planes.

#

a frustum is the 3d triangle bit.

uncut gale
#

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

uncut gale
#

It's not a fun as scaling the FOV to capture the object's dimensions ;)

#

I should probably change + z to + 2z 🤔

full halo
#

But, wow this helps

uncut gale
#

A triangle is defined by its base and height. That doesn't change in the third dimension

uncut gale
# uncut gale

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

full halo
#

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.

uncut gale
full halo
#

That isn't what I said

uncut gale
#

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

full halo
full halo
#

the levels in my game are designed to be small

uncut gale
full halo
#

oh ok, but where would i cut it, and at what angle?

full halo
#

my head is still scratching

uncut gale
#

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

full halo
#

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.

uncut gale
#

This approach views objects through a cone rather than a triangular prism

full halo
#

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

uncut gale
#

It will be a curved cutting plane

full halo
#

uh

uncut gale
#

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

full halo
#

what?

#

i dont think you understand what im trying to do

uncut gale
#

I do

full halo
#

have you seen viewfinder?

uncut gale
#

Oh, that game. Yeah, I don't think you should be working with the frustum for that effect

full halo
#

oh, how else?

uncut gale
#

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

full halo
#

you can freeze viewports.

uncut gale
full halo
#

as for the picture effect. sorry

full halo
uncut gale
full halo
#

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

full halo
uncut gale
#

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

full halo
#

oh my bad

#

i would delete the cloned cutted bits out

#

didnt specify sorry

uncut gale
#

You're cutting the space based on the geometry of the frustum, not the image

full halo
#

what?

uncut gale
#

"delete the objects outside the frustum"

full halo
#

delete the unused cutted up objects. since they wont be needed

uncut gale
#

Even the objects in the frustum

#

The frustum shouldn't be used here

full halo
#

what else should i use?

full halo
#

i know about that as well

uncut gale
#

Then use it

full halo
#

thats what im trying to do>

#

im not talking about manually cutting it up, if thats what your thinking

uncut gale
#

No. Obviously not. You have to use the CSG engine via code to dynamically cut the space

uncut gale
#

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)

full halo
#

but isnt it just a rectangle? it isnt really what i need if it just returns sizes only for rectangles and stuff

uncut gale
#

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

uncut gale
#

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

full halo
#

you want me to go from this, to this?:

uncut gale
#

The image exists at an offset from the camera, but yes

#

That's how the game works

uncut gale
full halo
#

oh

uncut gale
#

In the third dimesnion, it evolves to a cone with a hemispherical base

full halo
#

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

uncut gale
#

Taking a snapshot of the scene is another story

full halo
uncut gale
#

That's probably the only way to get around it

full halo
#

not sure how egomoose did it in his teleportation demo

uncut gale
# full halo 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...

▶ Play video
#

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

uncut gale
#

Also the idea of cloning a copy of the object on the other side

#

Look's like he didn't account for death, lol

full halo
#

I'm not trying to make portals.