Skip to content

Commit

Permalink
Merge pull request #14 from harfang3d/path_converter_nms_json
Browse files Browse the repository at this point in the history
Path converter nms json Fix #13
  • Loading branch information
disketflu authored Nov 22, 2022
2 parents bc3034e + 4924da2 commit f390a03
Show file tree
Hide file tree
Showing 12 changed files with 7,834 additions and 25 deletions.
14 changes: 14 additions & 0 deletions app/car_spawner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import harfang as hg
from utils import *

def CreateNewCar(scene, res, pos):
node, _ = hg.CreateInstanceFromAssets(scene, hg.TranslationMat4(pos), "vehicles/ai_vehicle/drivable_car.scn", res, hg.GetForwardPipelineInfo())
return node

def HandleCarMovement(carnode, physics):
carnode_transform = carnode.GetTransform()
car_pos = carnode_transform.GetPos()
# print("carpos : (" + str(car_pos.x) + ", " + str(car_pos.y) + ", " + str(car_pos.z) + ")")
car_pos.z += 0.65
carnode_transform.SetPos(car_pos)
# physics.NodeWake(carnode)
11 changes: 9 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# HARFANG® 3D - www.harfang3d.com - Raycast Car demo sample
# HARFANG® 3D - www.harfang3d.com - Raycast Car with VR Simulator
import harfang as hg
from car import *
from car_camera import *
from car_lights import *
from gui import *
from car_spawner import *
import sys

render_mode = "normal"
Expand Down Expand Up @@ -79,7 +80,10 @@ def CreateMaterial(ubc, orm):

clocks = hg.SceneClocks()
physics = hg.SceneBullet3Physics()
car = CarModelCreate("Generic Car", "car", scene, physics, res, hg.Vec3(-10, 1.5, -1000), hg.Vec3(0, 0, 0))
car = CarModelCreate("Generic Car", "car", scene, physics, res, hg.Vec3(5, 1.5, 0), hg.Vec3(0, 0, 0))
second_car = CreateNewCar(scene, res, hg.Vec3(3.5, 1, 10))
third_car = CreateNewCar(scene, res, hg.Vec3(7.5, 1, 20))

carlights = CarLightsCreate("car", scene)
physics.SceneCreatePhysicsFromAssets(scene)

Expand Down Expand Up @@ -158,6 +162,9 @@ def CreateMaterial(ubc, orm):
CarLightsSetReverse(carlights, reverse)
CarLightsUpdate(carlights, scene, dt)
current_camera_node, camera_update = CarCameraUpdate(car_camera, scene, keyboard, dt, car_vel, render_mode)
HandleCarMovement(second_car, physics)
HandleCarMovement(third_car, physics)


# Scene updates
vid = 0 # keep track of the next free view id
Expand Down
44 changes: 39 additions & 5 deletions app/resources/main.scn
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
},
{
"name": "road_blocks/block_highway_turn_in/block_highway_turn_in.scn"
},
{
"name": "road_blocks/block_highway_straight/block_highway_straight.scn"
}
],
"key_values": null,
Expand Down Expand Up @@ -187,7 +190,7 @@
4294967295
],
"disabled": false,
"idx": 19,
"idx": 5,
"instance": 5,
"name": "block_highway_turn_in"
},
Expand All @@ -200,7 +203,7 @@
4294967295
],
"disabled": false,
"idx": 21,
"idx": 6,
"instance": 3,
"name": "block_highway_straight"
},
Expand All @@ -213,7 +216,7 @@
4294967295
],
"disabled": false,
"idx": 24,
"idx": 7,
"instance": 6,
"name": "block_highway_turn_in"
},
Expand All @@ -226,9 +229,22 @@
4294967295
],
"disabled": false,
"idx": 25,
"idx": 8,
"instance": 4,
"name": "block_highway_turn_in"
},
{
"components": [
9,
4294967295,
4294967295,
4294967295,
4294967295
],
"disabled": false,
"idx": 36,
"instance": 7,
"name": "block_highway_straight"
}
],
"transforms": [
Expand Down Expand Up @@ -385,14 +401,32 @@
],
"rot": [
-0.0,
179.99998474121094,
179.99996948242188,
0.0
],
"scl": [
0.9999998211860657,
1.0,
0.9999998211860657
]
},
{
"parent": null,
"pos": [
0.0,
0.0,
-20000.0
],
"rot": [
-0.0,
0.0,
0.0
],
"scl": [
1.0,
1.0,
1.0
]
}
]
}
37 changes: 19 additions & 18 deletions app/resources/main.scn.editor
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
2,
3,
4,
19,
21,
24,
25
5,
6,
7,
8,
36
]
},
"node_sort_method": "custom",
Expand All @@ -35,13 +36,13 @@
"subdiv_size": 1.0
},
"navigation_plugin": {
"orbit_distance": 5.0,
"orbit_distance": 15.933184623718262,
"speed": 0.800000011920929,
"turbo": 100.0
},
"transform_gizmo_plugin": {
"mode": "local",
"snap": "snap",
"snap": "none",
"snap_rotation": 5.0,
"snap_rotation_fine": 1.0,
"snap_scale": 10.0,
Expand Down Expand Up @@ -125,18 +126,18 @@
},
"orthographic_size": 1.0,
"perspective": [
-0.1434980034828186,
0.289354532957077,
0.9464626312255859,
-4972.26953125,
0.0,
0.9563506841659546,
-0.29238173365592957,
667.3928833007813,
-0.9896777272224426,
-0.04195459187030792,
-0.1372241973876953,
599.6455688476563
0.8800933957099915,
0.1285829246044159,
0.45712271332740784,
-7.283420562744141,
0.0,
0.962685763835907,
-0.27079135179519653,
4.314568519592285,
-0.4748568534851074,
0.23831409215927124,
0.8472405076026917,
-20013.5
],
"perspective_fov": 0.8872777223587036,
"perspective_zrange": {
Expand Down
Loading

0 comments on commit f390a03

Please sign in to comment.