PDA

View Full Version : TR Programming Help Needed


Cochrane
08-05-07, 21:21
Hi, I have a question concerning writing my own Tomb Raider tools. Is there any chance I might get an answer here?

I'm currently trying to get the program I used to make my comics with (if you're interested, they're here (http://ferroequinologist.de/en/comics/)) in a shape where I can offer it as a download for everyone.

However, there are still some very serious bugs, and the most important one is that I cannot get the portal engine to work. I can render all rooms at once, but that shows the rooms overlapping. Any scheme I have devised to make the portals work as they should fails, either showing too much or too little (and some do both, at the same time). Is anyone here who has solved this problem, and could give me some advise?

Michiel
08-05-07, 22:04
For overlapping rooms, you need to check the portals. Tomb Raider maps are rendered using portal views between rooms. You have a current room (the one the camera should be in) and then you should check the portals array to see which rooms link to this one. A portal is a rectangle, you should check if the rectangle is visible from the current position from front. If the full rectangle is either visible from behind or not visible at all, skip this portal.

When a portal is visible, you should render that room as well. This is a recursive method, because in this room you should check portals again. Make sure you don't render the same room twice because different portals might point to the same room.

So the basics are: render room and then check portal for visibility, when visible check if it's viewed at the front, and then check if the room hasn't already been rendered. When these conditions are true, start again at the basics for this room as well until.

Cochrane
09-05-07, 20:09
I know that, my problem is that I cannot get an algorithm that will reliably do just that.

Is there any special trick to determining whether I can see a portal from the front or not? It appears to me that I cannot trust the normal vectors that are in the file. Edit: I just realised that I read the components for the normal vectors as unsigned, wich is clearly The Wrong Thing™ to do. Still, I haven't found a solution yet. Is it necessary to adjust the viewing volume for every portal I go through, or should just checking whether the portal is in the normal viewing volume and facing me be enough?

Edit 2: It actually works now! The problem actually was that I read the normals as unsigned. I had made a small change somewhere else a few minutes ago, though, and that was preventing immediate success (the original version was correct). Thanks for your help!