Skip to content

Commit

Permalink
Tweaked the car physics values.
Browse files Browse the repository at this point in the history
Display the mass in the debug GUI.
  • Loading branch information
astrofra committed Nov 27, 2022
1 parent fba6971 commit fc88767
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/car.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def CarModelCreate(name, instance_node_name, scene, scene_physics, resources, st

o['mass'] = NodeGetPhysicsMass(o['chassis_node'])
o['center_of_mass'] = NodeGetPhysicsCenterOfMass(o['chassis_node'])
o['spring_friction'] = 2500
o['spring_friction'] = 2500 * 2.5
o['tires_reaction'] = 25
o['tires_grip'] = 5000
o['steering_angle_max'] = 45
o['tires_grip'] = 10000
o['steering_angle_max'] = 25
o['thrust_power'] = 400000 # Acceleration
o['brakes_power'] = 1000000
o['steering_speed'] = 50
Expand Down
3 changes: 2 additions & 1 deletion app/gui.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import harfang as hg
from utils import MetersPerSecondToKMH

def DrawGui(res_x, res_y, dt, dts, car_vel, vid, debug_physic, car_pos, debug_car, control_keyboard):
def DrawGui(res_x, res_y, dt, dts, car_vel, vid, debug_physic, car_pos, car_mass, debug_car, control_keyboard):
hg.ImGuiBeginFrame(res_x, res_y, dt, hg.ReadMouse(), hg.ReadKeyboard())
hg.ImGuiBegin("Debug", True, hg.ImGuiWindowFlags_NoMove | hg.ImGuiWindowFlags_NoResize)
hg.ImGuiSetWindowSize("Debug", hg.Vec2(350, 180), hg.ImGuiCond_Once)
hg.ImGuiText("dt = " + str(round(dts, 4)))
hg.ImGuiText("car_mass = " + str(car_mass) + "Kg")
hg.ImGuiText("speed = " + str(round(MetersPerSecondToKMH(hg.Len(car_vel)))) + " km/h")
hg.ImGuiText("car position = Vec3(" + str(round(car_pos.x, 4)) + ", " + str(round(car_pos.y, 4)) + ", " + str(round(car_pos.z, 4)) + ")")
was_clicked, debug_physic = hg.ImGuiCheckbox('Physic Debug', debug_physic)
Expand Down
2 changes: 1 addition & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def CreateMaterial(ubc, orm):

if render_mode == "normal":
vid += 1
physics_debug, car_debug, control_keyboard = DrawGui(res_x, res_y, dt, dts, car_vel, vid, physics_debug, car_pos, car_debug, control_keyboard)
physics_debug, car_debug, control_keyboard = DrawGui(res_x, res_y, dt, dts, car_vel, vid, physics_debug, car_pos, car['mass'], car_debug, control_keyboard)

hg.Frame()
hg.UpdateWindow(win)
Expand Down

0 comments on commit fc88767

Please sign in to comment.