5

JavaScript で単純な月着陸船のクローンを作成しています ( http://www.isogenicengine.com/demos/1.1.0/lander/ )。高低だけの基本的なランドスケープの代わりに、アルゴリズムが必要です。ランダムな洞窟のような空間を生成します。[0, 0, 1920, 1200] で動作する長方形の領域が与えられると、アルゴリズムは下の画像のようなものを生成できるはずです。理想的には、洞窟エリアへの「入り口」は幅を設定して、ランダーがその「中に」入ることができるようにする必要があります。

ランダー

これは不可能かもしれないと考えました。代わりに、上記のような画像の束を描画し、ピクセル データをラフなポリゴン データに変換することもできますが、レベルをランダムに生成した方がずっとクールです!

超ハードコア ボーナス ポイントの場合、洞窟のような構造物がいくつあるかを指定する機能は、さらに素晴らしいものになるでしょう。

アルゴリズムの出力はポイントの配列であり、各ポイントは x および y プロパティ {x: val, y: val} を含むオブジェクトであり、現在のポイントと次のポイントの間に線を連続して描画すると、ポリゴンが構成されます。 .

誰かが同様の JavaScript 実装を持っている場合、それも大いに役立ちます!

4

2 に答える 2

3

Start with learning what a bubble diagram is as it's used in architecture. It's a topological diagram of a space, with bubbles as the spaces and lines to represent passageways. I didn't find any single great web page to recommend quickly, but doing an image search yields lots of examples.

A bubble diagram can be thought of as a graph with bubbles as vertices. In your example, model the "sky", the blob including the top edge, as a vertex. The cave is another vertex and the entrance is an edge. With this perspective, it's easy to generate as much cave-like complexity as you want.

The next trick is turning it into geometry. Essentially, you want to push out from the skeleton of the graph and make voids where the player can navigate. At the same time, you want to make sure that these voids don't push out too far and thin out or eliminate the walls. So you also need to model the solid area, and that's done with a dual graph. The dual graph goes "underneath" the original, in the sense that edge crossings represent conflict which is resolved in favor of void over solid.

Summarizing: (1) Make a topological graph with the features you want. (2) Create geometry for graph, assigning a location to each vertex and a path to each edge. (3) Construct a dual graph, and assign its geometry. (4) Flesh out the space associated with each graph by growing them outwards, resolving conflicts in favor of passage rather than blockage.

You might want to convince yourself that the perimeter list of the final geometry can be generated by a half-edge traversal of the graph, much like walking a maze with one hand on a wall.

于 2012-11-20T05:16:32.000 に答える
1

興味があれば、マーチング スクエアを使用して、スカラー値の 2D フィールド (おそらくパーリンまたはシンプレックス ノイズから取得) を一連のエッジ ラインに変換できます。もちろん、最終的にどのように見えるかは、2D フィールドのスカラー値を取得する方法 (パーリンまたはシンプレックス ノイズを操作する方法) によって異なります。

これは、詳細をよく調べている私が見つけることができる最高のサイトです. (3D ツインであるマーチング キューブほど文書化されていません)

実際、そのWikiページはかなり優れています。

于 2012-12-10T14:37:30.910 に答える