/* 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 * */ #ifndef SILKWORM_H #define SILKWORM_H #include #include #include #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, double windFactor); 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_RopeCreate(double xPosition, double yPosition, double mass, double friction, double windFactor, double pushFactor, double tearThreshold); SILKWORMAPI double Silkworm_RopeAddNode(double ropeId, double xPosition, double yPosition, double length); SILKWORMAPI double Silkworm_RopeVerticalLength(double ropeId); SILKWORMAPI double Silkworm_RopeNearestX(double ropeId, double xPosition, double yPosition); SILKWORMAPI double Silkworm_RopeNearestY(double ropeId, double xPosition, double yPosition); SILKWORMAPI double Silkworm_RopeNodeCount(double ropeId); SILKWORMAPI double Silkworm_RopeNodeXPosition(double ropeId, double nodeIndex); SILKWORMAPI double Silkworm_RopeNodeYPosition(double ropeId, double nodeIndex); SILKWORMAPI double Silkworm_RopeNodeXSpeed(double ropeId, double nodeIndex); SILKWORMAPI double Silkworm_RopeNodeYSpeed(double ropeId, double nodeIndex); SILKWORMAPI void Silkworm_UnpinRope(double ropeId); SILKWORMAPI void Silkworm_DeleteEndNode(double ropeId); SILKWORMAPI void Silkworm_RopeDestroy(double ropeId); SILKWORMAPI double Silkworm_RopeRequiredBufferSize(double ropeId); SILKWORMAPI double Silkworm_RopeFillBuffer(double ropeId, double width, 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 double Silkworm_NodeDestructionDataBufferRequiredSize(); SILKWORMAPI double Silkworm_FillNodeDestructionDataBuffer(); SILKWORMAPI double Silkworm_LinkDestructionDataBufferRequiredSize(); SILKWORMAPI double Silkworm_FillLinkDestructionDataBuffer(); SILKWORMAPI void Silkworm_PerformDestroys(); SILKWORMAPI void Silkworm_ClearAll(); SILKWORMAPI void Silkworm_Finish(); #endif /* SILKWORM_H */