Jump to content
  • Advertisement
Paul Drage

Frustums, bounding boxes and can one object see another

Recommended Posts

I think OP just needs some direction as to how to go about the math itself.

There are a few ways to go about it. Any 3d library that has "cameras" and all that is just using matrices, vertices, points, etc. If you are doing everything in 2d, it's entirely possible to do all of this using Euler X and Y coordinates and trig. It would better to learn some vector math, and use that. The exact same vector math will translate to 3d easily if you go that route.

If nothing else, if Three.js works, look at its source code for the underlying math and logic. Look up 3blue1brown vector math videos. Good search terms would include ray/circle intersection algorithms, 2d vector math tutorials, etc.

No idea if that helps, but my 2c. :)

Share this post


Link to post
Share on other sites
Advertisement
3 hours ago, Zakwayda said:

Just to be completely clear, is the issue you're facing that you want to perform operations on the server side that Three.js could handle for you, but you don't have Three.js available in that setting and you're not sure how to implement equivalent functionality yourself?

Yeah pretty much this - i went down the route a few weeks ago at looking how i may run three.js server side and realised that was just wrong on so many levels

2 hours ago, Scienthsine said:


There are a few ways to go about it. Any 3d library that has "cameras" and all that is just using matrices, vertices, points, etc. If you are doing everything in 2d, it's entirely possible to do all of this using Euler X and Y coordinates and trig. It would better to learn some vector math, and use that. The exact same vector math will translate to 3d easily if you go that route.

Thanks @Scienthsine really good point - i supposed i assumed there to be some 'magic' in threejs' camera system - i will lookup the videos you mention and also dig about in the threejs source - it is open source so i suppose i can pull the functions for 'insersectObject' (et al) and write them into a different language for server side

 

Share this post


Link to post
Share on other sites
15 minutes ago, Paul Drage said:

... i supposed i assumed there to be some 'magic' in threejs' camera system - i will lookup the videos you mention and also dig about in the threejs source - it is open source so i suppose i can pull the functions for 'insersectObject' (et al) and write them into a different language for server side

No magic - it's just math, which can be replicated in pretty much any environment as needed. (Not to say it's trivial necessarily - just that is can be done.)

Although I've read the whole thread, I don't remember everything that's been discussed, so I may be repeating some things. But, what you'll need to do obviously depends on some variables, like how the environment is represented and so on.

I gather from your initial post that this is 3-d and that therefore purely 2-d solutions won't suffice. It also sounds like there are two problems you want to solve: being visible or not based on position and orientation (ignoring obstacles), and whether there's an unobstructed line of sight between two entities.

For the first problem, you could do what a typical camera system does, which usually involves a frustum built out of planes. There are other options though, such as a visibility cone or some other ad hoc solution. That's probably the easier of the two problems to solve (determining line of sight can be more demanding). In any case, if you run into problems you can always post back here.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!