 |
 |
GoldenEye 007 Nintendo 64 Community, GoldenEye X, Nintendo 64 Games Discussion GoldenEye Cheats, GoldenEye X Codes, Tips, Help, Nintendo 64 Gaming Community
|
 |
 |
 |
 |
|
 |
 |
 |
 |
 |
tolos Agent

Joined: 17 Jan 2021 Posts: 6
 |
Posted: Tue Jul 20, 2021 7:21 pm Post subject: How do you calculate how long it takes to open/close a door? |
 |
|
Assume I load up Depot. I find a door, Preset 272A, #0002.
I'm looking at an Object Type of "01 Door" in the Object Editor. Object # 2.
On the right, I see what appear to be six relevant text boxes:
Distance Travels
0xE666
Walkthru Distance
0xCCCC
Acceleration
0xA
Rate
0xA
Max Speed
0x1EB
Time Open (ms)
0x384
The IRL time to open the depot roller door is ~3.0 seconds (NTSC on N64 hardware). How do I calculate 3 seconds from those numbers above? |
|
|
|
|
|
 |
 |
 |
 |
 |
Lazlo52 Secret Agent


Joined: 18 Nov 2017 Posts: 336 Location: N.J.  |
Posted: Thu Jul 22, 2021 12:45 pm Post subject: |
 |
|
l'm not too keen on the specifics of doors because l've always copy-pasted from other doors, but here's what l understand...
Distance Travels is how much the door will travel, where zero is closed and the provided value is fully open. Walkthru Distance is the point at which you can walk through the door (this is how vertical doors work).
Acceleration affects how long it takes for the door to reach full speed. I don't know what Rate does or how Acceleration is scaled, so check some existing doors for examples. It might actually be acceleration, then deceleration.
Max Speed is how fast the door will ultimately move, of course.
Time Open is how long the door will stay open until it automatically closes. It says (ms), but this is false, it's 60 cycles (frames) per second. 0x384 is 900, which is perfectly aligned with 15 seconds, and the Depot doors indeed stay open for 15 seconds.
So, for the purpose of determining how 3 seconds lines up with the door opening, I'd say it's a combination of Distance Travels, Acceleration, Rate, and Max Speed. _________________
Quote: | 22 not happening nerds. forget about it. 23 til the day i die. |
|
|
|
|
|
|
 |
 |
 |
 |
 |
Trevor 007


Joined: 15 Jan 2010 Posts: 926 Location: UK, Friockheim OS:Win11-Dev PerfectGold:Latest  |
Posted: Fri Jul 23, 2021 3:16 am Post subject: |
 |
|
Quote: | Time Open is how long the door will stay open until it automatically closes. It says (ms), but this is false, it's 60 cycles (frames) per second. 0x384 is 900, which is perfectly aligned with 15 seconds, and the Depot doors indeed stay open for 15 seconds. |
This actually perfectly explains the time difference you are seeing since PAL is 50, so 900/50 = 18 secs
Trev _________________
   |
|
|
|
|
|
 |
 |
 |
 |
 |
tolos Agent

Joined: 17 Jan 2021 Posts: 6
 |
Posted: Sat Jul 24, 2021 3:17 pm Post subject: |
 |
|
Alright, here's a summary of my findings. Thanks to trevor, ryan, carnviorous, whiteted along the way.
The original question I posted about was, given a set of configuration parameters, how do you tell how long it will take for a door to go from closed to open?
Basically the answer is to do the same thing the game does, and simulate the door opening by stepping it along one frame at a time. Once you know the number of frames you can convert from framerate to realtime.
This was part of a larger question which I wrote a C# program for, to collect some door information for every level in the game, across NTSC and PAL. If you care, the project is on github, https://github.com/burnsba/GoldeneyeDoorCalc .
The ApplySpeed function below simulates what happens in the game. The CalcOpen method resets the door state then calls ApplySpeed until the door is considered open, or too many iterations pass (some of the automatically collected "door" objects this program was written for were not actually doors). Once that's done, the door's OpenFrames property will contain the number of frames it took to open.
Relevant code from the door class:
Code: |
public double DistanceDone { get; set; } = 0.0;
public double MaxDistance { get; set; } = 0.0;
public double Speed { get; set; } = 0.0;
public double Acceleration { get; set; } = 0.0;
public double Deceleration { get; set; } = 0.0;
public double MaxSpeed { get; set; } = 0.0;
public int OpenFrames { get; set; } = 0;
public bool OpenDone { get; set; } = false;
public int ToMaxSpeedFrames { get; set; } = 0;
public bool ToMaxSpeedDone { get; set; } = false;
public int StartDecelFrame = 0;
// ...
public void ApplySpeed()
{
var localSpeed = Speed;
var limit = localSpeed * localSpeed * 0.5 / Deceleration;
var distRemaining = MaxDistance - DistanceDone;
if (distRemaining > 0.0)
{
if (localSpeed > 0.0 && distRemaining <= limit)
{
if (StartDecelFrame == 0)
{
StartDecelFrame = OpenFrames;
}
// Slow down for end
localSpeed -= Deceleration;
if (localSpeed < Deceleration)
{
localSpeed = Deceleration;
}
}
else if (localSpeed < MaxSpeed)
{
// Accelerate
if (localSpeed < 0.0)
{
localSpeed += Deceleration;
}
else
{
localSpeed += Acceleration;
}
if (localSpeed >= MaxSpeed)
{
localSpeed = MaxSpeed;
ToMaxSpeedDone = true;
}
if (!ToMaxSpeedDone)
{
ToMaxSpeedFrames++;
}
}
if (localSpeed >= distRemaining)
{
DistanceDone = MaxDistance;
OpenDone = true;
}
DistanceDone += localSpeed;
if (!OpenDone)
{
OpenFrames++;
}
}
else
{
if (localSpeed < 0.0 && -distRemaining <= limit)
{
localSpeed += Deceleration;
if (localSpeed > -Deceleration)
{
localSpeed = -Deceleration;
}
}
else if (localSpeed > -MaxSpeed)
{
if (localSpeed > 0.0)
{
localSpeed -= Deceleration;
}
else
{
localSpeed -= Acceleration;
}
if (localSpeed < -MaxSpeed)
{
localSpeed = -MaxSpeed;
}
}
if (localSpeed <= distRemaining)
{
DistanceDone = MaxDistance;
//break;
}
DistanceDone += localSpeed;
}
Speed = localSpeed;
}
public void CalcOpen()
{
Speed = 0;
DistanceDone = 0;
OpenFrames = 0;
ToMaxSpeedFrames = 0;
OpenDone = false;
ToMaxSpeedDone = false;
PositionCalcValid = null;
for (var i = 0; i < MaxOpenCalcIterations; i++)
{
ApplySpeed();
if (OpenDone && ToMaxSpeedDone)
{
PositionCalcValid = true;
break;
}
}
if (PositionCalcValid != true)
{
PositionCalcValid = false;
}
}
|
|
|
|
|
|
|
 |
 |
 |
 |
 |
|
 |
 |
 |
 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
 |