97 lines
3.6 KiB
C
97 lines
3.6 KiB
C
/* Silkworm - Verlet cloth physics in C
|
|
*
|
|
* Copyright (c) 2021 Evan Hemsley
|
|
*
|
|
* This software is provided 'as-is', without any express or implied warranty.
|
|
* In no event will the authors be held liable for any damages arising from
|
|
* the use of this software.
|
|
*
|
|
* Permission is granted to anyone to use this software for any purpose,
|
|
* including commercial applications, and to alter it and redistribute it
|
|
* freely, subject to the following restrictions:
|
|
*
|
|
* 1. The origin of this software must not be misrepresented; you must not
|
|
* claim that you wrote the original software. If you use this software in a
|
|
* product, an acknowledgment in the product documentation would be
|
|
* appreciated but is not required.
|
|
*
|
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
* misrepresented as being the original software.
|
|
*
|
|
* 3. This notice may not be removed or altered from any source distribution.
|
|
*
|
|
* Evan "cosmonaut" Hemsley <evan@moonside.games>
|
|
*
|
|
*/
|
|
|
|
#ifndef SILKWORM_H
|
|
#define SILKWORM_H
|
|
|
|
#include <math.h>
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#ifdef _WIN32
|
|
#define SILKWORMAPI __declspec(dllexport)
|
|
#define SILKWORMCALL __cdecl
|
|
#else
|
|
#define SILKWORMAPI
|
|
#define SILKWORMCALL
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif /* __cplusplus */
|
|
|
|
/* Version API */
|
|
|
|
#define SILKWORM_ABI_VERSION 0
|
|
#define SILKWORM_MAJOR_VERSION 0
|
|
#define SILKWORM_MINOR_VERSION 1
|
|
#define SILKWORM_PATCH_VERSION 0
|
|
#define SILKWORM_COMPILED_VERSION ( \
|
|
(SILKWORM_ABI_VERSION * 100 * 100 * 100) + \
|
|
(SILKWORM_MAJOR_VERSION * 100 * 100) + \
|
|
(SILKWORM_MINOR_VERSION * 100) + \
|
|
(SILKWORM_PATCH_VERSION) \
|
|
)
|
|
|
|
SILKWORMAPI void Silkworm_Init();
|
|
SILKWORMAPI void Silkworm_Update(double delta);
|
|
SILKWORMAPI void Silkworm_ApplyWind(double xSpeed, double ySpeed);
|
|
|
|
SILKWORMAPI void Silkworm_SetBuffer(const char* bufferId);
|
|
|
|
SILKWORMAPI double Silkworm_CreateNode(double xPosition, double yPosition, double mass, double friction, double radius, double pushFactor);
|
|
|
|
SILKWORMAPI void Silkworm_NodeSetDestroyable(double nodeId);
|
|
|
|
SILKWORMAPI double Silkworm_CreateLink(double aId, double bId, double distance, double tearThreshold);
|
|
|
|
SILKWORMAPI double Silkworm_CreateCloth(double xPosition, double yPosition, double width, double height, double mass, double friction, double windFactor, double tearThreshold);
|
|
SILKWORMAPI double Silkworm_ClothHorizontalNodeCount(double clothId);
|
|
SILKWORMAPI double Silkworm_ClothVerticalNodeCount(double clothId);
|
|
SILKWORMAPI void Silkworm_ClothNodePin(double clothId, double i, double j);
|
|
SILKWORMAPI void Silkworm_ClothNodeUnpin(double clothId, double i, double j);
|
|
SILKWORMAPI void Silkworm_ClothNodeDestroy(double clothId, double i, double j);
|
|
SILKWORMAPI void Silkworm_ClothFillNodeDataBuffer(double clothId);
|
|
SILKWORMAPI void Silkworm_DestroyCloth(double clothId);
|
|
|
|
SILKWORMAPI double Silkworm_ClothFillTriangleBuffer(double clothId, double leftUV, double widthUV, double topUV, double heightUV);
|
|
|
|
SILKWORMAPI double Silkworm_GetEditorBufferRequiredSize();
|
|
SILKWORMAPI double Silkworm_FillEditorBuffer();
|
|
|
|
SILKWORMAPI void Silkworm_DestroyNode(double nodeId);
|
|
|
|
SILKWORMAPI void Silkworm_PinNodesInRadius(double x, double y, double radius);
|
|
SILKWORMAPI void Silkworm_UnpinNodesInRadius(double x, double y, double radius);
|
|
SILKWORMAPI void Silkworm_PushNodesInRadius(double x, double y, double radius, double xDirection, double yDirection);
|
|
SILKWORMAPI void Silkworm_DestroyNodesInRadius(double x, double y, double radius);
|
|
SILKWORMAPI double Silkworm_DestroyClothInRadius(double x, double y, double radius);
|
|
|
|
SILKWORMAPI void Silkworm_ClearAll();
|
|
SILKWORMAPI void Silkworm_Finish();
|
|
|
|
#endif /* SILKWORM_H */
|