Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement aiVehicleOpponent::DrawTargetPt #151

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/midtown/mmai/aiGoalFollowWayPts.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class aiGoalFollowWayPts final : public aiGoal
// ?SolveTargetPoint@aiGoalFollowWayPts@@AAEXXZ
ARTS_IMPORT void SolveTargetPoint();

public:
aiVehicleOpponent* Vehicle;
aiRailSet* Rail;
mmCar* Car;
Expand Down
51 changes: 50 additions & 1 deletion code/midtown/mmai/aiVehicleOpponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ define_dummy_symbol(mmai_aiVehicleOpponent);
#include "agi/dlptmpl.h"
#include "agi/getdlp.h"
#include "agiworld/quality.h"
#include "dyna7/gfx.h"
#include "mmdyna/poly.h"
#include "mmphysics/phys.h"

#include "aiData.h"
#include "aiGoalBackup.h"
Expand All @@ -32,6 +35,52 @@ define_dummy_symbol(mmai_aiVehicleOpponent);
void aiVehicleOpponent::DrawDamage()
{}

void aiVehicleOpponent::DrawTargetPt()
{
DrawColor(ColPurple);

Vector3 base_pos = Car.Sim.ICS.Matrix.m3;

Vector3 car_pos = base_pos;
car_pos.y += 1.0f;

Vector3 target_pt = WayPts->TargetPt;
target_pt.y += 1.0f;

mmIntersection isect;
isect.InitSegment(car_pos, target_pt, nullptr, 2, 0);

PHYS.Collide(&isect, PHYS_COLLIDE_ROOM);

if (isect.HitPoly)
{
target_pt.y = (-isect.HitPoly->PlaneD - isect.HitPoly->PlaneN.z * target_pt.z - isect.HitPoly->PlaneN.x * target_pt.x) / isect.HitPoly->PlaneN.y - -0.5f;
}

DrawLine(car_pos, target_pt);

Vector3 speed_label = base_pos;
speed_label.y += 0.5f;

Vector3 steering_label = base_pos;
steering_label.y += 0.25f;

Vector3 throttle_label = base_pos;
throttle_label.y += 0.0f;

Vector3 brake_label = base_pos;
brake_label.y -= 0.25f;

DrawLabelf(speed_label, xconst("MPH: %.2f"), Car.Sim.SpeedMPH);
DrawLabelf(steering_label, xconst("Steering: %.2f"), Car.Sim.Steering);
DrawLabelf(throttle_label, xconst("Throttle: %.2f"), Car.Sim.Engine.Throttle);
DrawLabelf(brake_label, xconst("Brakes: %.2f"), Car.Sim.Brakes);

DrawColor(ColLightCyan);

RailSet.DrawTurn(WayPts->DistToSide);
}

void aiVehicleOpponent::Init(i32 opp_id, aiRaceData* race_data, char* race_name)
{
i32 tex_quality = agiRQ.TextureQuality;
Expand Down Expand Up @@ -72,4 +121,4 @@ void aiVehicleOpponent::Init(i32 opp_id, aiRaceData* race_data, char* race_name)
RailSet.RSideDist = max.x;
}
AudIndexNumber = -1;
}
}
2 changes: 1 addition & 1 deletion code/midtown/mmai/aiVehicleOpponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class aiVehicleOpponent final : public aiVehicle
ARTS_IMPORT void DrawId() override;

// ?DrawTargetPt@aiVehicleOpponent@@QAEXXZ
ARTS_IMPORT void DrawTargetPt();
ARTS_EXPORT void DrawTargetPt();

// ?Dump@aiVehicleOpponent@@QAEXXZ
ARTS_IMPORT void Dump();
Expand Down