diff options
author | Nemrav <> | 2024-11-17 22:51:35 +0100 |
---|---|---|
committer | Nemrav <> | 2024-11-17 22:51:35 +0100 |
commit | 0d1f42829b154c172608450e3689c56cbfacb4fd (patch) | |
tree | f5aa2633ea252ba2e602c88fea5d9b77a1b83283 /game/src/Game/GameSession/BillboardManager.gd | |
parent | 54ddd94739d7efa3b7539d638edaf89b023ef903 (diff) |
billboards placement
Diffstat (limited to 'game/src/Game/GameSession/BillboardManager.gd')
-rw-r--r-- | game/src/Game/GameSession/BillboardManager.gd | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/game/src/Game/GameSession/BillboardManager.gd b/game/src/Game/GameSession/BillboardManager.gd index 5a6fea6..ac1610b 100644 --- a/game/src/Game/GameSession/BillboardManager.gd +++ b/game/src/Game/GameSession/BillboardManager.gd @@ -4,8 +4,10 @@ extends MultiMeshInstance3D #var billboard_names = { #} -var billboard_names = [] +@export var _map_view : MapView +var billboard_names = [] +const SCALE_FACTOR = 1.0/64.0 # Called when the node enters the scene tree for the first time. func _ready(): const name_key : StringName = &"name" @@ -26,7 +28,7 @@ func _ready(): var noFrames = billboard[noOfFrames_key] textures.push_back(AssetManager.get_texture(texture)) frames.push_back(noFrames) - scales.push_back(b_scale) + scales.push_back(b_scale*SCALE_FACTOR) billboard_names.push_back(b_name) var material:ShaderMaterial = load("res://src/Game/GameSession/billboards.tres") @@ -50,18 +52,30 @@ func _ready(): #GameSingleton.get_mapmode_identifier(0) #GameSingleton.get_mapmode_count() - var positions: PackedVector2Array = MapItemSingleton.get_province_positions() + var positions_len = MapItemSingleton.get_province_count() + + print(positions_len) # Then resize (otherwise, changing the format is not allowed). - #multimesh.instance_count = positions.size() - #multimesh.visible_instance_count = positions.size() + multimesh.instance_count = positions_len + multimesh.visible_instance_count = positions_len print("===============") + var positions = MapItemSingleton.get_province_positions() + print("===============") + + var map_positions : PackedVector3Array = PackedVector3Array() + for pos_in in positions: + var pos = _map_view._map_to_world_coords(pos_in)# + Vector3(0, 0.5 * SCALE_FACTOR, 0) + map_positions.push_back(pos) #print(positions) #print(positions.size()) # Set the transform of the instances. - """for i in multimesh.visible_instance_count: + #model.set_position( + #_map_view._map_to_world_coords(unit_dict[position_key]) + # + Vector3(0, 0.1 * MODEL_SCALE, 0)) + for i in multimesh.visible_instance_count: multimesh.set_instance_transform(i, Transform3D(Basis(), - Vector3(positions[i].x, 0.5, positions[i].y) + map_positions[i] )) # custom data is a single vec4 float sent as a color # Info send to the shader is as follows: @@ -73,7 +87,7 @@ func _ready(): var im = r(textures.size()-1) multimesh.set_instance_custom_data(i,Color( im,r(frames[im]),1.0,0 - ))""" + )) func r(x:int=1)->int: return randi_range(0,x) |