chore: commit untracked UE/scaffold files (repo cleanup triage 20260707)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Dubai Metaverse Team
2026-07-07 03:43:19 -07:00
parent b9c4978802
commit 9629838469
147 changed files with 26523 additions and 0 deletions

158
scripts/data/gis_to_unreal.py Executable file
View File

@@ -0,0 +1,158 @@
#!/usr/bin/env python3
"""
Dubai Metaverse - GIS to Unreal Terrain Conversion Script
Converts elevation data (DEM/GeoTIFF) to Unreal Engine terrain format
"""
import os
import sys
import argparse
from typing import Tuple, Optional
try:
import rasterio
import numpy as np
except ImportError:
print("Error: Required packages not installed.")
print("Install with: pip install rasterio numpy")
sys.exit(1)
def load_elevation_data(dem_file: str) -> Tuple[np.ndarray, dict]:
"""
Load elevation data from GeoTIFF file.
Returns:
elevation_data: NumPy array of elevation values
metadata: Dictionary with geospatial metadata
"""
try:
with rasterio.open(dem_file) as src:
elevation_data = src.read(1) # Read first band
metadata = {
'width': src.width,
'height': src.height,
'crs': src.crs,
'transform': src.transform,
'bounds': src.bounds
}
return elevation_data, metadata
except Exception as e:
print(f"Error loading elevation data: {e}")
sys.exit(1)
def normalize_elevation(elevation_data: np.ndarray, min_elev: float, max_elev: float) -> np.ndarray:
"""
Normalize elevation data to 0-1 range for Unreal Engine.
Unreal Engine uses 0-1 normalized height values.
"""
# Clip to min/max range
elevation_data = np.clip(elevation_data, min_elev, max_elev)
# Normalize to 0-1
normalized = (elevation_data - min_elev) / (max_elev - min_elev)
return normalized
def export_heightmap(normalized_data: np.ndarray, output_file: str, format: str = 'raw'):
"""
Export normalized elevation data as heightmap.
Formats:
- 'raw': Raw binary format (16-bit)
- 'png': PNG format (16-bit grayscale)
"""
# Convert to 16-bit integer (0-65535)
heightmap = (normalized_data * 65535).astype(np.uint16)
if format == 'raw':
heightmap.tofile(output_file)
print(f"✓ Exported heightmap to {output_file} (RAW format)")
elif format == 'png':
try:
from PIL import Image
# Convert to 16-bit PNG
img = Image.fromarray(heightmap, mode='I;16')
img.save(output_file)
print(f"✓ Exported heightmap to {output_file} (PNG format)")
except ImportError:
print("Warning: PIL not installed, falling back to RAW format")
heightmap.tofile(output_file)
print(f"✓ Exported heightmap to {output_file} (RAW format)")
else:
print(f"Error: Unknown format '{format}'")
sys.exit(1)
def main():
parser = argparse.ArgumentParser(description='Convert GIS elevation data to Unreal terrain')
parser.add_argument('input', help='Input DEM/GeoTIFF file')
parser.add_argument('--output', '-o', default='data/processed/terrain_heightmap.raw',
help='Output heightmap file')
parser.add_argument('--format', choices=['raw', 'png'], default='raw',
help='Output format (raw or png)')
parser.add_argument('--min-elev', type=float, help='Minimum elevation (meters)')
parser.add_argument('--max-elev', type=float, help='Maximum elevation (meters)')
args = parser.parse_args()
if not os.path.exists(args.input):
print(f"Error: Input file not found: {args.input}")
sys.exit(1)
# Create output directory if it doesn't exist
os.makedirs(os.path.dirname(args.output), exist_ok=True)
print("==========================================")
print("Dubai Metaverse - GIS to Unreal Terrain")
print("==========================================")
print("")
print(f"Loading elevation data: {args.input}")
elevation_data, metadata = load_elevation_data(args.input)
print(f"Data dimensions: {metadata['width']} x {metadata['height']}")
print(f"Bounds: {metadata['bounds']}")
print("")
# Determine elevation range
if args.min_elev is None:
min_elev = float(np.nanmin(elevation_data))
else:
min_elev = args.min_elev
if args.max_elev is None:
max_elev = float(np.nanmax(elevation_data))
else:
max_elev = args.max_elev
print(f"Elevation range: {min_elev:.2f}m to {max_elev:.2f}m")
print("")
print("Normalizing elevation data...")
normalized = normalize_elevation(elevation_data, min_elev, max_elev)
print("Exporting heightmap...")
export_heightmap(normalized, args.output, args.format)
print("")
print("==========================================")
print("Conversion Complete")
print("==========================================")
print("")
print("Next steps:")
print("1. Import heightmap to Unreal Engine")
print("2. Create landscape from heightmap")
print("3. Adjust landscape material and settings")
print("")
print(f"Heightmap file: {args.output}")
print(f"Dimensions: {metadata['width']} x {metadata['height']}")
print("")
if __name__ == '__main__':
main()

