RANDY: Mathematics for slopes

Discuss anything ZDoom-related that doesn't fall into one of the other categories.
User avatar
CodeImp
Posts: 456
Joined: Sun Dec 28, 2003 7:40 pm
Location: Netherlands
Contact:

RANDY: Mathematics for slopes

Post by CodeImp »

I'd like to give slopes in my editor's 3D Mode another try, but I will only add it when done properly. I sloped some sectors and looked at their behaviour, but I dont understand behaviour of sloped, weird shaped sectors. Yet, I want mine to look exactly as they would in ZDoom. Could you give me the mathematics to calculate the Z height for any vertex of the sloped sector? Like a formula or logics that I can apply to each of the sloped sector's vertex and it will look exactly like what ZDoom would do?

So far, this is what I figured:
Find a vertex of the sloped sector which is farthest away from the slope line (imaginary unlimited line). At this vertex's coordinates the sector will have its original Z height and at the two vertices on the slope line the sector will have the height of the sector at the other side of the line.

..but now for the math that must be applied to each sector vertex ;)

Thanks!
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49223
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Post by Graf Zahl »

You find all the math in the source file p_setup.cpp in the functions

P_AlignPlane
P_SetSlopes (for linedef based slopes)


P_SlopeLineToPoint
P_CopyPlane
P_SetSlope
P_SpawnSlopeMakers (for thing based slopes)

Also important is the secplane_t class (in r_defs.h). It contains all the plane data calculated by the functions mentioned above and it also contains the fuction ZatPoint which is used to calculate the height at vertices and other points.
User avatar
CodeImp
Posts: 456
Joined: Sun Dec 28, 2003 7:40 pm
Location: Netherlands
Contact:

Post by CodeImp »

Ugh, thats more complicated than I expected. Anyway, I hope noone uses Things for slopes these days, because I dont think I will be supporting those, just line slopes (action 181).
User avatar
Risen
Posts: 5263
Joined: Thu Jan 08, 2004 1:02 pm
Location: N44°30' W073°05'

Post by Risen »

The slope line is by far the easiest, but for complex sloped areas it's impossible to get certain effects without using the slope things.

Still, having one kind of preview is better than none at all.
User avatar
CodeImp
Posts: 456
Joined: Sun Dec 28, 2003 7:40 pm
Location: Netherlands
Contact:

Post by CodeImp »

I tried to use one of those slopeThings, but havent got any good results, how do they work?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49223
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Post by Graf Zahl »

CodeImp wrote:Ugh, thats more complicated than I expected.

All it does is to create a plane equation from 3 points. It looks more complicated than it is due to the data it has to get its information from.

Anyway, I hope noone uses Things for slopes these days, because I dont think I will be supporting those, just line slopes (action 181).

Don't count on that. The copy plane things are used quite frequently (but they are the simplest ones and the other types have been used by a few WADs. 2 I can name are the Dark7 Mission Pack and Dissolution
User avatar
Risen
Posts: 5263
Joined: Thu Jan 08, 2004 1:02 pm
Location: N44°30' W073°05'

Post by Risen »

The 'slope to here' things define a point in space (via its position and Z-height value). then, you use line identifiers to determine which sectors and lines to slope from. This is useful for tricky spaces where there is no good sector to slope to, but even more so for complex slopes: think rounded pipe moving across an already sloped surface. I used them quite heavily in the KDIZD intermap. I'd be happy to provide it for you as an example.
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Post by randi »

So, have all your questions been answered, or do you need more help? Once created, the slopes are nothing more than standard plane equations in normal, distance form.
User avatar
CodeImp
Posts: 456
Joined: Sun Dec 28, 2003 7:40 pm
Location: Netherlands
Contact:

Post by CodeImp »

Risen: Yes please, Id like to use your map for testing this.

Randy: For now my questions have been answerred yes :) I havent started on the coding yet, I have only looked at the zdoom source.

Thanks, I hope this is gonna work.
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Post by HotWax »

CodeImp, I think I speak for just about every member of this community when I say... You freaking rock.
User avatar
Risen
Posts: 5263
Joined: Thu Jan 08, 2004 1:02 pm
Location: N44°30' W073°05'

Post by Risen »

I stripped out all of that map that would be useless to you. It was built with the Knee-Deep in ZDoom resource in mind, so you'll probably be missing lots of textures.

Demonstrates:
- Slope lines (181)
- Copy Slope
- Slope Floor to Here
- Compound slopes (181 lines + slope floor to here)

I find the 'set slope' things to be too imprecise for most detail work; none are included here. However, I have used them in my (as yet unreleased) maps for organic areas where precision is not necessary.
Attachments
slopes.zip
(86.27 KiB) Downloaded 39 times
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Post by wildweasel »

CodeImp wrote:I hope noone uses Things for slopes these days
I've been using Slope Things since the beginning...I don't know any other way to do it...I guess I should start learning, huh?
User avatar
Tormentor667
Posts: 13554
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Post by Tormentor667 »

Good to hear, that slopes are THE MUST HAVE feature of the latest DB release :)
User avatar
Your Name Is
Posts: 802
Joined: Sun Oct 31, 2004 5:06 pm
Location: Raleigh, NC
Contact:

Post by Your Name Is »

When will slopes be finished?
NiGHTMARE
Posts: 3463
Joined: Sat Jul 19, 2003 8:39 am

Post by NiGHTMARE »

When They're Done (TM)
Post Reply

Return to “General”