How to programmatically raise 3D floor slope in UDMF by 320?

Ask about mapping, UDMF, using DoomBuilder/editor of choice, etc, here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

How to programmatically raise 3D floor slope in UDMF by 320?

Postby zdusr » Thu May 27, 2021 9:37 am

Hi!

So far I have learned that zdoom uses plane equations to define slopes.

I have this sector in my map:
Code: Select allExpand view
sector // 6
{
heightfloor = 0;
heightceiling = 0;
texturefloor = "ASHWALL2";
textureceiling = "ASHWALL2";
lightlevel = 192;
floorplane_a = 0.0;
floorplane_b = 0.316227766016838;
floorplane_c = 0.948683298050514;
floorplane_d = -399.711896245283;
ceilingplane_a = 0.0;
ceilingplane_b = -0.3162278;
ceilingplane_c = -0.9486833;
ceilingplane_d = 414.890829;
xpanningceiling = 0.0;
ypanningceiling = 0.0;
rotationceiling = 0.0;
xscaleceiling = 1.0;
yscaleceiling = 1.0;
xpanningfloor = 0.0;
ypanningfloor = 0.0;
rotationfloor = 0.0;
xscalefloor = 1.0;
yscalefloor = 1.0;
comment = "@test";
}


As I understand d is distance in plane equation. But when I change d by 320 and leave everything else unchanged, the floor does not raise by 320 as I expected but by 337 instead.

Here is a diff:
diff.PNG


From which it can be seen that both distances are exactly changed by 320. But in game the height difference at same x,y location is 337, not 320. How do I exactly have to calculate these numbers if I want the exact same tilt on each axis but different height?

I am asking it because I am interested in writing my own custom function that takes sector data in and returns sector that that has the same slope but is either higher or lower by specified amount and I thought that maybe someone who has dealt with it in zdoom or UDB source code might know some hints for that.
You do not have the required permissions to view the files attached to this post.
zdusr
 
Joined: 19 Mar 2021

Re: How to programmatically raise 3D floor slope in UDMF by

Postby boris » Thu May 27, 2021 2:59 pm

You have to multiply the amount you want to raise/lower the slope with the z component of the directional vector to get the correct value to change the distance by. Which in the case of the plane equation is the c component, i.e. floorplane_c or ceilingplane_c.

So in your example: 320 * 0.948683298050514 = 303.57865537616448

The other way around, if you use that formula on the 337 result you got: 337 * 0.948683298050514 = 319.706271443023218
boris
I post less than Manc and Hobo
 
Joined: 15 Jul 2003

Re: How to programmatically raise 3D floor slope in UDMF by

Postby zdusr » Fri May 28, 2021 5:49 am

Thanks. Got it perfectly aligned now.

How do I need to I need to change those calculate those values if I want to move that 3D floor 1000 map units along x axis and 2000 map units along y axis but keep the same slope angle and height? I tried to look up some plane equation videos from youtube myself but they seem to explain planes by point and normal vector. I understand, that a, b and c represent point and d represents scalar, but I still don't understand how it works well enough to compute new plane for other scenarios. Even that d=c*320 was something that I didn't fully understand.
zdusr
 
Joined: 19 Mar 2021

Re: How to programmatically raise 3D floor slope in UDMF by

Postby boris » Fri May 28, 2021 7:56 am

To do that you "only" need to change the offset to the slope (i.e. the d component). You set it to the negative dot product of the directional vector and a vector comprising of the offset you're moving and the z position of a reference point on the plane.

You can check it out how it's done in UDB here: https://github.com/jewalky/UltimateDoom ... #L524-L538

What you can also always do is create a plane from the plane equation, select 3 random points on the plane, move them, and create a new plane (and thus plane equation) from those 3 points.
boris
I post less than Manc and Hobo
 
Joined: 15 Jul 2003

Re: How to programmatically raise 3D floor slope in UDMF by

Postby zdusr » Wed Jun 02, 2021 2:14 pm

What's exactly directional vector in this context? Adn what's the reference point on the plane in this case? I have watched some math videos on that topic on YT but I have difficulties linking it in my head to this topic here. What keywords would you suggest me to look up to be able to come up with these idea myself? I wasnt even able to come up with previous z offset thing on my own.

Also in UDB code, what is exactly this line for?
Code: Select allExpand view
Vector2D center = new Vector2D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2);


Do I need this?
zdusr
 
Joined: 19 Mar 2021

Re: How to programmatically raise 3D floor slope in UDMF by

Postby zdusr » Fri Jun 04, 2021 5:50 am

One more question: I tried plane equation now.

I have this sector:
Code: Select allExpand view
sector // 7
{
heightfloor = -1016;
heightceiling = 1024;
texturefloor = "FLOOR0_1";
textureceiling = "CEIL1_1";
lightlevel = 255;
floorplane_a = 12.0;
floorplane_b = 21.0;
floorplane_c = 13.0;
floorplane_d = -97.0;
comment = "slope_test";
}


On geogebra (https://www.geogebra.org/3d?lang=en) this plane equation looks like this:



On UDB it looks like this:


What do I need to do to make it look the same on UDB? this sector gos just like this geogebra example from -10 to +10 on x and y axis and according to geogebra this plane should barely start raising out of the floor but in UDB it is way out of floor.

Update: what's exactly up parameter in Plane constructor? true for floor and false for ceiling?
Code: Select allExpand view
public Plane(Vector3D p1, Vector3D p2, Vector3D p3, bool up)
zdusr
 
Joined: 19 Mar 2021


Return to Mapping

Who is online

Users browsing this forum: No registered users and 0 guests