port from perforce

This commit is contained in:
2026-04-18 22:31:51 +02:00
commit 8d0ab5b7cc
8409 changed files with 3972376 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
#pragma once
#include <d3dx9.h>
extern IDirect3DDevice9* g_d3d_device;
class TerrainGrid
{
public:
typedef float (TerrainGrid::*iso_surface_function)(const D3DXVECTOR3&);
void Init( int StepsXZ, int StepsY, iso_surface_function pIsoSurface );
void Render();
float IsoSurfaceIsle(const D3DXVECTOR3& pos);
float IsoSurfaceCave(const D3DXVECTOR3& pos);
float IsoSurfaceCaveGround(const D3DXVECTOR3& pos);
private:
typedef struct
{
D3DXVECTOR3 p[3];
} TRIANGLE;
typedef struct
{
D3DXVECTOR3 p[8];
float val[8];
} GRIDCELL;
float PerlinNoise_2D(float x, float y, float scale);
D3DXVECTOR3 VertexInterp(float isolevel, D3DXVECTOR3 p1, D3DXVECTOR3 p2, float valp1, float valp2);
int Polygonise(GRIDCELL grid, float isolevel, TRIANGLE* triangles);
D3DXVECTOR3 GetNormal(D3DXVECTOR3 input, iso_surface_function pIsoSurface);
D3DLOCKED_BOX noiseLock;
int vertexCount;
int indexCount;
IDirect3DVertexDeclaration9* vertexDecl;
IDirect3DIndexBuffer9* indexBuffer;
IDirect3DVertexBuffer9* vertexBuffer;
};
struct TerrainVertex
{
D3DXVECTOR3 pos;
D3DXVECTOR3 normal;
D3DXVECTOR2 tex;
D3DCOLOR col;
};