arx-level-generator
Version:
A tool for creating Arx Fatalis maps
116 lines (115 loc) • 4.59 kB
TypeScript
import { ArxColor, ArxPolygon, ArxPolygonFlags, ArxTextureContainer } from 'arx-convert/types';
import { QuadrupleOf } from 'arx-convert/utils';
import { Box3 } from 'three';
import { Color } from './Color.js';
import { Texture } from './Texture.js';
import { Vector3 } from './Vector3.js';
import { Vertex } from './Vertex.js';
export type TransparencyType = 'multiplicative' | 'additive' | 'blended' | 'subtractive';
type PolygonConfig = {
/** setting this to true will prevent calculation of norm, norm2 and normals properties */
areNormalsCalculated: boolean;
};
type PolygonContructorProps = {
isQuad?: boolean;
vertices: QuadrupleOf<Vertex>;
/** face normal for the 1st half of the polygon enclosed by vertices a, b and c */
norm?: Vector3;
/** face normal for the 2nd half of the polygon enclosed by vertices d, b and c when polygon is a quad */
norm2?: Vector3;
texture?: Texture;
flags?: ArxPolygonFlags;
/** vertex normals */
normals?: QuadrupleOf<Vector3>;
transval?: number;
area?: number;
room?: number;
paddy?: number;
config?: Partial<PolygonConfig>;
};
export declare class Polygon {
vertices: QuadrupleOf<Vertex>;
/** face normal for the 1st half of the polygon enclosed by vertices a, b and c */
norm: Vector3;
/** face normal for the 2nd half of the polygon enclosed by vertices d, b and c when polygon is a quad */
norm2: Vector3;
texture?: Texture;
flags: ArxPolygonFlags;
/** vertex normals */
normals?: QuadrupleOf<Vector3>;
transval: number;
area: number;
room: number;
paddy?: number;
config: PolygonConfig;
constructor(props: PolygonContructorProps);
clone(): Polygon;
static fromArxPolygon(polygon: ArxPolygon, colors: ArxColor[], textures: ArxTextureContainer[], areNormalsCalculated: boolean): Polygon;
hasTexture(): this is {
texture: Texture;
};
toArxPolygon(textureContainers: (ArxTextureContainer & {
remaining: number;
})[]): Promise<ArxPolygon>;
isQuad(): boolean;
isTransparent(): boolean;
calculateNormals(): void;
/**
* @see https://github.com/arx/ArxLibertatis/blob/1.2.1/src/graphics/data/Mesh.cpp#L1100
*/
getNindices(): 3 | 6;
/**
* @see https://github.com/arx/ArxLibertatis/blob/1.2.1/src/graphics/data/Mesh.cpp#L1102
*/
getTransparencyType(): TransparencyType | 'opaque';
setOpacity(percent: number, transparencyType?: TransparencyType): void;
/**
* Quote from Dscharrer:
*
* Looks like this is the "correct" formula for trinagles:
* @see https://github.com/arx/ArxLibertatis/blob/ArxFatalis-1.21/Sources/EERIE/EERIEPoly.cpp#L3134
*
* And for quads:
* @see https://github.com/arx/ArxLibertatis/blob/ArxFatalis-1.21/Sources/EERIE/EERIEDraw.cpp#L267
*
* At least the triangle formula looks like it was supposed to be the actual area but it only works for
* specific kinds of triangles. The quad "area" is probably annoying or impossible to replicate as it will
* depend on the order of the vertices in the triangle before they were reordered when merging into the quad.
*
* AFAICT the area value is only used for collisions to to do additional checks for larger polygons.
* I don't think the exact value matters in practice.
*/
calculateArea(): void;
/**
* assuming the order of vertices taking up a russian i (И) shape:
* ```
* 0 2
* 1 3
* ```
* `isQuadPart` === false -> calculate the area of 0-1-2
* `isQuadPart` === true -> calculate the area of 1-2-3
*/
private getHalfPolygonArea;
/**
* All the vertices are inside or on the surface of the box
* If exludeOnSurface (default true) is true, then we ignore checking the surface by shrinking
* the box by 1 on each side
*/
isWithin(box: Box3, excludeOnSurface?: boolean): boolean;
/**
* At least one of the vertices are inside or on the surface of the box
* If `exludeOnSurface` (default true) is true, then we ignore checking the surface by shrinking
* the box by a specific value on each side
*/
isPartiallyWithin(box: Box3, excludeOnSurface?: boolean): boolean;
setColor(color: Color): void;
move(offset: Vector3): void;
scale(scale: number): void;
equals(polygon: Polygon, epsilon?: number): boolean;
isOutOfBounds(): boolean;
makeDoubleSided(): void;
flipUVHorizontally(): void;
flipUVVertically(): void;
getBoundingBox(): Box3;
}
export {};