134
scripts/data/import_osm_data.py Executable file
View File

@@ -0,0 +1,134 @@
#!/usr/bin/env python3
"""
Dubai Metaverse - OpenStreetMap Data Import Script
Imports OpenStreetMap data for Dubai Marina and converts to Unreal-compatible format
"""
import os
import sys
import json
import argparse
from typing import List, Dict, Tuple
try:
import overpy
import geojson
except ImportError:
print("Error: Required packages not installed.")
print("Install with: pip install overpy geojson")
sys.exit(1)
def get_marina_buildings(api: overpy.Overpass) -> List[Dict]:
"""
Query OpenStreetMap for buildings in Dubai Marina area.
Note: Coordinates should be adjusted based on actual Dubai Marina location.
"""
# Dubai Marina approximate bounding box
# These coordinates should be verified and adjusted
query = """
[out:json][timeout:25];
(
way["building"](25.0750,55.1350,25.0850,55.1450);
);
out geom;
"""
try:
result = api.query(query)
buildings = []
for way in result.ways:
building = {
'id': way.id,
'nodes': [(node.lat, node.lon) for node in way.nodes],
'tags': way.tags
}
buildings.append(building)
return buildings
except Exception as e:
print(f"Error querying OpenStreetMap: {e}")
return []
def buildings_to_geojson(buildings: List[Dict], output_file: str):
"""Convert buildings to GeoJSON format."""
features = []
for building in buildings:
# Create polygon from nodes
coordinates = [[node[1], node[0]] for node in building['nodes']] # GeoJSON uses [lon, lat]
coordinates.append(coordinates[0]) # Close polygon
feature = {
'type': 'Feature',
'geometry': {
'type': 'Polygon',
'coordinates': [coordinates]
},
'properties': {
'id': building['id'],
'tags': building['tags']
}
}
features.append(feature)
geojson_data = {
'type': 'FeatureCollection',
'features': features
}
with open(output_file, 'w') as f:
json.dump(geojson_data, f, indent=2)
print(f"✓ Exported {len(features)} buildings to {output_file}")
def main():
parser = argparse.ArgumentParser(description='Import OpenStreetMap data for Dubai Marina')
parser.add_argument('--output', '-o', default='data/processed/dubai_marina_buildings.geojson',
help='Output GeoJSON file path')
parser.add_argument('--area', help='Custom bounding box (lat1,lon1,lat2,lon2)')
args = parser.parse_args()
# Create output directory if it doesn't exist
os.makedirs(os.path.dirname(args.output), exist_ok=True)
print("==========================================")
print("Dubai Metaverse - OSM Data Import")
print("==========================================")
print("")
print("Connecting to OpenStreetMap API...")
api = overpy.Overpass()
print("Querying Dubai Marina buildings...")
buildings = get_marina_buildings(api)
if not buildings:
print("⚠ No buildings found. Check coordinates and query.")
return
print(f"Found {len(buildings)} buildings")
print("")
print("Converting to GeoJSON...")
buildings_to_geojson(buildings, args.output)
print("")
print("==========================================")
print("Import Complete")
print("==========================================")
print("")
print("Next steps:")
print("1. Review GeoJSON file in GIS software (QGIS)")
print("2. Import to Unreal Engine using GIS import tools")
print("3. Generate building meshes from footprints")
print("")
if __name__ == '__main__':
main()