diff --git a/Makefile b/Makefile index 70254eb..fb5cf0c 100644 --- a/Makefile +++ b/Makefile @@ -77,10 +77,6 @@ SOURCES := \ $(SRCDIR)/main.c \ $(SRCDIR)/$(PLATFORM_DIR)/mlx.c \ $(SRCDIR)/put_info.c \ - $(SRCDIR)/debug/print_context.c \ - $(SRCDIR)/debug/print_objects.c \ - $(SRCDIR)/debug/print_scene.c \ - $(SRCDIR)/debug/print_utils.c \ $(SRCDIR)/parsing/object_list.c \ $(SRCDIR)/parsing/parse.c \ $(SRCDIR)/parsing/parse_ambient.c \ diff --git a/README.md b/README.md index ce5aecf..fceb471 100644 --- a/README.md +++ b/README.md @@ -102,14 +102,6 @@ pl cy ``` -### Example Scene Files - -Sample scene files are provided in the `scenes/` directory: - -- `scenes/valid/example.rt`: Basic example scene -- `scenes/valid/*`: Other valid scene files -- `scenes/error/*`: Invalid scene files for testing error handling - ### Controls - **ESC**: Close window and exit program diff --git a/docs/SPECIFICATION.md b/docs/SPECIFICATION.md deleted file mode 100644 index 0fcdf90..0000000 --- a/docs/SPECIFICATION.md +++ /dev/null @@ -1,397 +0,0 @@ -# miniRT 仕様書 - -## 概要 - -miniRTは、レイトレーシング技術を使用してコンピュータ生成画像をレンダリングするプログラムです。MiniLibXライブラリを使用してウィンドウ管理とピクセル描画を行います。 - ---- - -## 1. プログラム仕様 - -| 項目 | 内容 | -|------|------| -| プログラム名 | `miniRT` | -| 引数 | `*.rt`形式のシーン記述ファイル | -| 使用言語 | C言語 | -| コンパイラフラグ | `-Wall -Wextra -Werror` | - -### 1.1 使用可能な外部関数 - -- 標準関数: `open`, `close`, `read`, `write`, `printf`, `malloc`, `free`, `perror`, `strerror`, `exit` -- 数学ライブラリ: `math.h`の全関数(`-lm`フラグでコンパイル) -- グラフィックス: MiniLibXライブラリの全関数 -- その他: `gettimeofday()` - -### 1.2 自作ライブラリ - -- `libft`: 許可 - ---- - -## 2. 機能要件 - -### 2.1 幾何学的オブジェクト - -以下の3種類のオブジェクトをサポートする: - -| オブジェクト | 識別子 | プロパティ | -|-------------|--------|-----------| -| 球 (Sphere) | `sp` | 中心座標、直径、色 | -| 平面 (Plane) | `pl` | 通過点座標、法線ベクトル、色 | -| 円柱 (Cylinder) | `cy` | 中心座標、軸ベクトル、直径、高さ、色 | - -### 2.2 ライティング - -| 種類 | 説明 | -|------|------| -| 環境光 (Ambient) | シーン全体に均一に適用される基底光 | -| 拡散光 (Diffuse) | 光源からの方向依存の照明 | -| ハードシャドウ | オブジェクトによる影の描画 | - -### 2.3 交差判定 - -- 全てのオブジェクトに対するレイとの交差を正しく処理 -- オブジェクト内部からの交差も正しく処理 - -### 2.4 変換 - -| 変換 | 対象オブジェクト | -|------|------------------| -| 平行移動 | 全オブジェクト、ライト、カメラ | -| 回転 | 平面、円柱、カメラ(球とライトは回転不可) | -| リサイズ | 球の直径、円柱の幅と高さ | - ---- - -## 3. ウィンドウ管理 - -### 3.1 表示仕様 - -| 項目 | 値 | -|------|-----| -| ウィンドウ幅 | 1080px | -| ウィンドウ高さ | 800px | - -### 3.2 操作 - -| 操作 | 動作 | -|------|------| -| ESCキー押下 | ウィンドウを閉じ、プログラムを正常終了 | -| ウィンドウの×ボタン | ウィンドウを閉じ、プログラムを正常終了 | -| ウィンドウ切り替え | 流動的に動作すること | -| 最小化 | 流動的に動作すること | - ---- - -## 4. シーンファイル形式 (`.rt`) - -### 4.1 基本ルール - -- ファイル拡張子: `.rt` -- 要素は1つ以上の改行で区切る -- 要素内の情報は1つ以上のスペースで区切る -- 要素の順序は任意 -- 大文字識別子の要素(A, C, L)はシーン内で1回のみ - -### 4.2 要素定義 - -#### 環境光 (Ambient Light) - -``` -A -``` - -| パラメータ | 範囲 | 説明 | -|-----------|------|------| -| 識別子 | `A` | 固定 | -| ratio | 0.0〜1.0 | 環境光の強度 | -| R,G,B | 0〜255 | 色(カンマ区切り) | - -**例:** `A 0.2 255,255,255` - -#### カメラ (Camera) - -``` -C -``` - -| パラメータ | 範囲 | 説明 | -|-----------|------|------| -| 識別子 | `C` | 固定 | -| x,y,z | 実数 | 視点座標 | -| dx,dy,dz | -1.0〜1.0 | 正規化方向ベクトル | -| FOV | 0〜180 | 水平視野角(度) | - -**例:** `C -50.0,0,20 0,0,1 70` - -#### ライト (Light) - -``` -L -``` - -| パラメータ | 範囲 | 説明 | -|-----------|------|------| -| 識別子 | `L` | 固定 | -| x,y,z | 実数 | ライト座標 | -| brightness | 0.0〜1.0 | 明るさ | -| R,G,B | 0〜255 | 色(必須パートでは未使用) | - -**例:** `L -40.0,50.0,0.0 0.6 10,0,255` - -#### 球 (Sphere) - -``` -sp -``` - -| パラメータ | 範囲 | 説明 | -|-----------|------|------| -| 識別子 | `sp` | 固定 | -| x,y,z | 実数 | 中心座標 | -| diameter | 正の実数 | 直径 | -| R,G,B | 0〜255 | 色 | - -**例:** `sp 0.0,0.0,20.6 12.6 10,0,255` - -#### 平面 (Plane) - -``` -pl -``` - -| パラメータ | 範囲 | 説明 | -|-----------|------|------| -| 識別子 | `pl` | 固定 | -| x,y,z | 実数 | 平面上の点 | -| nx,ny,nz | -1.0〜1.0 | 正規化法線ベクトル | -| R,G,B | 0〜255 | 色 | - -**例:** `pl 0.0,0.0,-10.0 0.0,1.0,0.0 0,0,225` - -#### 円柱 (Cylinder) - -``` -cy -``` - -| パラメータ | 範囲 | 説明 | -|-----------|------|------| -| 識別子 | `cy` | 固定 | -| x,y,z | 実数 | 中心座標 | -| ax,ay,az | -1.0〜1.0 | 正規化軸ベクトル | -| diameter | 正の実数 | 直径 | -| height | 正の実数 | 高さ | -| R,G,B | 0〜255 | 色 | - -**例:** `cy 50.0,0.0,20.6 0.0,0.0,1.0 14.2 21.42 10,0,255` - -### 4.3 サンプルシーン - -``` -A 0.2 255,255,255 - -C -50,0,20 0,0,1 70 -L -40,0,30 0.7 255,255,255 - -pl 0,0,0 0,1.0,0 255,0,225 -sp 0,0,20 20 255,0,0 -cy 50.0,0.0,20.6 0,0,1.0 14.2 21.42 10,0,255 -``` - ---- - -## 5. エラー処理 - -### 5.1 エラー出力形式 - -``` -Error -<エラーメッセージ> -``` - -### 5.2 検出すべきエラー - -| カテゴリ | エラー内容 | -|---------|-----------| -| 引数 | ファイル拡張子が`.rt`でない | -| 引数 | ファイルが存在しない/読めない | -| 構文 | 不明な識別子 | -| 構文 | パラメータ数の不一致 | -| 値 | 範囲外の値(ratio, FOV, 色など) | -| シーン | 必須要素(A, C, L)の欠落 | -| シーン | 大文字要素の重複定義 | -| シーン | オブジェクトが1つもない | - ---- - -## 6. 技術仕様 - -### 6.1 座標系 - -- 右手座標系 -- X軸: 右方向が正 -- Y軸: 上方向が正 -- Z軸: 手前方向が正 - -### 6.2 定数 - -| 定数 | 値 | 用途 | -|------|-----|------| -| EPSILON | 1e-6 | 浮動小数点比較の許容誤差 | -| PI | 3.14159265358979323846 | 円周率 | - -### 6.3 レンダリングアルゴリズム - -1. **カメラフレーム設定**: FOVに基づく視錐台の計算 -2. **レイ生成**: 各ピクセルに対応するレイを生成 -3. **交差判定**: 全オブジェクトとの交差を計算 -4. **最近接点選択**: 最も近い交差点を選択 -5. **シャドウレイ**: 光源への遮蔽を判定 -6. **シェーディング**: 環境光 + 拡散光を計算 -7. **色出力**: ピクセル色を決定 - ---- - -## 7. ボーナス機能(オプション) - -必須パートが完全に動作する場合のみ実装可能: - -| 機能 | 説明 | -|------|------| -| スペキュラ反射 | 完全なPhong反射モデル | -| チェッカーボード | パターンテクスチャ | -| 複数ライト | 色付きマルチスポットライト | -| 追加オブジェクト | 円錐、双曲面、放物面など | -| バンプマッピング | テクスチャによる法線操作 | - ---- - -## 8. ビルド仕様 - -### 8.1 Makefileルール - -| ルール | 動作 | -|--------|------| -| `all` | プログラムをビルド | -| `clean` | オブジェクトファイルを削除 | -| `fclean` | オブジェクトファイルと実行ファイルを削除 | -| `re` | `fclean` + `all` | -| `bonus` | ボーナス機能付きでビルド | - -### 8.2 プラットフォーム - -- macOS -- Linux - ---- - -## 9. プロジェクト構成 - -``` -miniRT/ -├── includes/ # ヘッダファイル -│ ├── miniRT.h # メインAPI -│ ├── struct.h # データ構造定義 -│ ├── config.h # 設定定数 -│ └── errors.h # エラーメッセージ -├── srcs/ # ソースコード -│ ├── main.c # エントリポイント -│ ├── init.c # 初期化 -│ ├── mlx.c # ウィンドウ管理 -│ ├── render.c # レイトレーシング -│ ├── render_shading.c # シェーディング -│ ├── ray_*.c # 交差判定 -│ ├── parsing/ # パーシング -│ ├── utils/ # ユーティリティ -│ └── debug/ # デバッグ用 -├── libft/ # 自作ライブラリ -├── minilibx_*/ # MiniLibXライブラリ -├── scenes/ # テストシーン -│ ├── valid/ # 正常系テスト -│ └── error/ # 異常系テスト -└── Makefile -``` - ---- - -## 10. 実装状況 - -### 10.1 必須パート - -| 機能 | 状態 | -|------|------| -| シーンパーシング | 完了 | -| 球の交差判定 | 完了 | -| 平面の交差判定 | 完了 | -| 円柱の交差判定 | 完了 | -| 環境光 | 完了 | -| 拡散光 | 完了 | -| シャドウ | 完了 | -| ウィンドウ管理 | 完了 | -| エラー処理 | 完了 | - -### 10.2 ボーナスパート - -| 機能 | 状態 | -|------|------| -| スペキュラ反射 | 未実装 | -| チェッカーボード | 未実装 | -| 複数ライト | 未実装 | -| 追加オブジェクト | 未実装 | -| バンプマッピング | 未実装 | - ---- - -## 付録A: 数学公式 - -### A.1 レイの定義 - -``` -P(t) = O + t * D -``` - -- O: レイの原点 -- D: レイの方向(正規化) -- t: パラメータ(t > 0で有効) - -### A.2 球との交差 - -球の方程式: `|P - C|² = r²` - -二次方程式: `at² + bt + c = 0` -- a = D · D -- b = 2 * D · (O - C) -- c = (O - C) · (O - C) - r² - -判別式: `Δ = b² - 4ac` - -### A.3 平面との交差 - -平面の方程式: `(P - P₀) · N = 0` - -``` -t = (P₀ - O) · N / (D · N) -``` - -- P₀: 平面上の点 -- N: 法線ベクトル - -### A.4 円柱との交差 - -側面、上面キャップ、下面キャップの3つの交差を個別に計算し、最も近い有効な交差点を選択。 - -### A.5 拡散光(ランバート反射) - -``` -I_diffuse = I_light * k_d * max(0, N · L) -``` - -- I_light: 光源の強度 -- k_d: 拡散反射係数 -- N: 表面法線 -- L: 光源方向 - ---- - -*最終更新: 2026-01-10* diff --git a/includes/config.h b/includes/config.h index fb87720..b92c2db 100644 --- a/includes/config.h +++ b/includes/config.h @@ -6,7 +6,7 @@ /* By: stakada +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/08/22 21:44:50 by stakada #+# #+# */ -/* Updated: 2026/02/20 20:25:07 by stakada ### ########.fr */ +/* Updated: 2026/02/23 10:48:44 by stakada ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,6 +19,7 @@ # define PROGRAM "miniRT" # define EXECUTION "./miniRT" # define EPSILON 1e-6 +# define NORM_EPSILON 1e-3 # define DBL_MAX __DBL_MAX__ # if defined(__APPLE__) @@ -39,6 +40,8 @@ # define KEY_RIGHT 124 # define KEY_PLUS 24 # define KEY_MINUS 27 +# define KEY_P 35 +# define KEY_M 46 # define KEY_H 4 # define KEY_J 38 # else @@ -60,6 +63,8 @@ # define KEY_RIGHT XK_Right # define KEY_PLUS XK_plus # define KEY_MINUS XK_minus +# define KEY_P XK_p +# define KEY_M XK_m # define KEY_H XK_h # define KEY_J XK_j # endif @@ -77,13 +82,6 @@ # define MOUSE_SCROLL_UP 4 # define MOUSE_SCROLL_DOWN 5 -# if defined(__APPLE__) -# define ESC_KEY 53 -# else -# include -# define ESC_KEY XK_Escape -# endif - # define VALID 1 # define INVALID 0 diff --git a/includes/miniRT.h b/includes/miniRT.h index d74a18e..af549e8 100644 --- a/includes/miniRT.h +++ b/includes/miniRT.h @@ -6,7 +6,7 @@ /* By: stakada +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/08/22 13:37:02 by stakada #+# #+# */ -/* Updated: 2026/02/20 20:24:50 by stakada ### ########.fr */ +/* Updated: 2026/02/22 19:05:00 by stakada ### ########.fr */ /* */ /* ************************************************************************** */ @@ -60,15 +60,7 @@ int clamp_color(double value); void print_error(char *msg, ...); // free -void free_scene(t_scene *scene); +void free_scene(t_scene **scene); void free_ctx(t_ctx *ctx); -// TODO: delete debug statement (print_*) -// debug -void print_context(t_ctx *ctx); -void print_scene(t_scene *scene); -void print_objects(t_obj *objects); -void print_vec3(const char *prefix, t_vec3 vec); -void print_color(const char *prefix, t_rgb color); - #endif diff --git a/miniRT_v9_ja.md b/miniRT_v9_ja.md deleted file mode 100644 index ccbea15..0000000 --- a/miniRT_v9_ja.md +++ /dev/null @@ -1,259 +0,0 @@ -[[miniRT]] - ---- -# miniRT - -## 表紙 - -**miniRT** MiniLibXを使った私の最初のレイトレーサー - -**概要:** このプロジェクトは、レイトレーシングの美しい世界への入門です。 完了すれば、シンプルなコンピュータ生成画像をレンダリングできるようになり、数学的な公式を実装することを二度と恐れなくなるでしょう。 - -**バージョン:** 9.0 - ---- - -## 目次 - -- I 導入 ... 2 -- II 共通指示 ... 3 -- III AI指示 ... 5 -- IV 必須パート - miniRT ... 7 -- V ボーナスパート ... 12 -- VI 例 ... 14 -- VII 提出とピア評価 ... 19 - ---- - -## 第I章:導入 - -3次元のコンピュータ生成画像をレンダリングする際には、2つの可能なアプローチがあります:その効率性からほぼすべてのグラフィックスエンジンで使用されている「**ラスタライゼーション**」と、「**レイトレーシング**」です。 - -「**レイトレーシング**」手法は、1968年に初めて開発されましたが(その後改良されてきました)、「**ラスタライゼーション**」手法よりも計算コストが高いままです。その結果、リアルタイムの使用例にはまだ完全には適応されていませんが、はるかに高い視覚的リアリズムを生み出します。 - -_図I.1: 上の写真はレイトレーシング技術でレンダリングされています。印象的でしょう?_ - -このような高品質なグラフィックスを生成し始める前に、基礎をマスターしなければなりません:miniRTは、Cで書かれ、ノーム準拠で、控えめながらも機能的な、あなたの最初のレイトレーサーです。 - -miniRTの主な目標は、数学者でなくても数学的または物理的な公式を実装できることを自分自身に証明することです。ここでは最も基本的なレイトレーシング機能のみを実装するので、落ち着いて、深呼吸して、**パニックにならないで!** このプロジェクトの後、学校で費やしている時間を正当化するための見栄えの良い画像を披露できるようになるでしょう。 - ---- - -## 第II章:共通指示 - -- あなたのプロジェクトはCで書かれなければなりません。 -- あなたのプロジェクトはノームに従って書かれなければなりません。ボーナスファイル/関数がある場合、それらはノームチェックに含まれ、ノームエラーがあれば0点となります。 -- あなたの関数は、未定義動作を除いて、予期せず終了してはなりません(セグメンテーションフォルト、バスエラー、ダブルフリーなど)。これが発生した場合、あなたのプロジェクトは機能していないとみなされ、評価中に0点を受けます。 -- ヒープに割り当てられたすべてのメモリは、必要に応じて適切に解放されなければなりません。メモリリークは許容されません。 -- 課題で必要とされる場合、ccを使用して-Wall、-Wextra、-Werrorフラグでソースファイルを必要な出力にコンパイルするMakefileを提出しなければなりません。さらに、あなたのMakefileは不必要な再リンクを行ってはなりません。 -- あなたのMakefileには、少なくとも$(NAME)、all、clean、fclean、reのルールが含まれていなければなりません。 -- プロジェクトのボーナスを提出するには、Makefileにbonusルールを含める必要があります。これにより、プロジェクトの主要部分で許可されていない様々なヘッダー、ライブラリ、または関数がすべて追加されます。ボーナスは、課題で別途指定されない限り、_bonus.{c/h}ファイルに配置されなければなりません。必須パートとボーナスパートの評価は別々に行われます。 -- プロジェクトでlibftの使用が許可されている場合、そのソースと関連するMakefileをlibftフォルダにコピーしなければなりません。プロジェクトのMakefileは、そのMakefileを使用してライブラリをコンパイルし、その後プロジェクトをコンパイルしなければなりません。 -- 提出や採点の必要はありませんが、プロジェクトのテストプログラムを作成することを推奨します。自分の作業や同期の作業を簡単にテストする機会を与えてくれます。これらのテストは、ディフェンス中に特に役立つでしょう。実際、ディフェンス中は、自分のテストや評価している同期のテストを自由に使用できます。 -- 指定されたGitリポジトリに作業を提出してください。Gitリポジトリ内の作業のみが採点されます。Deepthoughtがあなたの作業を採点するよう割り当てられている場合、それはピア評価の後に行われます。Deepthoughtの採点中にあなたの作業のいずれかのセクションでエラーが発生した場合、評価は停止します。 - ---- - -## 第III章:AI指示 - -### ● コンテキスト - -学習の過程で、AIは多くの異なるタスクを支援できます。AIツールの様々な機能と、それらがあなたの作業をどのようにサポートできるかを探求する時間を取ってください。ただし、常に注意を払い、結果を批判的に評価してアプローチしてください。コード、ドキュメント、アイデア、技術的な説明のいずれであっても、あなたの質問が適切に形成されていたか、生成されたコンテンツが正確であるかを完全に確信することはできません。あなたの同期は、間違いや盲点を避けるのに役立つ貴重なリソースです。 - -### ● 主なメッセージ - -☛ 反復的または退屈なタスクを減らすためにAIを使用してください。 - -☛ 将来のキャリアに役立つプロンプティングスキル(コーディングと非コーディングの両方)を開発してください。 - -☛ 一般的なリスク、バイアス、倫理的問題をより良く予測し回避するために、AIシステムがどのように機能するかを学んでください。 - -☛ 同期と協力して、技術的スキルとパワースキルの両方を構築し続けてください。 - -☛ 完全に理解し、責任を取れるAI生成コンテンツのみを使用してください。 - -### ● 学習者のルール: - -- AIツールを探求し、それらがどのように機能するかを理解する時間を取るべきです。そうすることで、倫理的に使用し、潜在的なバイアスを減らすことができます。 -- プロンプトを書く前に問題について考えるべきです。これにより、正確な語彙を使用して、より明確で、より詳細で、より関連性の高いプロンプトを書くのに役立ちます。 -- AIによって生成されたものを体系的にチェック、レビュー、質問、テストする習慣を身につけるべきです。 -- 常にピアレビューを求めるべきです。自分の検証だけに頼らないでください。 - -### ● フェーズの成果: - -- 汎用およびドメイン固有のプロンプティングスキルを開発する。 -- AIツールの効果的な使用で生産性を向上させる。 -- 計算的思考、問題解決、適応性、協力を強化し続ける。 - -### ● コメントと例: - -- 試験、評価など、実際の理解を示さなければならない状況に定期的に遭遇します。準備をして、技術的スキルと対人スキルの両方を構築し続けてください。 -- 同期と推論を説明し議論することで、理解のギャップが明らかになることがよくあります。ピアラーニングを優先してください。 -- AIツールはあなたの特定のコンテキストを欠いていることが多く、一般的な回答を提供する傾向があります。あなたの環境を共有する同期は、より関連性が高く正確な洞察を提供できます。 -- AIが最も可能性の高い答えを生成する傾向がある一方で、同期は代替の視点と貴重なニュアンスを提供できます。品質チェックポイントとして彼らに頼ってください。 - -**✓ 良い実践:** 私はAIに尋ねます:「ソート関数をどのようにテストしますか?」いくつかのアイデアをくれます。それらを試して、同期と結果をレビューします。一緒にアプローチを改善します。 - -**✗ 悪い実践:** 私はAIに関数全体を書くように頼み、プロジェクトにコピペします。ピア評価中、それが何をするか、なぜそうするかを説明できません。信頼性を失い、プロジェクトに失敗します。 - -**✓ 良い実践:** 私はパーサーの設計を助けるためにAIを使用します。その後、同期とロジックを確認します。2つのバグを発見し、一緒に書き直します。より良く、よりクリーンに、完全に理解されています。 - -**✗ 悪い実践:** 私はCopilotにプロジェクトの重要な部分のコードを生成させます。コンパイルは通りますが、パイプをどのように処理するかを説明できません。評価中、正当化できず、プロジェクトに失敗します。 - ---- - -## 第IV章:必須パート - miniRT - -| 項目 | 内容 | -| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| プログラム名 | miniRT | -| 提出ファイル | すべてのファイル | -| Makefile | all, clean, fclean, re, bonus | -| 引数 | *.rt形式のシーン | -| 外部関数 | • open, close, read, write, printf, malloc, free, perror, strerror, exit. • 数学ライブラリのすべての関数。(manページ:man math.hまたはman 3 math。-lmフラグでコンパイルすることを忘れずに)。 • MinilibXライブラリのすべての関数。 • gettimeofday() | -| Libft許可 | はい | -| 説明 | あなたのプログラムの目標は、レイトレーシングプロトコルを使用して画像を生成することです。これらのコンピュータ生成画像は、それぞれシンプルな幾何学的オブジェクトによって定義され、独自の照明システムを持つ、特定の角度と位置から見たシーンを表します。 | - -制約は以下の通りです: -- オペレーティングシステムで利用可能なバージョン、またはそのソースから、**miniLibX**ライブラリを使用しなければなりません。ソースで作業することを選択した場合、共通指示パートで上記に書かれたlibftと同じルールを適用する必要があります。 -- ウィンドウの管理は流動的でなければなりません:別のウィンドウへの切り替え、最小化など。 -- 少なくとも3つのシンプルな幾何学的オブジェクトが必要です:**平面、球、円柱**。 -- 該当する場合、すべての可能な交差とオブジェクトの内部は正しく処理されなければなりません。 -- あなたのプログラムは、オブジェクトの固有のプロパティをリサイズできなければなりません:球の直径、円柱の幅と高さ。 -- あなたのプログラムは、オブジェクト、ライト、カメラに平行移動と回転変換を適用できなければなりません(回転できない球とライトを除く)。 - -- ライト管理:スポットの明るさ、ハードシャドウ、環境光(オブジェクトは決して完全に暗闇になりません)。環境光と拡散光を実装しなければなりません。 - -- プログラムはウィンドウに画像を表示し、以下のルールを尊重します: - - **ESC**を押すと、ウィンドウを閉じてプログラムをきれいに終了しなければなりません。 - - ウィンドウフレームの赤い×をクリックすると、ウィンドウを閉じてプログラムをきれいに終了しなければなりません。 - - minilibXライブラリの**images**の使用を強く推奨します。 -- あなたのプログラムは、**.rt**拡張子を持つシーン記述ファイルを最初の引数として受け取らなければなりません。 - - 各タイプの要素は、1つ以上の改行で区切ることができます。 - - 要素からの各タイプの情報は、1つ以上のスペースで区切ることができます。 - - 各タイプの要素は、ファイル内で任意の順序で設定できます。 - - 大文字で定義される要素は、シーン内で一度だけ宣言できます。 - - 各要素の最初の情報は、タイプ識別子(1文字または2文字で構成)であり、その後に以下のような厳密な順序で各オブジェクトのすべての固有情報が続きます: - -**○ 環境光:** - -``` -A 0.2 255,255,255 -``` -- 識別子:**A** -- [0.0,1.0]の範囲の環境光比率:**0.2** -- [0-255]の範囲のR, G, B色:**255, 255, 255** - -**○ カメラ:** - -``` -C -50.0,0,20 0,0,1 70 -``` -- 識別子:**C** -- 視点のx, y, z座標:**-50.0,0,20** -- 各x, y, z軸について[-1,1]の範囲の3D正規化方向ベクトル:**0.0,0.0,1.0** -- FOV:[0,180]の範囲の度数による水平視野角:**70** - -**○ ライト:** - -``` -L -40.0,50.0,0.0 0.6 10,0,255 -``` -- 識別子:**L** -- ライトポイントのx, y, z座標:**-40.0,50.0,0.0** -- [0.0,1.0]の範囲のライト明るさ比率:**0.6** -- (必須パートでは未使用)[0-255]の範囲のR, G, B色:**10, 0, 255** - -**○ 球:** - -``` -sp 0.0,0.0,20.6 12.6 10,0,255 -``` - -- 識別子:**sp** -- 球の中心のx, y, z座標:**0.0,0.0,20.6** -- 球の直径:**12.6** -- [0-255]の範囲のR,G,B色:**10, 0, 255** - -**○ 平面:** - -``` -pl 0.0,0.0,-10.0 0.0,1.0,0.0 0,0,225 -``` - -- 識別子:**pl** -- 平面上の点のx, y, z座標:**0.0,0.0,-10.0** -- 各x, y, z軸について[-1,1]の範囲の3D正規化法線ベクトル:**0.0,1.0,0.0** -- [0-255]の範囲のR,G,B色:**0,0,225** - -**○ 円柱:** - -``` -cy 50.0,0.0,20.6 0.0,0.0,1.0 14.2 21.42 10,0,255 -``` - -- 識別子:**cy** -- 円柱の中心のx, y, z座標:**50.0,0.0,20.6** -- 各x, y, z軸について[-1,1]の範囲の円柱の軸の3D正規化ベクトル:**0.0,0.0,1.0** -- 円柱の直径:**14.2** -- 円柱の高さ:**21.42** -- [0,255]の範囲のR, G, B色:**10, 0, 255** -- 必須パートの最小限の.rtシーンの例: - -``` -A 0.2 255,255,255 - -C -50,0,20 0,0,1 70 -L -40,0,30 0.7 255,255,255 - -pl 0,0,0 0,1.0,0 255,0,225 -sp 0,0,20 20 255,0,0 -cy 50.0,0.0,20.6 0,0,1.0 14.2 21.42 10,0,255 -``` - -- ファイル内で何らかの設定ミスが発生した場合、プログラムは適切に終了し、「Error\n」の後にあなたが選んだ明示的なエラーメッセージを返さなければなりません。 -- ディフェンスのために、作成する要素の制御を容易にするために、機能しているものに焦点を当てたシーンのセット全体を持っていることが理想的です。 - ---- - -## 第V章:ボーナスパート - -レイトレーシング技術は、反射、透明度、屈折、より複雑なオブジェクト、ソフトシャドウ、コースティクス、グローバルイルミネーション、バンプマッピング、.objファイルレンダリングなど、さらに多くのものを処理できます。 - -しかし、miniRTプロジェクトでは、あなたの最初のレイトレーサーとCGIでの最初のステップのために、物事をシンプルに保ちたいと思います。 - -より大きなボーナスをやりたい場合は、この小さなものが完成して完全に機能した後、開発者人生の後半で新しいレイトレーサーを再コーディングすることを強くお勧めします。 - -_図V.1: スポット、宇宙のスカイボックス、バンプマッピングを施した光沢のある地球テクスチャの球_ - -> ⚠️ **ボーナスは、必須パートが完璧な場合にのみ評価されます。** 完璧とは、当然ながら完全である必要があり、間違った使用法などの厄介なミスの場合でも失敗しないことを意味します。つまり、採点中に必須パートがすべてのポイントを獲得しなかった場合、ボーナスは完全に無視されます。 - -**ボーナスリスト:** - -- 完全なPhong反射モデルを達成するためにスペキュラ反射を追加する。 -- 色の変化:チェッカーボードパターン。 -- 色付きおよびマルチスポットライト。 -- もう1つの二次曲面オブジェクト:円錐、双曲面、放物面など。 -- バンプマップテクスチャを処理する。 - -> ℹ️ ボーナスパートを完了するために、他の関数を使用したり、シーン記述に機能を追加したりすることが許可されています。ただし、評価中にその使用が正当化される場合に限ります。また、ニーズに合わせて期待されるシーンファイル形式を変更することも許可されています。賢くなってください! - ---- - -## 第VI章:例 - -_図VI.1: 球、1つのスポット、少しの輝き(オプション)。_ - -_図VI.2: 円柱、1つのスポット。_ - -_図VI.3: 円錐(オプション)、平面、1つのスポット。_ - -_図VI.4: すべてが少しずつ、2つの平面を含む。_ - -_図VI.5: 同じシーン、異なるカメラ。_ - -_図VI.6: 今回は影付き。_ - -_図VI.7: 複数のスポット付き。_ - -_図VI.8: そして最後に、複数のスポットと中央の光沢のあるチェッカー(オプション)球。_ diff --git a/scenes/error/error_ambient_ratio.rt b/scenes/error/error_ambient_ratio.rt deleted file mode 100644 index 140540b..0000000 --- a/scenes/error/error_ambient_ratio.rt +++ /dev/null @@ -1,7 +0,0 @@ -A 1.2 255,255,255 -C -50,0,20 0,0,1 70 -L -40,0,30 0.7 255,255,255 - -pl 0,0,0 0,1.0,0 255,0,225 -sp 0,0,20 20 255,0,0 -cy 50.0,0.0,20.6 0,0,1.0 14.2 21.42 10,0,255 diff --git a/scenes/error/error_consecutive_commas.rt b/scenes/error/error_consecutive_commas.rt deleted file mode 100644 index e790f36..0000000 --- a/scenes/error/error_consecutive_commas.rt +++ /dev/null @@ -1,7 +0,0 @@ -A 0.2 255,255,255 -C -50,,0,20 0,0,1 70 -L -40,0,30 0.7 255,255,255 - -pl 0,0,0 0,1.0,0 255,0,225 -sp 0,0,20 20 255,0,0 -cy 50.0,0.0,20.6 0,0,1.0 14.2 21.42 10,0,255 diff --git a/scenes/error/error_duplicate_element.rt b/scenes/error/error_duplicate_element.rt deleted file mode 100644 index bfcf725..0000000 --- a/scenes/error/error_duplicate_element.rt +++ /dev/null @@ -1,9 +0,0 @@ -A 0.2 255,255,255 -A 0.3 200,200,200 - -C -50,0,20 0,0,1 70 -L -40,0,30 0.7 255,255,255 - -pl 0,0,0 0,1.0,0 255,0,225 -sp 0,0,20 20 255,0,0 -cy 50.0,0.0,20.6 0,0,1.0 14.2 21.42 10,0,255 diff --git a/scenes/error/error_empty_identifier.rt b/scenes/error/error_empty_identifier.rt deleted file mode 100644 index 684814d..0000000 --- a/scenes/error/error_empty_identifier.rt +++ /dev/null @@ -1,7 +0,0 @@ -A 0.2 255,255,255 -C -50,0,20 0,0,1 70 -L -40,0,30 0.7 255,255,255 - -pl 0,0,0 0,1.0,0 255,0,225 - 0,0,20 20 255,0,0 -cy 50.0,0.0,20.6 0,0,1.0 14.2 21.42 10,0,255 diff --git a/scenes/error/error_empty_lines.rt b/scenes/error/error_empty_lines.rt deleted file mode 100644 index a50ccd6..0000000 --- a/scenes/error/error_empty_lines.rt +++ /dev/null @@ -1,9 +0,0 @@ -A 0.2 255,255,255 -C -50,0,20 0,0,1 70 -L -40,0,30 0.7 255,255,255 - -pl 0,0,0 0,1.0,0 255,0,225 - -sp 0,0,20 20 255,0,0 - -cy 50.0,0.0,20.6 0,0,1.0 14.2 21.42 10,0,255 diff --git a/scenes/error/error_fov_range.rt b/scenes/error/error_fov_range.rt deleted file mode 100644 index 053a4e5..0000000 --- a/scenes/error/error_fov_range.rt +++ /dev/null @@ -1,7 +0,0 @@ -A 0.2 255,255,255 -C -50,0,20 0,0,1 190 -L -40,0,30 0.7 255,255,255 - -pl 0,0,0 0,1.0,0 255,0,225 -sp 0,0,20 20 255,0,0 -cy 50.0,0.0,20.6 0,0,1.0 14.2 21.42 10,0,255 diff --git a/scenes/error/error_invalid_identifier.rt b/scenes/error/error_invalid_identifier.rt deleted file mode 100644 index e1adff3..0000000 --- a/scenes/error/error_invalid_identifier.rt +++ /dev/null @@ -1,7 +0,0 @@ -A 0.2 255,255,255 -C -50,0,20 0,0,1 70 -L -40,0,30 0.7 255,255,255 - -pl 0,0,0 0,1.0,0 255,0,225 -sp 0,0,20 20 255,0,0 -XX 50.0,0.0,20.6 0,0,1.0 14.2 21.42 10,0,255 diff --git a/scenes/error/error_missing_camera.rt b/scenes/error/error_missing_camera.rt deleted file mode 100644 index 0cdcbae..0000000 --- a/scenes/error/error_missing_camera.rt +++ /dev/null @@ -1,7 +0,0 @@ -A 0.2 255,255,255 - -L -40,0,30 0.7 255,255,255 - -pl 0,0,0 0,1.0,0 255,0,225 -sp 0,0,20 20 255,0,0 -cy 50.0,0.0,20.6 0,0,1.0 14.2 21.42 10,0,255 diff --git a/scenes/error/error_missing_parameter.rt b/scenes/error/error_missing_parameter.rt deleted file mode 100644 index 87c7b75..0000000 --- a/scenes/error/error_missing_parameter.rt +++ /dev/null @@ -1,7 +0,0 @@ -A 0.2 255,255,255 -C -50,0,20 0,0,1 70 -L -40,0,30 0.7 255,255,255 - -pl 0,0,0 0,1.0,0 255,0,225 -sp 0,0,20 20 255,0,0 -cy 50.0,0.0,20.6 0,0,1.0 14.2 10,0,255 diff --git a/scenes/error/error_multiple_signs.rt b/scenes/error/error_multiple_signs.rt deleted file mode 100644 index b3d842d..0000000 --- a/scenes/error/error_multiple_signs.rt +++ /dev/null @@ -1,7 +0,0 @@ -A 0.2 255,255,255 -C -50,0,20 0,0,1 70 -L -40,0,30 0.7 255,255,255 - -pl 0,0,0 0,1.0,0 255,0,225 -sp 0,0,20 --10 255,0,0 -cy 50.0,0.0,20.6 0,0,1.0 14.2 21.42 10,0,255 diff --git a/scenes/error/error_negative_diameter.rt b/scenes/error/error_negative_diameter.rt deleted file mode 100644 index d01df47..0000000 --- a/scenes/error/error_negative_diameter.rt +++ /dev/null @@ -1,7 +0,0 @@ -A 0.2 255,255,255 -C -50,0,20 0,0,1 70 -L -40,0,30 0.7 255,255,255 - -pl 0,0,0 0,1.0,0 255,0,225 -sp 0,0,20 -20 255,0,0 -cy 50.0,0.0,20.6 0,0,1.0 14.2 21.42 10,0,255 diff --git a/scenes/error/error_negative_height.rt b/scenes/error/error_negative_height.rt deleted file mode 100644 index eb7233e..0000000 --- a/scenes/error/error_negative_height.rt +++ /dev/null @@ -1,6 +0,0 @@ -A 0.2 255,255,255 -C -50,0,20 0,0,1 70 -L -40,0,30 0.7 255,255,255 -pl 0,0,0 0,1.0,0 255,0,225 -sp 0,0,20 20 255,0,0 -cy 50.0,0.0,20.6 0,0,1.0 14.2 -21.42 10,0,255 diff --git a/scenes/error/error_no_objects.rt b/scenes/error/error_no_objects.rt deleted file mode 100644 index 6ff71f1..0000000 --- a/scenes/error/error_no_objects.rt +++ /dev/null @@ -1,3 +0,0 @@ -A 0.2 255,255,255 -C -50,0,20 0,0,1 70 -L -40,0,30 0.7 255,255,255 diff --git a/scenes/error/error_non_normalized_vector.rt b/scenes/error/error_non_normalized_vector.rt deleted file mode 100644 index 7803e19..0000000 --- a/scenes/error/error_non_normalized_vector.rt +++ /dev/null @@ -1,7 +0,0 @@ -A 0.2 255,255,255 -C -50,0,20 0,0,2 70 -L -40,0,30 0.7 255,255,255 - -pl 0,0,0 0,1.0,0 255,0,225 -sp 0,0,20 20 255,0,0 -cy 50.0,0.0,20.6 0,0,1.0 14.2 21.42 10,0,255 diff --git a/scenes/error/error_non_numeric.rt b/scenes/error/error_non_numeric.rt deleted file mode 100644 index 236ed30..0000000 --- a/scenes/error/error_non_numeric.rt +++ /dev/null @@ -1,7 +0,0 @@ -A 0.2 255,255,255 -C -50,0,20 0,0,1 70 -L -40,0,30 0.7 255,255,255 - -pl 0,0,0 0,1.0,0 255,0,225 -sp 0,0,20 x 255,0,0 -cy 50.0,0.0,20.6 0,0,1.0 14.2 21.42 10,0,255 diff --git a/scenes/error/error_rgb_format.rt b/scenes/error/error_rgb_format.rt deleted file mode 100644 index bb65bae..0000000 --- a/scenes/error/error_rgb_format.rt +++ /dev/null @@ -1,7 +0,0 @@ -A 0.2 255 255 255 -C -50,0,20 0,0,1 70 -L -40,0,30 0.7 255,255,255 - -pl 0,0,0 0,1.0,0 255,0,225 -sp 0,0,20 20 255,0,0 -cy 50.0,0.0,20.6 0,0,1.0 14.2 21.42 10,0,255 diff --git a/scenes/error/error_rgb_range.rt b/scenes/error/error_rgb_range.rt deleted file mode 100644 index aec5f65..0000000 --- a/scenes/error/error_rgb_range.rt +++ /dev/null @@ -1,7 +0,0 @@ -A 0.2 300,255,255 -C -50,0,20 0,0,1 70 -L -40,0,30 0.7 255,255,255 - -pl 0,0,0 0,1.0,0 255,0,225 -sp 0,0,20 20 255,0,0 -cy 50.0,0.0,20.6 0,0,1.0 14.2 21.42 10,0,255 diff --git a/scenes/error/error_trailing_comma.rt b/scenes/error/error_trailing_comma.rt deleted file mode 100644 index 13379f6..0000000 --- a/scenes/error/error_trailing_comma.rt +++ /dev/null @@ -1,7 +0,0 @@ -A 0.2 255,255,255, -C -50,0,20, 0,0,1 70 -L -40,0,30 0.7 255,255,255 - -pl 0,0,0 0,1.0,0, 255,0,225 -sp 0,0,20 20 255,0,0 -cy 50.0,0.0,20.6 0,0,1.0 14.2 21.42 10,0,255, diff --git a/scenes/error/error_zero_sequence.rt b/scenes/error/error_zero_sequence.rt deleted file mode 100644 index 31a8bf5..0000000 --- a/scenes/error/error_zero_sequence.rt +++ /dev/null @@ -1,7 +0,0 @@ -A 0.2 255,255,255 -C -50,0,20 0,0,1 70 -L -40,0,30 0.7 255,255,255 - -pl 0,0,0 0,1.0,0 255,0,225 -sp 0,0,20 20.000 255,0,0 -cy 50.0,000.0,20.6 0,0,1.0 14.2 21.42 10,0,255 diff --git a/scenes/test/camera_all_negative.rt b/scenes/test/camera_all_negative.rt deleted file mode 100644 index 612eb64..0000000 --- a/scenes/test/camera_all_negative.rt +++ /dev/null @@ -1,5 +0,0 @@ -A 0.3 255,255,255 -C 10,10,10 -0.577,-0.577,-0.577 60 -L 10,10,-10 0.8 255,255,255 - -sp 0,0,0 10 0,255,0 diff --git a/scenes/test/camera_negative_dir.rt b/scenes/test/camera_negative_dir.rt deleted file mode 100644 index cbc78cc..0000000 --- a/scenes/test/camera_negative_dir.rt +++ /dev/null @@ -1,5 +0,0 @@ -A 0.3 255,255,255 -C 0,0,20 0,0,-1 60 -L 10,10,-10 0.8 255,255,255 - -sp 0,0,0 10 255,0,0 diff --git a/scenes/test/camera_out_of_range.rt b/scenes/test/camera_out_of_range.rt deleted file mode 100644 index f058f8a..0000000 --- a/scenes/test/camera_out_of_range.rt +++ /dev/null @@ -1,5 +0,0 @@ -A 0.3 255,255,255 -C 0,0,20 0,0,-1.5 60 -L 10,10,-10 0.8 255,255,255 - -sp 0,0,0 10 255,0,0 diff --git a/scenes/test/multiple_spaces.rt b/scenes/test/multiple_spaces.rt deleted file mode 100644 index b154586..0000000 --- a/scenes/test/multiple_spaces.rt +++ /dev/null @@ -1,6 +0,0 @@ -A 0.2 255,255,255 - -C -50,0,20 0,0,1 70 -L -40,0,30 0.7 255,255,255 - -sp 0,0,20 20 255,0,0 diff --git a/scenes/valid/complex_scene.rt b/scenes/valid/complex_scene.rt deleted file mode 100644 index 6062e43..0000000 --- a/scenes/valid/complex_scene.rt +++ /dev/null @@ -1,15 +0,0 @@ -A 0.1 255,255,200 - -C 0,10,50 0,-0.099504,-0.995037 80 -L 20,20,20 0.9 255,240,220 - -pl 0,0,0 0,1,0 200,200,200 -pl -30,0,0 1,0,0 150,180,200 - -sp -15,5,10 10 200,50,50 -sp 0,5,0 8 50,200,50 -sp 15,5,10 10 50,50,200 - -cy -15,0,-10 0,1,0 5 15 200,100,50 -cy 0,0,-10 0,1,0 5 15 100,200,50 -cy 15,0,-10 0,1,0 5 15 50,100,200 diff --git a/scenes/valid/example.rt b/scenes/valid/example.rt deleted file mode 100644 index f29fda0..0000000 --- a/scenes/valid/example.rt +++ /dev/null @@ -1,6 +0,0 @@ -A 0.3 255,255,255 -C 0,0,-20 0,0,1 60 -L 10,10,-10 0.8 255,255,255 - -cy 0,0,0 0,1,0 5 15 200,100,50 -pl 0,-6,0 0,1,0 120,120,120 diff --git a/scenes/valid/sphere_only_blue.rt b/scenes/valid/sphere_only_blue.rt deleted file mode 100644 index 5a7a802..0000000 --- a/scenes/valid/sphere_only_blue.rt +++ /dev/null @@ -1,6 +0,0 @@ -A 0.3 255,255,255 -C 0,0,-20 0,0,1 60 -L 10,10,-10 0.8 255,255,255 - -sp 0,0,0 10 0,0,255 -pl 0,-6,0 0,1,0 120,120,120 diff --git a/scenes/valid/sphere_only_green.rt b/scenes/valid/sphere_only_green.rt deleted file mode 100644 index faf9a59..0000000 --- a/scenes/valid/sphere_only_green.rt +++ /dev/null @@ -1,6 +0,0 @@ -A 0.3 255,255,255 -C 0,0,-20 0,0,1 60 -L 10,10,-10 0.8 255,255,255 - -sp 0,0,0 10 0,255,0 -pl 0,-6,0 0,1,0 120,120,120 diff --git a/scenes/valid/sphere_only_red.rt b/scenes/valid/sphere_only_red.rt deleted file mode 100644 index 4c863c7..0000000 --- a/scenes/valid/sphere_only_red.rt +++ /dev/null @@ -1,6 +0,0 @@ -A 0.3 0,0,0 -C 0,0,-20 0,0,1 60 -L 10,10,-10 0.8 255,255,255 - -sp 0,0,0 10 255,0,0 -pl 0,-6,0 0,1,0 120,120,120 \ No newline at end of file diff --git a/scenes/valid/valid_scene.rt b/scenes/valid/valid_scene.rt deleted file mode 100644 index 9214d31..0000000 --- a/scenes/valid/valid_scene.rt +++ /dev/null @@ -1,8 +0,0 @@ -A 0.3 200,200,255 - -C -30,5,15 1,0,0 90 -L -20,10,25 0.8 255,255,255 - -pl 0,0,-5 0,0,1 120,120,200 -sp 10,0,10 15 255,100,100 -cy 0,5,15 0,1.0,0 10 18.2 100,200,100 diff --git a/srcs/debug/print_context.c b/srcs/debug/print_context.c deleted file mode 100644 index d05eb2c..0000000 --- a/srcs/debug/print_context.c +++ /dev/null @@ -1,52 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* print_context.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: stakada +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2026/02/13 19:01:06 by stakada #+# #+# */ -/* Updated: 2026/02/13 19:14:39 by stakada ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "miniRT.h" - -static const char *get_edit_mode_str(t_edit_mode mode) -{ - if (mode == MODE_CAMERA) - return ("Camera"); - else if (mode == MODE_LIGHT) - return ("Light"); - else if (mode == MODE_OBJECT) - return ("Object"); - return ("Unknown"); -} - -static const char *get_selected_object_str(t_obj_type type) -{ - if (type == SPHERE) - return ("Sphere"); - else if (type == PLANE) - return ("Plane"); - else if (type == CYLINDER) - return ("Cylinder"); - return ("Unknown"); -} - -void print_context(t_ctx *ctx) -{ - if (!ctx) - { - printf("Error: Context is NULL\n"); - return ; - } - printf("\n===== Context Information =====\n\n"); - printf("Edit Mode: %s\n", get_edit_mode_str(ctx->edit_mode)); - if (ctx->edit_mode == MODE_OBJECT && ctx->selected_object) - printf("Selected Object Type: %s\n", - get_selected_object_str(ctx->selected_object->type)); - printf("\n--- Scene Information ---\n\n"); - print_scene(ctx->scene); - printf("\n=============================\n\n"); -} diff --git a/srcs/debug/print_objects.c b/srcs/debug/print_objects.c deleted file mode 100644 index 0cc7e2f..0000000 --- a/srcs/debug/print_objects.c +++ /dev/null @@ -1,60 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* print_objects.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: stakada +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2025/08/28 22:14:33 by stakada #+# #+# */ -/* Updated: 2026/02/13 18:42:18 by stakada ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "miniRT.h" - -static void print_sphere(t_sphere *sphere) -{ - printf("Sphere:\n"); - print_vec3(" Center", sphere->center); - printf(" Diameter: %.2f\n", sphere->diameter); - print_color(" Color", sphere->color); -} - -static void print_plane(t_plane *plane) -{ - printf("Plane:\n"); - print_vec3(" Point", plane->point); - print_vec3(" Normal", plane->normal); - print_color(" Color", plane->color); -} - -static void print_cylinder(t_cylinder *cylinder) -{ - printf("Cylinder:\n"); - print_vec3(" Center", cylinder->center); - print_vec3(" Axis", cylinder->axis); - printf(" Diameter: %.2f\n", cylinder->diameter); - printf(" Height: %.2f\n", cylinder->height); - print_color(" Color", cylinder->color); -} - -void print_objects(t_obj *objects) -{ - t_obj *current; - int count; - - current = objects; - count = 0; - printf("Objects List:\n"); - while (current) - { - printf("Object %d:\n", ++count); - if (current->type == SPHERE) - print_sphere((t_sphere *)current->obj_data); - else if (current->type == PLANE) - print_plane((t_plane *)current->obj_data); - else if (current->type == CYLINDER) - print_cylinder((t_cylinder *)current->obj_data); - current = current->next; - } -} diff --git a/srcs/debug/print_scene.c b/srcs/debug/print_scene.c deleted file mode 100644 index d9e2e67..0000000 --- a/srcs/debug/print_scene.c +++ /dev/null @@ -1,52 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* print_scene.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: stakada +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2025/08/28 22:15:34 by stakada #+# #+# */ -/* Updated: 2026/02/13 19:04:24 by stakada ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "miniRT.h" - -static void print_ambient(t_ambient ambient) -{ - printf("Ambient Light:\n"); - printf(" Ratio: %.2f\n", ambient.ratio); - print_color(" Color", ambient.color); -} - -static void print_camera(t_camera camera) -{ - printf("Camera:\n"); - print_vec3(" Position", camera.position); - print_vec3(" Direction", camera.direction); - printf(" FOV: %.2f\n", camera.fov_deg); -} - -static void print_light(t_light light) -{ - printf("Light:\n"); - print_vec3(" Position", light.position); - printf(" Brightness: %.2f\n", light.brightness); - print_color(" Color", light.color); -} - -void print_scene(t_scene *scene) -{ - if (!scene) - { - printf("Error: Scene is NULL\n"); - return ; - } - print_ambient(scene->ambient); - printf("\n"); - print_camera(scene->camera); - printf("\n"); - print_light(scene->light); - printf("\n"); - print_objects(scene->objects); -} diff --git a/srcs/debug/print_utils.c b/srcs/debug/print_utils.c deleted file mode 100644 index 4e16da3..0000000 --- a/srcs/debug/print_utils.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* print_utils.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: stakada +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2025/08/28 22:11:37 by stakada #+# #+# */ -/* Updated: 2026/02/13 21:31:46 by stakada ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "miniRT.h" - -void print_vec3(const char *prefix, t_vec3 vec) -{ - printf("%s: (%.2f, %.2f, %.2f)\n", prefix, vec.x, vec.y, vec.z); -} - -void print_color(const char *prefix, t_rgb color) -{ - printf("%s: (%.2d, %.2d, %.2d)\n", prefix, color.red, color.green, - color.blue); -} diff --git a/srcs/free.c b/srcs/free.c index aa53e96..087ffe6 100644 --- a/srcs/free.c +++ b/srcs/free.c @@ -12,27 +12,26 @@ #include "miniRT.h" -void free_scene(t_scene *scene) +void free_scene(t_scene **scene) { t_obj *current; t_obj *next; - if (scene) + if (!scene || !*scene) + return ; + if ((*scene)->objects) { - if (scene->objects) + current = (*scene)->objects; + while (current) { - current = scene->objects; - while (current) - { - next = current->next; - free(current->obj_data); - free(current); - current = next; - } + next = current->next; + free(current->obj_data); + free(current); + current = next; } - free(scene); } - scene = NULL; + free(*scene); + *scene = NULL; } void free_ctx(t_ctx *ctx) @@ -42,6 +41,6 @@ void free_ctx(t_ctx *ctx) if (ctx->img) free(ctx->img); if (ctx->scene) - free_scene(ctx->scene); + free_scene(&ctx->scene); free(ctx); } diff --git a/srcs/key_handler.c b/srcs/key_handler.c index 5f7d1e1..5736879 100644 --- a/srcs/key_handler.c +++ b/srcs/key_handler.c @@ -6,7 +6,7 @@ /* By: stakada +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/01/10 20:00:00 by kinamura #+# #+# */ -/* Updated: 2026/02/15 03:13:07 by stakada ### ########.fr */ +/* Updated: 2026/02/23 10:43:59 by stakada ### ########.fr */ /* */ /* ************************************************************************** */ @@ -77,12 +77,12 @@ static int get_rotate_params(int keycode, t_vec3 *axis, double *angle) static int get_adjust_params(int keycode, int *sign, int *height_mode) { - if (keycode == KEY_PLUS) + if (keycode == KEY_P) { *sign = 1; *height_mode = 0; } - else if (keycode == KEY_MINUS) + else if (keycode == KEY_M) { *sign = -1; *height_mode = 0; diff --git a/srcs/parsing/object_list.c b/srcs/parsing/object_list.c index ab8abdc..7728139 100644 --- a/srcs/parsing/object_list.c +++ b/srcs/parsing/object_list.c @@ -19,7 +19,7 @@ t_obj *create_object_node(t_obj_type type, void *obj) node = (t_obj *)malloc(sizeof(t_obj)); if (!node) { - perror(""); + print_error(ERR_MSG_MALLOC); return (NULL); } node->type = type; diff --git a/srcs/parsing/parse.c b/srcs/parsing/parse.c index 9622f01..b2c117c 100644 --- a/srcs/parsing/parse.c +++ b/srcs/parsing/parse.c @@ -110,12 +110,12 @@ t_scene *parse_scene(char *filename) read_flags = 0; if (parse_file(filename, scene, &read_flags) < 0) { - free_scene(scene); + free_scene(&scene); return (NULL); } if (!validate_scene(read_flags)) { - free_scene(scene); + free_scene(&scene); return (NULL); } return (scene); diff --git a/srcs/parsing/validate_values.c b/srcs/parsing/validate_values.c index f64caff..b4f8b30 100644 --- a/srcs/parsing/validate_values.c +++ b/srcs/parsing/validate_values.c @@ -42,7 +42,7 @@ int validate_normalized_vec3(t_vec3 vec) double len_squared; len_squared = vec3_dot(vec, vec); - if (fabs(len_squared - 1.0) > EPSILON) + if (fabs(len_squared - 1.0) > NORM_EPSILON) return (INVALID); return (VALID); } diff --git a/srcs/put_info.c b/srcs/put_info.c index 2ec483b..16a8fb6 100644 --- a/srcs/put_info.c +++ b/srcs/put_info.c @@ -6,7 +6,7 @@ /* By: stakada +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/02/15 00:30:30 by stakada #+# #+# */ -/* Updated: 2026/02/15 02:18:32 by stakada ### ########.fr */ +/* Updated: 2026/02/23 10:44:25 by stakada ### ########.fr */ /* */ /* ************************************************************************** */ @@ -34,7 +34,7 @@ static void put_camera_info(t_ctx *ctx) mlx_string_put(ctx->mlx, ctx->win, MARGIN, LINE_HEIGHT * 6, TEXT_COLOR, " Rotate: Arrow keys"); mlx_string_put(ctx->mlx, ctx->win, MARGIN, LINE_HEIGHT * 7, TEXT_COLOR, - " FOV: + (Increase), - (Decrease)"); + " FOV: P (Increase), M (Decrease)"); } static void put_light_info(t_ctx *ctx) @@ -46,7 +46,7 @@ static void put_light_info(t_ctx *ctx) mlx_string_put(ctx->mlx, ctx->win, MARGIN, LINE_HEIGHT * 5, TEXT_COLOR, " Move: W, A, S, D, Q, E"); mlx_string_put(ctx->mlx, ctx->win, MARGIN, LINE_HEIGHT * 6, TEXT_COLOR, - " Brightness: + (Increase), - (Decrease)"); + " Brightness: P (Increase), M (Decrease)"); } static void put_object_info(t_ctx *ctx) @@ -72,7 +72,7 @@ static void put_object_info(t_ctx *ctx) if (ctx->selected_object->type == SPHERE || ctx->selected_object->type == CYLINDER) mlx_string_put(ctx->mlx, ctx->win, MARGIN, LINE_HEIGHT * line++, - TEXT_COLOR, " Diameter: + (Increase), - (Decrease)"); + TEXT_COLOR, " Diameter: P (Increase), M (Decrease)"); if (ctx->selected_object->type == CYLINDER) mlx_string_put(ctx->mlx, ctx->win, MARGIN, LINE_HEIGHT * line++, TEXT_COLOR, " Height: H (Increase), J (Decrease)"); diff --git a/srcs/render/render.c b/srcs/render/render.c index b37f4d1..b006e95 100644 --- a/srcs/render/render.c +++ b/srcs/render/render.c @@ -6,7 +6,7 @@ /* By: stakada +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/10/22 00:47:58 by kinamura #+# #+# */ -/* Updated: 2026/02/13 20:08:24 by stakada ### ########.fr */ +/* Updated: 2026/02/22 19:05:06 by stakada ### ########.fr */ /* */ /* ************************************************************************** */ @@ -53,7 +53,6 @@ static t_vec3 get_ray_direction(t_camera_frame *frame, int x, int y) return (vec3_normalize(dir)); } -// TODO: delete debug statement (print_context) void render_scene(t_ctx *ctx) { t_camera_frame frame; @@ -64,7 +63,6 @@ void render_scene(t_ctx *ctx) if (!ctx || !ctx->scene || !ctx->img) return ; - print_context(ctx); init_camera_frame(ctx->scene->camera, &frame); y = 0; while (y < WIN_HEIGHT)