Skip to main content
gamedev.net
🔒 Locked

Portal problem

Started by N64Marin 6 replies 1.5k views
Original Post
N64Marin
N64Marin
I'm considering a portal engine. But in a portal engine, your must first determine which portal you're in. How to solve that problem?
haphazardlynamed
haphazardlynamed
i think you mean sector
-which sector you are in

with a portal engine you have sectors joined by portals

to start off, you really should know which sector you start in, since when you design your map you have to place a 'spawn point' or something for the player to start at, right?

then you'd just keep track of which one he moves into whenever walking thru a portal

simple enough, or are you asking something else?
N64Marin
N64Marin
I'm not using any player spawn point. How to determine the sector with an arbitary camera point?
greldik
greldik
Not trying to be rude or anything, but maybe you should start with something more simple? Or at least read some tutorials on the subject. Do a search on goolge, I'm sure there are lots of them.

Anyway, to try and answer your question.
Find the closest sectors to your object (to narrow it down a bit). Dot the object position with the planes that make up a sector and see if the dot is positive on all planes, if they are, you've found the sector.

I assume the sectors are convex.
N64Marin
N64Marin
I've considered your answer. If there is many sectors, your algorithm will be very slow. I'm considering using a BSP tree to separate the sectors. The dividing planes will be chosen from the portal polygons. But this algorithm only applies to convex sectors. I just want an algorithm for both convex and concave sectors.
Armand
Armand
The way I would determin if I was in a sector(room, cell, [insert other name of containing object here]) is by doing an aabb(axis alinged bounding box) check as a first pass.

your sectors can genorate these on load, or your could pre-gen them. its a very quick negitive test.

But there is always more than one one way of solving a problem.

Armand.
Armand -------------------------It is a good day to code.
N64Marin
N64Marin
The AABB approach seems not reliable. As the AABBs of different sectors may overlap.
greldik
greldik
Quote:
If there is many sectors, your algorithm will be very slow

That's why I wrote "Find the closest sectors" first. How you find the closest sectors to your point can be done in a number of different ways. quad/oct-tree, bsp, simple sector+radius-to-point-test, ...

The AABB approach Armand mentioned is also to narrow down the number of possible sectors.

Anyway, you only have to find a sector one time. Speed is not really important at that time, right? When you've found it, do as haphazardlynamed said.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.