Add HairParticleSystem and Small Enhancements for Lua Bindings (#553)

* Update Lua

* Update Lua Bindings

* HairComponent Lua Binding Fix

* Adding Documentation
This commit is contained in:
Megumumpkin
2022-09-04 00:06:56 +07:00
committed by GitHub
parent b8bb07234e
commit 018f5d003d
6 changed files with 820 additions and 2 deletions
+16
View File
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug Editor",
"type": "gdb",
"request": "launch",
"target": "./WickedEngineEditor",
"cwd": "${workspaceRoot}/build/Editor",
"valuesFormatting": "parseText"
}
]
}
@@ -32,6 +32,7 @@ This is a reference and explanation of Lua scripting features in Wicked Engine.
7. [AnimationComponent](#animationcomponent)
8. [MaterialComponent](#materialcomponent)
9. [EmitterComponent](#emittercomponent)
9. [HairParticleSystem](#hairparticlesystem)
10. [LightComponent](#lightcomponent)
11. [ObjectComponent](#objectcomponent)
12. [InverseKinematicsComponent](#inversekinematicscomponent)
@@ -657,6 +658,7 @@ Describes an orientation in 3D space.
- GetAmount() : float result
#### MaterialComponent
- _flags : int
- BaseColor : Vector
- EmissiveColor : Vector
- EngineStencilRef : int
@@ -692,8 +694,30 @@ Describes an orientation in 3D space.
- SetEngineStencilRef(int value)
- SetUserStencilRef(int value)
- GetStencilRef() : int result
- SetTexture(int textureindex, string texturefile)
- SetTextureUVSet(int textureindex, int uvset)
- GetTexture(int textureindex) : string texturefile
- GetTextureUVSet(int textureindex) : int uvset
#### MeshComponent
- _flags : int
- TessellationFactor : float
- ArmatureID : int
- SubsetsPerLOD : int
</br>
- SetMeshSubsetMaterialID(int subsetindex, Entity materialID)
- GetMeshSubsetMaterialID(int subsetindex)
#### EmitterComponent
- _flags : int
- ShaderType : int
- Mass : float
- Velocity : Vector
- Gravity : Vector
- Drag : float
- Restitution : float
- EmitCount : float -- emitted particle count per second
- Size : float -- particle starting size
- Life : float -- particle lifetime
@@ -704,6 +728,15 @@ Describes an orientation in 3D space.
- ScaleY : float -- scaling along lifetime in Y axis
- Rotation : float -- rotation speed
- MotionBlurAmount : float -- set the motion elongation factor
- SPH_h : float
- SPH_K : float
- SPH_p0 : float
- SPH_e : float
- SpriteSheet_Frames_X : int
- SpriteSheet_Frames_Y : int
- SpriteSheet_Frame_Count : int
- SpriteSheet_Frame_Start : int
- SpriteSheet_Framerate : float
</br>
@@ -719,6 +752,20 @@ Describes an orientation in 3D space.
- SetRotation(float value) -- set rotation speed
- SetMotionBlurAmount(float value) -- set the motion elongation factor
#### HairParticleSystem
- _flags : int
- StrandCount : int
- SegmentCount : int
- RandomSeed : int
- Length : float
- Stiffness : float
- Randomness : float
- ViewDistance : float
- SpriteSheet_Frames_X : int
- SpriteSheet_Frames_Y : int
- SpriteSheet_Frame_Count : int
- SpriteSheet_Frame_Start : int
#### LightComponent
- Type : int -- light type, see accepted values below (by default it is a point light)
- [outer]DIRECTIONAL : int
@@ -800,9 +847,22 @@ Describes an Inverse Kinematics effector.
#### SpringComponent
Enables jiggle effect on transforms such as bones for example.
- Stiffness : float
- Damping : float
- WindAffection : float
- DragForce : float
- HitRadius : float
- GravityPower : float
- GravityDirection : Vector
</br>
- SetStiffness(float value)
- SetDamping(float value)
- SetWindAffection(float value)
- GetStiffness() : float result
- GetDamping() : float result
- GetWindAffection() : float result
#### ScriptComponent
A lua script bound to an entity
@@ -995,15 +1055,27 @@ It inherits functions from RenderPath2D.
#### Ray
A ray is defined by an origin Vector and a normalized direction Vector. It can be used to intersect with other primitives or the scene
- Origin : Vector
- Direction : Vector
</br>
- [constructor]Ray(Vector origin,direction)
- Intersects(AABB aabb) : bool result
- Intersects(Sphere sphere) : bool result
- Intersects(Capsule capsule) : bool result
- GetOrigin() : Vector result
- GetDirection() : Vector result
- SetOrigin(Vector vector)
- SetDirection(Vector vector)
#### AABB
Axis Aligned Bounding Box. Can be intersected with other primitives.
- Min : Vector
- Max : Vector
</br>
- [constructor]AABB(opt Vector min,max) -- if no argument is given, it will be infinitely inverse that can't intersect
- Intersects2D(AABB aabb) : bool result -- omit the z component for intersection check for more precise 2D intersection
- Intersects(AABB aabb) : bool result
@@ -1011,6 +1083,8 @@ Axis Aligned Bounding Box. Can be intersected with other primitives.
- Intersects(Ray ray) : bool result
- GetMin() : Vector result
- GetMax() : Vector result
- SetMin(Vector vector)
- SetMax(Vector vector)
- GetCenter() : Vector result
- GetHalfExtents() : Vector result
- Transform(Matrix matrix) : AABB result -- transforms the AABB with a matrix and returns the resulting conservative AABB
+92
View File
@@ -30,9 +30,13 @@ namespace wi::lua::primitive
lunamethod(Ray_BindLua, Intersects),
lunamethod(Ray_BindLua, GetOrigin),
lunamethod(Ray_BindLua, GetDirection),
lunamethod(Ray_BindLua, SetOrigin),
lunamethod(Ray_BindLua, SetDirection),
{ NULL, NULL }
};
Luna<Ray_BindLua>::PropertyType Ray_BindLua::properties[] = {
lunaproperty(Ray_BindLua, Origin),
lunaproperty(Ray_BindLua, Direction),
{ NULL, NULL }
};
@@ -104,11 +108,53 @@ namespace wi::lua::primitive
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&ray.origin)));
return 1;
}
int Ray_BindLua::SetOrigin(lua_State *L)
{
int argc = wi::lua::SGetArgCount(L);
if (argc > 0)
{
Vector_BindLua* v = Luna<Vector_BindLua>::lightcheck(L, 1);
if (v != nullptr)
{
XMStoreFloat3(&ray.origin, XMLoadFloat4(v));
}
else
{
wi::lua::SError(L, "SetOrigin(Vector vector) argument is not a vector!");
}
}
else
{
wi::lua::SError(L, "SetOrigin(Vector vector) not enough arguments!");
}
return 0;
}
int Ray_BindLua::GetDirection(lua_State* L)
{
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&ray.direction)));
return 1;
}
int Ray_BindLua::SetDirection(lua_State *L)
{
int argc = wi::lua::SGetArgCount(L);
if (argc > 0)
{
Vector_BindLua* v = Luna<Vector_BindLua>::lightcheck(L, 1);
if (v != nullptr)
{
XMStoreFloat3(&ray.direction, XMLoadFloat4(v));
}
else
{
wi::lua::SError(L, "SetDirection(Vector vector) argument is not a vector!");
}
}
else
{
wi::lua::SError(L, "SetDirection(Vector vector) not enough arguments!");
}
return 0;
}
@@ -119,6 +165,8 @@ namespace wi::lua::primitive
lunamethod(AABB_BindLua, Intersects2D),
lunamethod(AABB_BindLua, GetMin),
lunamethod(AABB_BindLua, GetMax),
lunamethod(AABB_BindLua, SetMin),
lunamethod(AABB_BindLua, SetMax),
lunamethod(AABB_BindLua, GetCenter),
lunamethod(AABB_BindLua, GetHalfExtents),
lunamethod(AABB_BindLua, Transform),
@@ -126,6 +174,8 @@ namespace wi::lua::primitive
{ NULL, NULL }
};
Luna<AABB_BindLua>::PropertyType AABB_BindLua::properties[] = {
lunaproperty(AABB_BindLua, Min),
lunaproperty(AABB_BindLua, Max),
{ NULL, NULL }
};
@@ -220,12 +270,54 @@ namespace wi::lua::primitive
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&M)));
return 1;
}
int AABB_BindLua::SetMin(lua_State *L)
{
int argc = wi::lua::SGetArgCount(L);
if (argc > 0)
{
Vector_BindLua* v = Luna<Vector_BindLua>::lightcheck(L, 1);
if (v != nullptr)
{
XMStoreFloat3(&aabb._min, XMLoadFloat4(v));
}
else
{
wi::lua::SError(L, "SetMin(Vector vector) argument is not a vector!");
}
}
else
{
wi::lua::SError(L, "SetMin(Vector vector) not enough arguments!");
}
return 0;
}
int AABB_BindLua::GetMax(lua_State* L)
{
XMFLOAT3 M = aabb.getMax();
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&M)));
return 1;
}
int AABB_BindLua::SetMax(lua_State *L)
{
int argc = wi::lua::SGetArgCount(L);
if (argc > 0)
{
Vector_BindLua* v = Luna<Vector_BindLua>::lightcheck(L, 1);
if (v != nullptr)
{
XMStoreFloat3(&aabb._max, XMLoadFloat4(v));
}
else
{
wi::lua::SError(L, "SetMax(Vector vector) argument is not a vector!");
}
}
else
{
wi::lua::SError(L, "SetMax(Vector vector) not enough arguments!");
}
return 0;
}
int AABB_BindLua::GetCenter(lua_State* L)
{
XMFLOAT3 C = aabb.getCenter();
+4
View File
@@ -23,6 +23,8 @@ namespace wi::lua::primitive
int Intersects(lua_State* L);
int GetOrigin(lua_State* L);
int GetDirection(lua_State* L);
int SetOrigin(lua_State* L);
int SetDirection(lua_State* L);
};
class AABB_BindLua
@@ -41,6 +43,8 @@ namespace wi::lua::primitive
int Intersects2D(lua_State* L);
int GetMin(lua_State* L);
int GetMax(lua_State* L);
int SetMin(lua_State* L);
int SetMax(lua_State* L);
int GetCenter(lua_State* L);
int GetHalfExtents(lua_State* L);
int Transform(lua_State* L);
File diff suppressed because it is too large Load Diff
+216 -2
View File
@@ -46,6 +46,8 @@ namespace wi::lua::scene
int Component_CreateName(lua_State* L);
int Component_CreateLayer(lua_State* L);
int Component_CreateTransform(lua_State* L);
int Component_CreateEmitter(lua_State* L);
int Component_CreateHairParticleSystem(lua_State* L);
int Component_CreateLight(lua_State* L);
int Component_CreateObject(lua_State* L);
int Component_CreateMaterial(lua_State* L);
@@ -65,7 +67,9 @@ namespace wi::lua::scene
int Component_GetCamera(lua_State* L);
int Component_GetAnimation(lua_State* L);
int Component_GetMaterial(lua_State* L);
int Component_GetMesh(lua_State* L);
int Component_GetEmitter(lua_State* L);
int Component_GetHairParticleSystem(lua_State* L);
int Component_GetLight(lua_State* L);
int Component_GetObject(lua_State* L);
int Component_GetInverseKinematics(lua_State* L);
@@ -84,7 +88,9 @@ namespace wi::lua::scene
int Component_GetCameraArray(lua_State* L);
int Component_GetAnimationArray(lua_State* L);
int Component_GetMaterialArray(lua_State* L);
int Component_GetMeshArray(lua_State* L);
int Component_GetEmitterArray(lua_State* L);
int Component_GetHairParticleSystemArray(lua_State* L);
int Component_GetLightArray(lua_State* L);
int Component_GetObjectArray(lua_State* L);
int Component_GetInverseKinematicsArray(lua_State* L);
@@ -103,7 +109,9 @@ namespace wi::lua::scene
int Entity_GetCameraArray(lua_State* L);
int Entity_GetAnimationArray(lua_State* L);
int Entity_GetMaterialArray(lua_State* L);
int Entity_GetMeshArray(lua_State* L);
int Entity_GetEmitterArray(lua_State* L);
int Entity_GetHairParticleSystemArray(lua_State* L);
int Entity_GetLightArray(lua_State* L);
int Entity_GetObjectArray(lua_State* L);
int Entity_GetInverseKinematicsArray(lua_State* L);
@@ -285,6 +293,7 @@ namespace wi::lua::scene
inline void BuildBindings()
{
_flags = LongLongProperty(reinterpret_cast<long long*>(&component->_flags));
ShaderType = IntProperty(reinterpret_cast<int*>(&component->shaderType));
UserBlendMode = IntProperty(reinterpret_cast<int*>(&component->roughness));
SpecularColor = VectorProperty(&component->specularColor);
@@ -314,6 +323,7 @@ namespace wi::lua::scene
MaterialComponent_BindLua(lua_State *L);
~MaterialComponent_BindLua();
LongLongProperty _flags;
IntProperty ShaderType;
IntProperty UserBlendMode;
VectorProperty SpecularColor;
@@ -338,6 +348,7 @@ namespace wi::lua::scene
FloatProperty texAnimElapsedTime;
IntProperty customShaderID;
PropertyFunction(_flags)
PropertyFunction(ShaderType)
PropertyFunction(UserBlendMode)
PropertyFunction(SpecularColor)
@@ -371,6 +382,47 @@ namespace wi::lua::scene
int SetUserStencilRef(lua_State* L);
int GetUserStencilRef(lua_State* L);
int GetStencilRef(lua_State* L);
int SetTexture(lua_State* L);
int SetTextureUVSet(lua_State* L);
int GetTexture(lua_State* L);
int GetTextureUVSet(lua_State* L);
};
class MeshComponent_BindLua
{
public:
bool owning = false;
wi::scene::MeshComponent* component = nullptr;
static const char className[];
static Luna<MeshComponent_BindLua>::FunctionType methods[];
static Luna<MeshComponent_BindLua>::PropertyType properties[];
inline void BuildBindings()
{
_flags = LongLongProperty(reinterpret_cast<long long*>(&component->_flags));
TessellationFactor = FloatProperty(&component->tessellationFactor);
ArmatureID = LongLongProperty(reinterpret_cast<long long*>(&component->armatureID));
SubsetsPerLOD = LongLongProperty(reinterpret_cast<long long*>(&component->subsets_per_lod));
}
MeshComponent_BindLua(wi::scene::MeshComponent* component) :component(component) { BuildBindings(); }
MeshComponent_BindLua(lua_State *L);
~MeshComponent_BindLua();
LongLongProperty _flags;
FloatProperty TessellationFactor;
LongLongProperty ArmatureID;
LongLongProperty SubsetsPerLOD;
PropertyFunction(_flags)
PropertyFunction(TessellationFactor)
PropertyFunction(ArmatureID)
PropertyFunction(SubsetsPerLOD)
int SetMeshSubsetMaterialID(lua_State* L);
int GetMeshSubsetMaterialID(lua_State* L);
};
class EmitterComponent_BindLua
@@ -383,10 +435,76 @@ namespace wi::lua::scene
static Luna<EmitterComponent_BindLua>::FunctionType methods[];
static Luna<EmitterComponent_BindLua>::PropertyType properties[];
EmitterComponent_BindLua(wi::EmittedParticleSystem* component) :component(component) {}
inline void BuildBindings()
{
_flags = LongLongProperty(reinterpret_cast<long long*>(&component->_flags));
ShaderType = IntProperty(reinterpret_cast<int*>(&component->shaderType));
Mass = FloatProperty(&component->mass);
Velocity = VectorProperty(&component->velocity);
Gravity = VectorProperty(&component->gravity);
Drag = FloatProperty(&component->drag);
Restitution = FloatProperty(&component->restitution);
SPH_h = FloatProperty(&component->SPH_h);
SPH_K = FloatProperty(&component->SPH_K);
SPH_p0 = FloatProperty(&component->SPH_p0);
SPH_e = FloatProperty(&component->SPH_e);
SpriteSheet_Frames_X = LongLongProperty(reinterpret_cast<long long*>(&component->framesX));
SpriteSheet_Frames_Y = LongLongProperty(reinterpret_cast<long long*>(&component->framesY));
SpriteSheet_Frame_Count = LongLongProperty(reinterpret_cast<long long*>(&component->frameCount));
SpriteSheet_Frame_Start = LongLongProperty(reinterpret_cast<long long*>(&component->frameStart));
SpriteSheet_Framerate = FloatProperty(&component->frameRate);
}
EmitterComponent_BindLua(wi::EmittedParticleSystem* component) :component(component) { BuildBindings(); }
EmitterComponent_BindLua(lua_State *L);
~EmitterComponent_BindLua();
LongLongProperty _flags;
IntProperty ShaderType;
FloatProperty Mass;
VectorProperty Velocity;
VectorProperty Gravity;
FloatProperty Drag;
FloatProperty Restitution;
FloatProperty SPH_h;
FloatProperty SPH_K;
FloatProperty SPH_p0;
FloatProperty SPH_e;
LongLongProperty SpriteSheet_Frames_X;
LongLongProperty SpriteSheet_Frames_Y;
LongLongProperty SpriteSheet_Frame_Count;
LongLongProperty SpriteSheet_Frame_Start;
FloatProperty SpriteSheet_Framerate;
PropertyFunction(_flags)
PropertyFunction(ShaderType)
PropertyFunction(Mass)
PropertyFunction(Velocity)
PropertyFunction(Gravity)
PropertyFunction(Drag)
PropertyFunction(Restitution)
PropertyFunction(SPH_h)
PropertyFunction(SPH_K)
PropertyFunction(SPH_p0)
PropertyFunction(SPH_e)
PropertyFunction(SpriteSheet_Frames_X)
PropertyFunction(SpriteSheet_Frames_Y)
PropertyFunction(SpriteSheet_Frame_Count)
PropertyFunction(SpriteSheet_Frame_Start)
PropertyFunction(SpriteSheet_Framerate)
int Burst(lua_State* L);
int SetEmitCount(lua_State* L);
int SetSize(lua_State* L);
@@ -411,6 +529,69 @@ namespace wi::lua::scene
int GetMotionBlurAmount(lua_State* L);
};
class HairParticleSystem_BindLua
{
public:
bool owning = false;
HairParticleSystem* component = nullptr;
static const char className[];
static Luna<HairParticleSystem_BindLua>::FunctionType methods[];
static Luna<HairParticleSystem_BindLua>::PropertyType properties[];
inline void BuildBindings()
{
_flags = LongLongProperty(reinterpret_cast<long long*>(&component->_flags));
StrandCount = LongLongProperty(reinterpret_cast<long long*>(&component->strandCount));
SegmentCount = LongLongProperty(reinterpret_cast<long long*>(&component->segmentCount));
RandomSeed = LongLongProperty(reinterpret_cast<long long*>(&component->randomSeed));
Length = FloatProperty(&component->length);
Stiffness = FloatProperty(&component->stiffness);
Randomness = FloatProperty(&component->randomness);
ViewDistance = FloatProperty(&component->viewDistance);
SpriteSheet_Frames_X = LongLongProperty(reinterpret_cast<long long*>(&component->framesX));
SpriteSheet_Frames_Y = LongLongProperty(reinterpret_cast<long long*>(&component->framesY));
SpriteSheet_Frame_Count = LongLongProperty(reinterpret_cast<long long*>(&component->frameCount));
SpriteSheet_Frame_Start = LongLongProperty(reinterpret_cast<long long*>(&component->frameStart));
}
HairParticleSystem_BindLua(HairParticleSystem* component) :component(component) { BuildBindings(); }
HairParticleSystem_BindLua(lua_State *L);
~HairParticleSystem_BindLua();
LongLongProperty _flags;
LongLongProperty StrandCount;
LongLongProperty SegmentCount;
LongLongProperty RandomSeed;
FloatProperty Length;
FloatProperty Stiffness;
FloatProperty Randomness;
FloatProperty ViewDistance;
LongLongProperty SpriteSheet_Frames_X;
LongLongProperty SpriteSheet_Frames_Y;
LongLongProperty SpriteSheet_Frame_Count;
LongLongProperty SpriteSheet_Frame_Start;
PropertyFunction(_flags)
PropertyFunction(StrandCount)
PropertyFunction(SegmentCount)
PropertyFunction(RandomSeed)
PropertyFunction(Length)
PropertyFunction(Stiffness)
PropertyFunction(Randomness)
PropertyFunction(ViewDistance)
PropertyFunction(SpriteSheet_Frames_X)
PropertyFunction(SpriteSheet_Frames_Y)
PropertyFunction(SpriteSheet_Frame_Count)
PropertyFunction(SpriteSheet_Frame_Start)
};
class LightComponent_BindLua
{
public:
@@ -517,13 +698,34 @@ namespace wi::lua::scene
static Luna<SpringComponent_BindLua>::FunctionType methods[];
static Luna<SpringComponent_BindLua>::PropertyType properties[];
SpringComponent_BindLua(wi::scene::SpringComponent* component) :component(component) {}
inline void BuildBindings()
{
DragForce = FloatProperty(&component->dragForce);
HitRadius = FloatProperty(&component->hitRadius);
GravityPower = FloatProperty(&component->gravityPower);
GravityDirection = VectorProperty(&component->gravityDir);
}
SpringComponent_BindLua(wi::scene::SpringComponent* component) :component(component) { BuildBindings(); }
SpringComponent_BindLua(lua_State* L);
~SpringComponent_BindLua();
FloatProperty DragForce;
FloatProperty HitRadius;
FloatProperty GravityPower;
VectorProperty GravityDirection;
PropertyFunction(DragForce)
PropertyFunction(HitRadius)
PropertyFunction(GravityPower)
PropertyFunction(GravityDirection)
int SetStiffness(lua_State* L);
int SetDamping(lua_State* L);
int SetWindAffection(lua_State* L);
int GetStiffness(lua_State* L);
int GetDamping(lua_State* L);
int GetWindAffection(lua_State* L);
};
class ScriptComponent_BindLua
@@ -986,6 +1188,10 @@ namespace wi::lua::scene
OceanParameters = Weather_OceanParams_Property(&component->oceanParameters);
AtmosphereParameters = Weather_AtmosphereParams_Property(&component->atmosphereParameters);
VolumetricCloudParameters = Weather_VolumetricCloudParams_Property(&component->volumetricCloudParameters);
skyMapName = StringProperty(&component->skyMapName);
colorGradingMapName = StringProperty(&component->colorGradingMapName);
volumetricCloudsWeatherMapName = StringProperty(&component->volumetricCloudsWeatherMapName);
}
WeatherComponent_BindLua(wi::scene::WeatherComponent* component) :component(component) { BuildBindings(); }
@@ -1046,6 +1252,14 @@ namespace wi::lua::scene
PropertyFunction(AtmosphereParameters)
PropertyFunction(VolumetricCloudParameters)
StringProperty skyMapName;
StringProperty colorGradingMapName;
StringProperty volumetricCloudsWeatherMapName;
PropertyFunction(skyMapName)
PropertyFunction(colorGradingMapName)
PropertyFunction(volumetricCloudsWeatherMapName)
int IsOceanEnabled(lua_State* L);
int IsSimpleSky(lua_State* L);
int IsRealisticSky(lua_State* L);