diff --git a/.gitignore b/.gitignore index 18ca1b1..30cc2e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/app/assets \ No newline at end of file +/app/assets +/app/__pycache__ \ No newline at end of file diff --git a/README.md b/README.md index 35a8788..07a9983 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,23 @@ -# car-simulator - Car simulator - VR & 3D - Raycast Car | Made with Harfang 3D +## Car Simulator - VR & 3D - Raycast Car | Made with Harfang 3D + +* Implemented in Python +* VR Support (using [Harfang 3D OpenVR Support](https://partner.steamgames.com/doc/features/steamvr/openvr?l=french)) +* Raycast Car (using [Bullet Physics](https://github.com/bulletphysics/bullet3)) +* Built on [Harfang 3D](https://github.com/harfang3d/harfang3d) +* **W.I.P** + +### Screenshots of the actual version + +![](img/car_interior.png)
+![](img/physics_debug.png)
+![](img/car_debug.png)
+ +### First version of the Raycast Car + +![](img/raycast_car_001.gif) + +### Generic Car Model + +![](img/generic_car_20221002110516.png)
+![](img/generic_car_20221002110523.png)
+![](img/generic_car_20221002110544.png)
\ No newline at end of file diff --git a/app/__pycache__/car.cpython-310.pyc b/app/__pycache__/car.cpython-310.pyc index 39a0483..78e2a2c 100644 Binary files a/app/__pycache__/car.cpython-310.pyc and b/app/__pycache__/car.cpython-310.pyc differ diff --git a/app/__pycache__/car_camera.cpython-310.pyc b/app/__pycache__/car_camera.cpython-310.pyc index 4d50fff..cb92238 100644 Binary files a/app/__pycache__/car_camera.cpython-310.pyc and b/app/__pycache__/car_camera.cpython-310.pyc differ diff --git a/app/__pycache__/car_lights.cpython-310.pyc b/app/__pycache__/car_lights.cpython-310.pyc index 4e6cc43..93ff0ce 100644 Binary files a/app/__pycache__/car_lights.cpython-310.pyc and b/app/__pycache__/car_lights.cpython-310.pyc differ diff --git a/app/__pycache__/gui.cpython-310.pyc b/app/__pycache__/gui.cpython-310.pyc index 7d17913..eddf114 100644 Binary files a/app/__pycache__/gui.cpython-310.pyc and b/app/__pycache__/gui.cpython-310.pyc differ diff --git a/app/__pycache__/utils.cpython-310.pyc b/app/__pycache__/utils.cpython-310.pyc index 0bcda89..e53d9f3 100644 Binary files a/app/__pycache__/utils.cpython-310.pyc and b/app/__pycache__/utils.cpython-310.pyc differ diff --git a/app/bin/glfw3.dll b/app/bin/glfw3.dll index 313dfdb..06c7077 100644 Binary files a/app/bin/glfw3.dll and b/app/bin/glfw3.dll differ diff --git a/app/bin/harfang.dll b/app/bin/harfang.dll index 3ac44ca..7f58053 100644 Binary files a/app/bin/harfang.dll and b/app/bin/harfang.dll differ diff --git a/app/bin/harfang/assetc/assetc.exe b/app/bin/harfang/assetc/assetc.exe index d4325d1..dea82f6 100644 Binary files a/app/bin/harfang/assetc/assetc.exe and b/app/bin/harfang/assetc/assetc.exe differ diff --git a/app/bin/harfang/assetc/glfw3.dll b/app/bin/harfang/assetc/glfw3.dll index 3850ea3..06c7077 100644 Binary files a/app/bin/harfang/assetc/glfw3.dll and b/app/bin/harfang/assetc/glfw3.dll differ diff --git a/app/bin/harfang/assetc/lua54.dll b/app/bin/harfang/assetc/lua54.dll index 567aeb9..34de2a6 100644 Binary files a/app/bin/harfang/assetc/lua54.dll and b/app/bin/harfang/assetc/lua54.dll differ diff --git a/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/bulletc.exe b/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/bulletc.exe index 2c0b08b..23331cd 100644 Binary files a/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/bulletc.exe and b/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/bulletc.exe differ diff --git a/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/cmft.exe b/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/cmft.exe index af1ffd4..e51d088 100644 Binary files a/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/cmft.exe and b/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/cmft.exe differ diff --git a/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/luac.exe b/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/luac.exe index 47a2b6e..13c5bdf 100644 Binary files a/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/luac.exe and b/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/luac.exe differ diff --git a/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/recastc.exe b/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/recastc.exe index 5b7ce27..59e696c 100644 Binary files a/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/recastc.exe and b/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/recastc.exe differ diff --git a/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/shaderc.exe b/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/shaderc.exe index 5598a6a..2f4b787 100644 Binary files a/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/shaderc.exe and b/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/shaderc.exe differ diff --git a/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/texturec.exe b/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/texturec.exe index 338ad3a..1bcef32 100644 Binary files a/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/texturec.exe and b/app/bin/harfang/assetc/toolchains/host-windows-x64-target-windows-x64/texturec.exe differ diff --git a/app/bin/harfang/assimp_converter/assimp_converter.exe b/app/bin/harfang/assimp_converter/assimp_converter.exe new file mode 100644 index 0000000..75927ca Binary files /dev/null and b/app/bin/harfang/assimp_converter/assimp_converter.exe differ diff --git a/app/bin/harfang/assimp_converter/glfw3.dll b/app/bin/harfang/assimp_converter/glfw3.dll new file mode 100644 index 0000000..06c7077 Binary files /dev/null and b/app/bin/harfang/assimp_converter/glfw3.dll differ diff --git a/app/bin/harfang/assimp_converter/lua54.dll b/app/bin/harfang/assimp_converter/lua54.dll new file mode 100644 index 0000000..34de2a6 Binary files /dev/null and b/app/bin/harfang/assimp_converter/lua54.dll differ diff --git a/app/bin/harfang/assimp_converter/openvr_api.dll b/app/bin/harfang/assimp_converter/openvr_api.dll new file mode 100644 index 0000000..a4ad764 Binary files /dev/null and b/app/bin/harfang/assimp_converter/openvr_api.dll differ diff --git a/app/bin/harfang/fbx_converter/fbx_converter.exe b/app/bin/harfang/fbx_converter/fbx_converter.exe new file mode 100644 index 0000000..1920355 Binary files /dev/null and b/app/bin/harfang/fbx_converter/fbx_converter.exe differ diff --git a/app/bin/harfang/fbx_converter/glfw3.dll b/app/bin/harfang/fbx_converter/glfw3.dll new file mode 100644 index 0000000..06c7077 Binary files /dev/null and b/app/bin/harfang/fbx_converter/glfw3.dll differ diff --git a/app/bin/harfang/fbx_converter/libfbxsdk.dll b/app/bin/harfang/fbx_converter/libfbxsdk.dll new file mode 100644 index 0000000..27484c5 Binary files /dev/null and b/app/bin/harfang/fbx_converter/libfbxsdk.dll differ diff --git a/app/bin/harfang/fbx_converter/lua54.dll b/app/bin/harfang/fbx_converter/lua54.dll new file mode 100644 index 0000000..34de2a6 Binary files /dev/null and b/app/bin/harfang/fbx_converter/lua54.dll differ diff --git a/app/bin/harfang/fbx_converter/openvr_api.dll b/app/bin/harfang/fbx_converter/openvr_api.dll new file mode 100644 index 0000000..a4ad764 Binary files /dev/null and b/app/bin/harfang/fbx_converter/openvr_api.dll differ diff --git a/app/bin/harfang/fbx_converter/tests.exe b/app/bin/harfang/fbx_converter/tests.exe new file mode 100644 index 0000000..6e05eac Binary files /dev/null and b/app/bin/harfang/fbx_converter/tests.exe differ diff --git a/app/bin/harfang/gltf_exporter/glfw3.dll b/app/bin/harfang/gltf_exporter/glfw3.dll new file mode 100644 index 0000000..06c7077 Binary files /dev/null and b/app/bin/harfang/gltf_exporter/glfw3.dll differ diff --git a/app/bin/harfang/gltf_exporter/gltf_exporter.exe b/app/bin/harfang/gltf_exporter/gltf_exporter.exe new file mode 100644 index 0000000..e3e9be0 Binary files /dev/null and b/app/bin/harfang/gltf_exporter/gltf_exporter.exe differ diff --git a/app/bin/harfang/gltf_exporter/lua54.dll b/app/bin/harfang/gltf_exporter/lua54.dll new file mode 100644 index 0000000..34de2a6 Binary files /dev/null and b/app/bin/harfang/gltf_exporter/lua54.dll differ diff --git a/app/bin/harfang/gltf_exporter/openvr_api.dll b/app/bin/harfang/gltf_exporter/openvr_api.dll new file mode 100644 index 0000000..a4ad764 Binary files /dev/null and b/app/bin/harfang/gltf_exporter/openvr_api.dll differ diff --git a/app/bin/harfang/gltf_importer/glfw3.dll b/app/bin/harfang/gltf_importer/glfw3.dll new file mode 100644 index 0000000..06c7077 Binary files /dev/null and b/app/bin/harfang/gltf_importer/glfw3.dll differ diff --git a/app/bin/harfang/gltf_importer/gltf_importer.exe b/app/bin/harfang/gltf_importer/gltf_importer.exe new file mode 100644 index 0000000..4eef2f1 Binary files /dev/null and b/app/bin/harfang/gltf_importer/gltf_importer.exe differ diff --git a/app/bin/harfang/gltf_importer/lua54.dll b/app/bin/harfang/gltf_importer/lua54.dll new file mode 100644 index 0000000..34de2a6 Binary files /dev/null and b/app/bin/harfang/gltf_importer/lua54.dll differ diff --git a/app/bin/harfang/gltf_importer/openvr_api.dll b/app/bin/harfang/gltf_importer/openvr_api.dll new file mode 100644 index 0000000..a4ad764 Binary files /dev/null and b/app/bin/harfang/gltf_importer/openvr_api.dll differ diff --git a/app/bin/lua.exe b/app/bin/lua.exe index 7d6cc03..8319292 100644 Binary files a/app/bin/lua.exe and b/app/bin/lua.exe differ diff --git a/app/bin/lua54.dll b/app/bin/lua54.dll index fdea500..34de2a6 100644 Binary files a/app/bin/lua54.dll and b/app/bin/lua54.dll differ diff --git a/app/car.lua b/app/car.lua deleted file mode 100644 index 8f3f682..0000000 --- a/app/car.lua +++ /dev/null @@ -1,223 +0,0 @@ -hg = require("harfang") - -function CreateRCCar(name, instance_node_name, scene, scene_physics, resources, start_position, start_rotation) - local o = {} - o.start_position = start_position or hg.Vec3(0, 0, 0) - o.start_rotation = start_rotation or hg.Vec3(0, 0, 0) - o.name = name - - -- Instance_node is not affected by physics. - o.instance_node = scene:GetNode(instance_node_name) - if not o.instance_node:IsValid() then - print("ERROR - Instance node not found !") - return - end - o.instance_node:GetTransform():SetPos(hg.Vec3(0, 0, 0)) - o.scene_view = o.instance_node:GetInstanceSceneView() - o.nodes = o.scene_view:GetNodes(scene) - o.chassis_node = o.scene_view:GetNode(scene, "car_body") - if not o.chassis_node:IsValid() then - print("ERROR - Parent node not found !") - return - end - o.chassis_node:GetTransform():SetPos(o.start_position) - o.chassis_node:GetTransform():SetRot(o.start_rotation) - o.thrust = o.scene_view:GetNode(scene, "thrust") - if not o.thrust:IsValid() then - print("ERROR - Thrust node not found !") - return - end - o.wheels = {} - for n = 0, 3 do - wheel = o.scene_view:GetNode(scene, "wheel_" .. n) - if not wheel:IsValid() then - print("ERROR - Wheel_"..n.." node not found !") - return - end - table.insert(o.wheels, wheel) - end - - o.ray_dir = nil - obj = o.wheels[1]:GetObject() - f,bounds = obj:GetMinMax(resources) - o.wheels_ray = bounds.mx.y - o.ray_max_dist = o.wheels_ray + 0.2 - - o.wheels_rot_speed = {0, 0, 0, 0} - o.ground_hits = {false, false, false, false} - o.ground_impacts = {nil, nil, nil, nil} - - -- Constants - - o.mass = 1000 - o.spring_friction = 2500 - o.tires_reaction = 25 - o.tires_adhesion = 1500 - o.front_angle_max = 45 - o.thrust_power = 400000 -- Acceleration - o.brakes_power = 1000000 - o.turn_speed = 150 - - -- Variables - - o.front_angle = 0 - - -- Setup physics - - o.chassis_rigid = scene:CreateRigidBody() - o.chassis_rigid:SetType(hg.RBT_Dynamic) - o.chassis_node:SetRigidBody(o.chassis_rigid) - colbox = scene:CreateCollision() - colbox:SetType(hg.CT_Cube) - colbox:SetSize(hg.Vec3(1, 0.5, 3)) - colbox:SetMass(o.mass) - colbox:SetLocalTransform(hg.TransformationMat4(hg.Vec3(0, 0, 0), hg.Deg3(0, 0, 0))) - o.chassis_node:SetCollision(1,colbox) - o.chassis_rigid:SetAngularDamping(0) - o.chassis_rigid:SetLinearDamping(0) - scene_physics:NodeCreatePhysicsFromAssets(o.chassis_node) - - - -- Get wheels rays - - o.local_rays = {} - for _, wheel in pairs(o.wheels) do - table.insert(o.local_rays, wheel:GetTransform():GetPos()) - end - - return o -end - -function RCCarReset(rccar, scene_physics) - scene_physics:NodeResetWorld(rccar.chassis_node, hg.TransformationMat4(rccar.start_position, rccar.start_rotation)) -end - -function RCCarTurn(rccar, angle, steering_wheel) - rccar.front_angle = math.max(math.min(rccar.front_angle + angle, rccar.front_angle_max), -rccar.front_angle_max) - rccar.thrust:GetTransform():SetRot(hg.Deg3(0, rccar.front_angle, 0)) - steering_wheel_rot = steering_wheel:GetTransform():GetRot() - steering_wheel:GetTransform():SetRot(hg.Deg3(steering_wheel_rot.x, 180 - rccar.front_angle * 2, steering_wheel_rot.z)) -end - -function RCCarAccelerate(rccar, value, scene_physics) - f = 0 - for i = 1, 2 do - if rccar.ground_hits[i] then - f = f + 0.5 - end - end - pos = hg.GetT(rccar.thrust:GetTransform():GetWorld()) - dir = hg.GetZ(rccar.thrust:GetTransform():GetWorld()) - scene_physics:NodeAddImpulse(rccar.chassis_node, dir * f * value * (1/60), pos) -end - -function RCCarBrake(rccar, value, scene_physics) - f = 0 - for i = 1, 4 do - if rccar.ground_hits[i] then - f = f + 0.25 - end - end - v = scene_physics:NodeGetLinearVelocity(rccar.chassis_node) - value = value * math.min(hg.Len(v), 1) - pos = hg.GetT(rccar.thrust:GetTransform():GetWorld()) - scene_physics:NodeAddImpulse(rccar.chassis_node,hg.Normalize(v) * (1 / 60) * f * -value, pos) -end - -function RCCarUpdate(rccar, scene, scene_physics, dts) - scene_physics:NodeWake(rccar.chassis_node) - rccar.ray_dir = hg.Reverse(hg.GetY(rccar.chassis_node:GetTransform():GetWorld())) - - for i = 1, 4 do - RCCarUpdateWheel(rccar, scene, scene_physics, i, dts) - end -end - -function RCCarUpdateWheel(rccar, scene, scene_physics, id, dts) - - wheel = rccar.wheels[id] - mat = rccar.chassis_node:GetTransform():GetWorld() -- Ray position in World space - ray_pos = mat * rccar.local_rays[id] - - hit = scene_physics:RaycastFirstHit(scene,ray_pos, rccar.ray_dir * rccar.ray_max_dist + ray_pos) - rccar.ground_hits[id] = false - - if hit.t > 0 and hit.t < rccar.ray_max_dist then - rccar.ground_impacts[id] = hit - hit_distance = hg.Len(rccar.ground_impacts[id].P - ray_pos) - if hit_distance <= rccar.ray_max_dist then - rccar.ground_hits[id] = true - end - end - - if rccar.ground_hits[id] then - - v = hg.Reverse(scene_physics:NodeGetPointVelocity(rccar.chassis_node, ray_pos)) - - -- Spring bounce - - v_dot_ground_n = hg.Dot(rccar.ground_impacts[id].N, v) - if v_dot_ground_n > 0 then - v_bounce = rccar.ground_impacts[id].N * v_dot_ground_n - scene_physics:NodeAddImpulse(rccar.chassis_node,v_bounce * rccar.spring_friction * dts, ray_pos) - end - - -- Tire/Ground reaction - - wheel_reaction = math.sqrt(rccar.ray_max_dist - hit_distance) * rccar.tires_reaction - scene_physics:NodeAddForce(rccar.chassis_node, rccar.ground_impacts[id].N * wheel_reaction * rccar.mass / 4, ray_pos) - - -- Wheel lateral friction - - x_axis = hg.GetX(wheel:GetTransform():GetWorld()) - proj = hg.Dot(x_axis, v) - v_lat = x_axis * proj - scene_physics:NodeAddImpulse(rccar.chassis_node, v_lat * rccar.tires_adhesion * dts, ray_pos) - - -- Adjust wheel on the ground - - wheel_p = wheel:GetTransform():GetPos() - wheel_p.y = rccar.local_rays[id].y - hit_distance + rccar.wheels_ray - wheel:GetTransform():SetPos(wheel_p) - - -- Wheel rotation - - z_axis = hg.Normalize(hg.Cross(x_axis, rccar.ray_dir)) - vlin = hg.Dot(z_axis, v) -- Linear speed (along Z axis) - rccar.wheels_rot_speed[id] = (vlin / rccar.wheels_ray) - else - rccar.wheels_rot_speed[id] = rccar.wheels_rot_speed[id] * 0.95 -- Wheel slow-down - end - - rot = wheel:GetTransform():GetRot() - rot.x = rot.x + rccar.wheels_rot_speed[id] * dts - if id == 1 or id == 2 then - rot.y = hg.Deg(rccar.front_angle) - end - wheel:GetTransform():SetRot(rot) -end - -function RCCarGetParentNode(rccar) - return rccar.chassis_node -end - -function RCCarControl(rccar, scene_physics, kb, dts, steering_wheel) - if kb:Down(hg.K_Up) then - RCCarAccelerate(rccar, rccar.thrust_power * dts, scene_physics) - end - if kb:Down(hg.K_Down) then - RCCarAccelerate(rccar, -rccar.thrust_power * dts, scene_physics) - end - if kb:Down(hg.K_Space) then - RCCarBrake(rccar, rccar.brakes_power * dts, scene_physics) - end - if kb:Down(hg.K_Left) then - RCCarTurn(rccar, -rccar.turn_speed * dts, steering_wheel) - end - if kb:Down(hg.K_Right) then - RCCarTurn(rccar, rccar.turn_speed * dts, steering_wheel) - end - if kb:Pressed(hg.K_Backspace) then - RCCarReset(rccar, scene_physics) - end -end \ No newline at end of file diff --git a/app/main.lua b/app/main.lua deleted file mode 100644 index ebd77c6..0000000 --- a/app/main.lua +++ /dev/null @@ -1,115 +0,0 @@ --- HARFANG® 3D - www.harfang3d.com - Raycast Car demo sample - -hg = require("harfang") -rcar = require("car") - --- HARFANG3D inits - -hg.InputInit() -hg.WindowSystemInit() - -res_x, res_y = 1280, 720 -win = hg.RenderInit('Raycast car', res_x, res_y, hg.RF_VSync | hg.RF_MSAA4X) - -pipeline = hg.CreateForwardPipeline() -res = hg.PipelineResources() - -hg.AddAssetsFolder("assets") - --- Display physics debug lines - -vtx_lines = hg.VertexLayout() -vtx_lines:Begin() -vtx_lines:Add(hg.A_Position, 3, hg.AT_Float) -vtx_lines:Add(hg.A_Color0, 3, hg.AT_Float) -vtx_lines:End() -lines_program = hg.LoadProgramFromAssets("shaders/pos_rgb") - --- Load scene - -scene = hg.Scene() -hg.LoadSceneFromAssets("main.scn", scene, res, hg.GetForwardPipelineInfo()) --- cam = scene:GetNode("CameraInterior") -cam = scene:GetNode("Camera") -scene:SetCurrentCamera(cam) -steering_wheel = scene:GetNode("steering_wheel") - --- Ground - -vs_decl= hg.VertexLayoutPosFloatNormUInt8() -cube_mdl = hg.CreateCubeModel(vs_decl, 10, 10, 10) -cube_ref = res:AddModel('cube', cube_mdl) -ground_mdl = hg.CreateCubeModel(vs_decl, 100, 0.01, 100) -ground_ref = res:AddModel('ground', ground_mdl) -prg_ref = hg.LoadPipelineProgramRefFromAssets('core/shader/pbr.hps', res, hg.GetForwardPipelineInfo()) - -function create_material(ubc, orm) - mat = hg.Material() - hg.SetMaterialProgram(mat, prg_ref) - hg.SetMaterialValue(mat, "uBaseOpacityColor", ubc) - hg.SetMaterialValue(mat, "uOcclusionRoughnessMetalnessColor", orm) - return mat -end - -mat_ground = create_material(hg.Vec4(22/255, 42/255, 42/255, 1),hg.Vec4(1, 1, 0, 1)) - -cube_node = hg.CreatePhysicCube(scene, hg.Vec3(10,10,10), hg.TransformationMat4(hg.Vec3(0, -2.5, -10),hg.Deg3(30, 0, 10)), cube_ref, {mat_ground}, 0) -ground_node = hg.CreatePhysicCube(scene, hg.Vec3(100, 0.01, 100), hg.TranslationMat4(hg.Vec3(0, -0.005, 0)), ground_ref, {mat_ground}, 0) - -cube_node:GetRigidBody():SetType(hg.RBT_Kinematic) -ground_node:GetRigidBody():SetType(hg.RBT_Kinematic) - --- Scene physics - -clocks = hg.SceneClocks() -physics = hg.SceneBullet3Physics() -car = CreateRCCar("Kubolid", "car", scene, physics, res, hg.Vec3(0, 1.5, 0)) -physics:SceneCreatePhysicsFromAssets(scene) - --- Inputs - -keyboard = hg.Keyboard() -mouse = hg.Mouse() -hg.ResetClock() - --- Main loop - -while not keyboard:Pressed(hg.K_Escape) do - - keyboard:Update() - mouse:Update() - - dt = hg.TickClock() - dts = hg.time_to_sec_f(dt) - - -- Car updates - - RCCarControl(car, physics, keyboard, dts, steering_wheel) - RCCarUpdate(car, scene, physics, dts) - - -- Scene updates - - hg.SceneUpdateSystems(scene, clocks, dt, physics, hg.time_from_sec_f(1/60), 3) - vid, passId = hg.SubmitSceneToPipeline(0, scene, hg.IntRect(0, 0, res_x, res_y), true, pipeline, res) - - -- Debug physics - - hg.SetViewClear(vid, 0, 0, 1.0, 0) - hg.SetViewRect(vid, 0, 0, res_x, res_y) - cam_mat = cam:GetTransform():GetWorld() - view_matrix = hg.InverseFast(cam_mat) - c = cam:GetCamera() - projection_matrix = hg.ComputePerspectiveProjectionMatrix(c:GetZNear(), c:GetZFar(), hg.FovToZoomFactor(c:GetFov()), hg.Vec2(res_x / res_y, 1)) - hg.SetViewTransform(vid, view_matrix, projection_matrix) - rs = hg.ComputeRenderState(hg.BM_Opaque, hg.DT_Disabled, hg.FC_Disabled) - physics:RenderCollision(vid, vtx_lines, lines_program, rs, 0) - - -- EoF - - hg.Frame() - hg.UpdateWindow(win) - -end - -hg.RenderShutdown() -hg.DestroyWindow(win) diff --git a/app/main.py b/app/main.py index 6487319..8b9e4d7 100644 --- a/app/main.py +++ b/app/main.py @@ -15,9 +15,6 @@ hg.InputInit() hg.WindowSystemInit() - - - res_x, res_y = 1900, 1000 win = hg.RenderInit('Raycast car', res_x, res_y, hg.RF_VSync | hg.RF_MSAA4X) @@ -88,7 +85,7 @@ def create_material(ubc, orm): clocks = hg.SceneClocks() physics = hg.SceneBullet3Physics() -car = CreateRCCar("Generic Car", "car", scene, physics, res, hg.Vec3(-10, 1.5, 0), hg.Vec3(0, 0, 0)) +car = CreateRCCar("Generic Car", "car", scene, physics, res, hg.Vec3(-10, 1.5, 1000), hg.Vec3(0, 0, 0)) carlights = CarLightsCreate("car", scene) physics.SceneCreatePhysicsFromAssets(scene) @@ -195,7 +192,6 @@ def create_material(ubc, orm): for line in car_lines: draw_line(line[0], line[1], line[2], opaque_view_id, vtx_line_layout, lines_program) - # EoF if render_mode == "vr": main_camera_matrix = scene.GetCurrentCamera().GetTransform().GetWorld() diff --git a/app/resources/_meta/fbx_importer_cfg.txt b/app/resources/_meta/fbx_importer_cfg.txt index 4a8119e..c301123 100644 --- a/app/resources/_meta/fbx_importer_cfg.txt +++ b/app/resources/_meta/fbx_importer_cfg.txt @@ -4,7 +4,7 @@ "anim_simplify_scale_tolerance":"0.001000" "anim_simplify_translation_tolerance":"0.001000" "detect_geometry_instances":"1" -"fbx_file_path":"" +"fbx_file_path":"c:/Users/clem/Documents/octogone.fbx" "finalizer_script":"" "fix_geometry_orientation":"0" "frames_per_second":"24" @@ -13,7 +13,7 @@ "import_animations":"1" "material_policy":"1" "max_smoothing_angle":"45.000000" -"output_folder":"" +"output_folder":"octogone" "profile":"1" "recalculate_normals":"0" "recalculate_tangents":"0" diff --git a/app/resources/main.scn b/app/resources/main.scn index a76b707..74c181d 100644 --- a/app/resources/main.scn +++ b/app/resources/main.scn @@ -67,34 +67,7 @@ "name": "road_blocks/block_highway_straight/block_highway_straight.scn" }, { - "name": "road_blocks/block_highway_straight/block_highway_straight.scn" - }, - { - "name": "road_blocks/block_highway_straight/block_highway_straight.scn" - }, - { - "name": "road_blocks/block_highway_straight/block_highway_straight.scn" - }, - { - "name": "road_blocks/block_highway_straight/block_highway_straight.scn" - }, - { - "name": "road_blocks/block_highway_straight/block_highway_straight.scn" - }, - { - "name": "road_blocks/block_highway_straight/block_highway_straight.scn" - }, - { - "name": "road_blocks/block_highway_straight/block_highway_straight.scn" - }, - { - "name": "road_blocks/block_highway_straight/block_highway_straight.scn" - }, - { - "name": "road_blocks/block_highway_straight/block_highway_straight.scn" - }, - { - "name": "road_blocks/block_highway_straight/block_highway_straight.scn" + "name": "road_blocks/block_highway_turn_in/block_highway_turn_in.scn" } ], "key_values": null, @@ -180,19 +153,6 @@ "instance": 1, "name": "block_highway_straight" }, - { - "components": [ - 13, - 4294967295, - 4294967295, - 4294967295, - 4294967295 - ], - "disabled": false, - "idx": 27, - "instance": 11, - "name": "block_highway_straight" - }, { "components": [ 4, @@ -202,113 +162,9 @@ 4294967295 ], "disabled": false, - "idx": 28, + "idx": 45, "instance": 2, - "name": "block_highway_straight" - }, - { - "components": [ - 5, - 4294967295, - 4294967295, - 4294967295, - 4294967295 - ], - "disabled": false, - "idx": 30, - "instance": 3, - "name": "block_highway_straight" - }, - { - "components": [ - 6, - 4294967295, - 4294967295, - 4294967295, - 4294967295 - ], - "disabled": false, - "idx": 32, - "instance": 4, - "name": "block_highway_straight" - }, - { - "components": [ - 7, - 4294967295, - 4294967295, - 4294967295, - 4294967295 - ], - "disabled": false, - "idx": 34, - "instance": 5, - "name": "block_highway_straight" - }, - { - "components": [ - 8, - 4294967295, - 4294967295, - 4294967295, - 4294967295 - ], - "disabled": false, - "idx": 36, - "instance": 6, - "name": "block_highway_straight" - }, - { - "components": [ - 9, - 4294967295, - 4294967295, - 4294967295, - 4294967295 - ], - "disabled": false, - "idx": 38, - "instance": 7, - "name": "block_highway_straight" - }, - { - "components": [ - 10, - 4294967295, - 4294967295, - 4294967295, - 4294967295 - ], - "disabled": false, - "idx": 40, - "instance": 8, - "name": "block_highway_straight" - }, - { - "components": [ - 11, - 4294967295, - 4294967295, - 4294967295, - 4294967295 - ], - "disabled": false, - "idx": 42, - "instance": 9, - "name": "block_highway_straight" - }, - { - "components": [ - 12, - 4294967295, - 4294967295, - 4294967295, - 4294967295 - ], - "disabled": false, - "idx": 44, - "instance": 10, - "name": "block_highway_straight" + "name": "block_highway_turn_in" } ], "transforms": [ @@ -320,7 +176,7 @@ 13.72885799407959 ], "rot": [ - 18.90964698791504, + 18.909645080566406, -122.79573059082031, 9.935133675753605e-07 ], @@ -387,174 +243,12 @@ { "parent": null, "pos": [ - 0.0, - 0.0, - 5000.0 - ], - "rot": [ - -0.0, - 0.0, - 0.0 - ], - "scl": [ - 1.0, - 1.0, - 1.0 - ] - }, - { - "parent": null, - "pos": [ - 0.0, - 0.0, - 7500.0 - ], - "rot": [ - -0.0, - 0.0, - 0.0 - ], - "scl": [ - 1.0, - 1.0, - 1.0 - ] - }, - { - "parent": null, - "pos": [ - 0.0, - 0.0, - 10000.0 - ], - "rot": [ - -0.0, - 0.0, - 0.0 - ], - "scl": [ - 1.0, - 1.0, - 1.0 - ] - }, - { - "parent": null, - "pos": [ - 0.0, - 0.0, - 12500.0 - ], - "rot": [ - -0.0, - 0.0, - 0.0 - ], - "scl": [ - 1.0, - 1.0, - 1.0 - ] - }, - { - "parent": null, - "pos": [ - 0.0, - 0.0, - 15000.0 - ], - "rot": [ - -0.0, - 0.0, - 0.0 - ], - "scl": [ - 1.0, - 1.0, - 1.0 - ] - }, - { - "parent": null, - "pos": [ - 0.0, - 0.0, - 17500.0 - ], - "rot": [ - -0.0, - 0.0, - 0.0 - ], - "scl": [ - 1.0, - 1.0, - 1.0 - ] - }, - { - "parent": null, - "pos": [ - 0.0, - 0.0, - 20000.0 - ], - "rot": [ - -0.0, - 0.0, - 0.0 - ], - "scl": [ - 1.0, - 1.0, - 1.0 - ] - }, - { - "parent": null, - "pos": [ - 0.0, - 0.0, - 22500.0 - ], - "rot": [ - -0.0, - 0.0, - 0.0 - ], - "scl": [ - 1.0, - 1.0, - 1.0 - ] - }, - { - "parent": null, - "pos": [ - 0.0, - 0.0, - 25000.0 - ], - "rot": [ - -0.0, - 0.0, - 0.0 - ], - "scl": [ - 1.0, - 1.0, - 1.0 - ] - }, - { - "parent": null, - "pos": [ - 0.0, + -260.0, 0.0, 2500.0 ], "rot": [ - -0.0, + 0.0, 0.0, 0.0 ], diff --git a/app/resources/main.scn.editor b/app/resources/main.scn.editor index 1ced81a..1b5f8e5 100644 --- a/app/resources/main.scn.editor +++ b/app/resources/main.scn.editor @@ -14,16 +14,7 @@ 1, 2, 3, - 27, - 28, - 30, - 32, - 34, - 36, - 38, - 40, - 42, - 44 + 45 ] }, "node_sort_method": "custom", @@ -46,7 +37,7 @@ }, "transform_gizmo_plugin": { "mode": "local", - "snap": "none", + "snap": "snap", "snap_rotation": 5.0, "snap_rotation_fine": 1.0, "snap_scale": 10.0, @@ -130,18 +121,18 @@ }, "orthographic_size": 1.0, "perspective": [ - 1.0000081062316895, - 0.0015469788340851665, - 0.004526082891970873, - 3.0016093254089355, - 0.0, - 0.9463406801223755, - -0.32330530881881714, - 41.481101989746094, - -0.00478630606085062, - 0.3232990801334381, - 0.9463456869125366, - -24.189163208007813 + -0.9592915773391724, + -0.09731687605381012, + -0.2652011513710022, + 126.4337158203125, + 0.0, + 0.9388278126716614, + -0.3445146679878235, + 89.39422607421875, + 0.2824861407279968, + -0.33048033714294434, + -0.9006063342094421, + 1507.5623779296875 ], "perspective_fov": 0.8872777223587036, "perspective_zrange": { diff --git a/img/car_debug.png b/img/car_debug.png new file mode 100644 index 0000000..2488a02 Binary files /dev/null and b/img/car_debug.png differ diff --git a/img/car_interior.png b/img/car_interior.png new file mode 100644 index 0000000..a4348ea Binary files /dev/null and b/img/car_interior.png differ diff --git a/img/physics_debug.png b/img/physics_debug.png new file mode 100644 index 0000000..da54215 Binary files /dev/null and b/img/physics_debug.png differ diff --git a/img/raycast_car_001.gif b/img/raycast_car_001.gif new file mode 100644 index 0000000..2afb013 Binary files /dev/null and b/img/raycast_car_001.gif differ