WUT_Computer_Science/code/main.py
Jakub Poćwiardowski 5212d78a73
arg parsing, minor name changes and fixes (#2)
* arg parsing, minor name changes and fixes

* reqs returned, scene and env added as args to rendering (not doing anything yet)

* added folders for scenes and envs

* added folders for scenes and envs (now they actually appear on GH after adding readmes)

* added varying spheres amount
2024-12-28 16:57:27 +01:00

36 lines
1.6 KiB
Python

import argparse
from configparser import ConfigParser
from rendering import ray_trace
from utils import load_config, parse_resolution
def main():
# default config
config = load_config('config.ini')
# Parse
parser = argparse.ArgumentParser(description="Rendering Program")
parser.add_argument('--algorithm', type=str, help='Algorithm to use', default=config.get('DEFAULT', 'algorithm'))
parser.add_argument('--scene', type=str, help='Path to scene file', default=config.get('DEFAULT', 'scene'))
parser.add_argument('--environment_map', type=str, help='Environment map file', default=config.get('DEFAULT', 'environment_map'))
parser.add_argument('--resolution', type=str, help='Image resolution (WIDTHxHEIGHT)',
default=config.get('DEFAULT', 'resolution'))
parser.add_argument('--num_spheres', type=int, default=3, help='Number of spheres in the scene')
args = parser.parse_args()
width, height = parse_resolution(args.resolution)
# Run the selected algorithm
if args.algorithm == "ray_tracing":
print("Starting ray tracing...")
# ray_trace(args.scene, args.environment_map, image_width=width, image_height=height, output_file="output_ray_traced.png")
ray_trace(args.num_spheres, args.environment_map, image_width=width, image_height=height, # na razie generujemy w kodzie, ale potem trzeba będzie obj wczytywać
output_file="output_ray_traced.png")
else:
print(f"Unknown algorithm: {args.algorithm}")
return
if __name__ == '__main__':
main()