|
@@ -21,15 +21,15 @@ inline FVector3D parseFVector3D(const ReadableString& content) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// A 2D image with depth and normal images for deferred light
|
|
|
|
|
-// To be rendered into images in advance for maximum detail level
|
|
|
|
|
|
|
+// A 2D image with depth and normal images for deferred light.
|
|
|
|
|
+// To be rendered into images in advance for maximum detail level.
|
|
|
struct SpriteInstance {
|
|
struct SpriteInstance {
|
|
|
public:
|
|
public:
|
|
|
int32_t typeIndex;
|
|
int32_t typeIndex;
|
|
|
Direction direction;
|
|
Direction direction;
|
|
|
- IVector3D location; // Mini-tile coordinates
|
|
|
|
|
|
|
+ IVector3D location; // Mini-tile coordinates.
|
|
|
bool shadowCasting;
|
|
bool shadowCasting;
|
|
|
- uint64_t userData; // Can be used to store additional information needed for specific games
|
|
|
|
|
|
|
+ uint64_t userData; // Can be used to store additional information needed for specific games.
|
|
|
public:
|
|
public:
|
|
|
SpriteInstance(int typeIndex, Direction direction, const IVector3D& location, bool shadowCasting, uint64_t userData = 0)
|
|
SpriteInstance(int typeIndex, Direction direction, const IVector3D& location, bool shadowCasting, uint64_t userData = 0)
|
|
|
: typeIndex(typeIndex), direction(direction), location(location), shadowCasting(shadowCasting), userData(userData) {}
|
|
: typeIndex(typeIndex), direction(direction), location(location), shadowCasting(shadowCasting), userData(userData) {}
|
|
@@ -39,13 +39,13 @@ struct DenseModelImpl;
|
|
|
using DenseModel = std::shared_ptr<struct DenseModelImpl>;
|
|
using DenseModel = std::shared_ptr<struct DenseModelImpl>;
|
|
|
DenseModel DenseModel_create(const Model& original);
|
|
DenseModel DenseModel_create(const Model& original);
|
|
|
|
|
|
|
|
-// A 3D model that can be rotated freely
|
|
|
|
|
-// To be rendered during game-play to allow free rotation
|
|
|
|
|
|
|
+// A 3D model that can be rotated freely.
|
|
|
|
|
+// To be rendered during game-play to allow free rotation.
|
|
|
struct ModelInstance {
|
|
struct ModelInstance {
|
|
|
public:
|
|
public:
|
|
|
int typeIndex;
|
|
int typeIndex;
|
|
|
- Transform3D location; // 3D tile coordinates with translation and 3-axis rotation allowed
|
|
|
|
|
- uint64_t userData; // Can be used to store additional information needed for specific games
|
|
|
|
|
|
|
+ Transform3D location; // 3D tile coordinates with translation and 3-axis rotation allowed.
|
|
|
|
|
+ uint64_t userData; // Can be used to store additional information needed for specific games.
|
|
|
public:
|
|
public:
|
|
|
ModelInstance(int typeIndex, const Transform3D& location, uint64_t userData = 0)
|
|
ModelInstance(int typeIndex, const Transform3D& location, uint64_t userData = 0)
|
|
|
: typeIndex(typeIndex), location(location), userData(userData) {}
|
|
: typeIndex(typeIndex), location(location), userData(userData) {}
|
|
@@ -72,20 +72,20 @@ void spriteWorld_addTemporaryModel(SpriteWorld& world, const ModelInstance& inst
|
|
|
|
|
|
|
|
// SpriteInstance& sprite, const IVector3D origin, const IVector3D minBound, const IVector3D maxBound -> bool selected
|
|
// SpriteInstance& sprite, const IVector3D origin, const IVector3D minBound, const IVector3D maxBound -> bool selected
|
|
|
using SpriteSelection = std::function<bool(SpriteInstance&, const IVector3D, const IVector3D, const IVector3D)>;
|
|
using SpriteSelection = std::function<bool(SpriteInstance&, const IVector3D, const IVector3D, const IVector3D)>;
|
|
|
-// Remove sprites using an axis aligned serach box in mini-tile coordinates and a lambda filter
|
|
|
|
|
-// Use userData in the lambda's first argument to get ownership information
|
|
|
|
|
-// Return true for each sprite to remove from the background
|
|
|
|
|
|
|
+// Remove sprites using an axis aligned serach box in mini-tile coordinates and a lambda filter.
|
|
|
|
|
+// Use userData in the lambda's first argument to get ownership information.
|
|
|
|
|
+// Return true for each sprite to remove from the background.
|
|
|
void spriteWorld_removeBackgroundSprites(SpriteWorld& world, const IVector3D& searchMinBound, const IVector3D& searchMaxBound, const SpriteSelection& filter);
|
|
void spriteWorld_removeBackgroundSprites(SpriteWorld& world, const IVector3D& searchMinBound, const IVector3D& searchMaxBound, const SpriteSelection& filter);
|
|
|
-// Erasing every sprite within the bound
|
|
|
|
|
|
|
+// Erasing every sprite within the bound.
|
|
|
void spriteWorld_removeBackgroundSprites(SpriteWorld& world, const IVector3D& searchMinBound, const IVector3D& searchMaxBound);
|
|
void spriteWorld_removeBackgroundSprites(SpriteWorld& world, const IVector3D& searchMinBound, const IVector3D& searchMaxBound);
|
|
|
|
|
|
|
|
-// ModelInstance& model, const IVector3D origin, const IVector3D minBound, const IVector3D maxBound -> bool selected
|
|
|
|
|
|
|
+// ModelInstance& model, const IVector3D origin, const IVector3D minBound, const IVector3D maxBound -> bool selected.
|
|
|
using ModelSelection = std::function<bool(ModelInstance&, const IVector3D, const IVector3D, const IVector3D)>;
|
|
using ModelSelection = std::function<bool(ModelInstance&, const IVector3D, const IVector3D, const IVector3D)>;
|
|
|
-// Remove models using an axis aligned serach box in mini-tile coordinates and a lambda filter
|
|
|
|
|
-// Use userData in the lambda's first argument to get ownership information
|
|
|
|
|
-// Return true for each model to remove from the background
|
|
|
|
|
|
|
+// Remove models using an axis aligned serach box in mini-tile coordinates and a lambda filter.
|
|
|
|
|
+// Use userData in the lambda's first argument to get ownership information.
|
|
|
|
|
+// Return true for each model to remove from the background.
|
|
|
void spriteWorld_removeBackgroundModels(SpriteWorld& world, const IVector3D& searchMinBound, const IVector3D& searchMaxBound, const ModelSelection& filter);
|
|
void spriteWorld_removeBackgroundModels(SpriteWorld& world, const IVector3D& searchMinBound, const IVector3D& searchMaxBound, const ModelSelection& filter);
|
|
|
-// Erasing every model within the bound
|
|
|
|
|
|
|
+// Erasing every model within the bound.
|
|
|
void spriteWorld_removeBackgroundModels(SpriteWorld& world, const IVector3D& searchMinBound, const IVector3D& searchMaxBound);
|
|
void spriteWorld_removeBackgroundModels(SpriteWorld& world, const IVector3D& searchMinBound, const IVector3D& searchMaxBound);
|
|
|
|
|
|
|
|
// Create a point light that only exists until the next call to spriteWorld_clearTemporary.
|
|
// Create a point light that only exists until the next call to spriteWorld_clearTemporary.
|
|
@@ -95,21 +95,18 @@ void spriteWorld_createTemporary_directedLight(SpriteWorld& world, const FVector
|
|
|
|
|
|
|
|
void spriteWorld_clearTemporary(SpriteWorld& world);
|
|
void spriteWorld_clearTemporary(SpriteWorld& world);
|
|
|
|
|
|
|
|
-// Draw the world using the current camera at the center of colorTarget
|
|
|
|
|
|
|
+// Draw the world using the current camera at the center of colorTarget.
|
|
|
void spriteWorld_draw(SpriteWorld& world, AlignedImageRgbaU8& colorTarget);
|
|
void spriteWorld_draw(SpriteWorld& world, AlignedImageRgbaU8& colorTarget);
|
|
|
|
|
|
|
|
-// Draw debug information
|
|
|
|
|
|
|
+// Draw debug information.
|
|
|
void spriteWorld_debug_octrees(SpriteWorld& world, AlignedImageRgbaU8& colorTarget);
|
|
void spriteWorld_debug_octrees(SpriteWorld& world, AlignedImageRgbaU8& colorTarget);
|
|
|
|
|
|
|
|
// The result is an approximation in mini-tile units.
|
|
// The result is an approximation in mini-tile units.
|
|
|
// The 3D system does not align with screen pixels for less than whole tile units.
|
|
// The 3D system does not align with screen pixels for less than whole tile units.
|
|
|
IVector3D spriteWorld_findGroundAtPixel(SpriteWorld& world, const AlignedImageRgbaU8& colorBuffer, const IVector2D& pixelLocation);
|
|
IVector3D spriteWorld_findGroundAtPixel(SpriteWorld& world, const AlignedImageRgbaU8& colorBuffer, const IVector2D& pixelLocation);
|
|
|
|
|
|
|
|
-// Set the camera's location directly
|
|
|
|
|
-void spriteWorld_setCameraLocation(SpriteWorld& world, const IVector3D miniTileLocation);
|
|
|
|
|
-
|
|
|
|
|
-// Approximates a mini-tile offset along the ground from the given pixel offset and moves the camera accordingly
|
|
|
|
|
-// If the offset is too small, the camera might not move at all
|
|
|
|
|
|
|
+// Approximates a mini-tile offset along the ground from the given pixel offset and moves the camera accordingly.
|
|
|
|
|
+// If the offset is too small, the camera might not move at all.
|
|
|
void spriteWorld_moveCameraInPixels(SpriteWorld& world, const IVector2D& pixelOffset);
|
|
void spriteWorld_moveCameraInPixels(SpriteWorld& world, const IVector2D& pixelOffset);
|
|
|
|
|
|
|
|
// Get internal buffers after rendering.
|
|
// Get internal buffers after rendering.
|
|
@@ -121,18 +118,28 @@ OrderedImageRgbaU8 spriteWorld_getNormalBuffer(SpriteWorld& world);
|
|
|
OrderedImageRgbaU8 spriteWorld_getLightBuffer(SpriteWorld& world);
|
|
OrderedImageRgbaU8 spriteWorld_getLightBuffer(SpriteWorld& world);
|
|
|
AlignedImageF32 spriteWorld_getHeightBuffer(SpriteWorld& world);
|
|
AlignedImageF32 spriteWorld_getHeightBuffer(SpriteWorld& world);
|
|
|
|
|
|
|
|
-// Access the index of the camera's fixed direction
|
|
|
|
|
-// This is not an index selecting the camera itself, only selecting the viewing angle
|
|
|
|
|
|
|
+// Camera's location as a 3D coordinate in world mini-tile coordinates.
|
|
|
|
|
+IVector3D spriteWorld_getCameraLocation(const SpriteWorld& world);
|
|
|
|
|
+void spriteWorld_setCameraLocation(SpriteWorld& world, const IVector3D miniTileLocation);
|
|
|
|
|
+
|
|
|
|
|
+// Access the index of the camera's fixed direction.
|
|
|
|
|
+// This is not an index selecting the camera itself, only selecting the viewing angle.
|
|
|
// TODO: Implement bound checks or a system that's easier to understand.
|
|
// TODO: Implement bound checks or a system that's easier to understand.
|
|
|
-int spriteWorld_getCameraDirectionIndex(SpriteWorld& world);
|
|
|
|
|
|
|
+int spriteWorld_getCameraDirectionIndex(const SpriteWorld& world);
|
|
|
void spriteWorld_setCameraDirectionIndex(SpriteWorld& world, int index);
|
|
void spriteWorld_setCameraDirectionIndex(SpriteWorld& world, int index);
|
|
|
|
|
|
|
|
|
|
+// Get the current direction's orthogonal axis system.
|
|
|
|
|
+// This can be used to convert between world and screen coordinates using the camera location.
|
|
|
|
|
+OrthoView& spriteWorld_getCurrentOrthoView(SpriteWorld& world);
|
|
|
|
|
+// Get the whole game's orthogonal system for all camera angles.
|
|
|
|
|
+OrthoSystem& spriteWorld_getOrthoSystem(SpriteWorld& world);
|
|
|
|
|
+
|
|
|
// Pre-conditions:
|
|
// Pre-conditions:
|
|
|
-// The model should be pre-transformed so that it can be rendered at the world origin
|
|
|
|
|
-// Textures must be converted into vertex colors or else they will simply be ignored
|
|
|
|
|
-// Enabling debug will save another file using a *Debug.png prefix with additional information
|
|
|
|
|
-// Use it to find flaws in generated shadow shapes that are hard to see in raw data
|
|
|
|
|
-// TODO: Hide OrthoSystem or expose it safely
|
|
|
|
|
|
|
+// The model should be pre-transformed so that it can be rendered at the world origin.
|
|
|
|
|
+// Textures must be converted into vertex colors or else they will simply be ignored.
|
|
|
|
|
+// Enabling debug will save another file using a *Debug.png prefix with additional information.
|
|
|
|
|
+// Use it to find flaws in generated shadow shapes that are hard to see in raw data.
|
|
|
|
|
+// TODO: Hide OrthoSystem or expose it safely.
|
|
|
void sprite_generateFromModel(const Model& visibleModel, const Model& shadowModel, const OrthoSystem& ortho, const String& targetPath, int cameraAngles, bool debug = false);
|
|
void sprite_generateFromModel(const Model& visibleModel, const Model& shadowModel, const OrthoSystem& ortho, const String& targetPath, int cameraAngles, bool debug = false);
|
|
|
// A simpler version writing the result to an image and a string instead of saving to files.
|
|
// A simpler version writing the result to an image and a string instead of saving to files.
|
|
|
void sprite_generateFromModel(ImageRgbaU8& targetAtlas, String& targetConfigText, const Model& visibleModel, const Model& shadowModel, const OrthoSystem& ortho, const String& targetPath, int cameraAngles);
|
|
void sprite_generateFromModel(ImageRgbaU8& targetAtlas, String& targetConfigText, const Model& visibleModel, const Model& shadowModel, const OrthoSystem& ortho, const String& targetPath, int cameraAngles);
|