DayZ 1.24
Loading...
Searching...
No Matches
EnPhysics.c
Go to the documentation of this file.
1
6typedef int[] dGeom;
7typedef int[] dJoint;
8typedef int[] dBlock;
9
10proto native int dGetNumDynamicBodies(notnull IEntity worldEnt);
11proto native IEntity dGetDynamicBody(notnull IEntity worldEnt, int index);
12proto native void dSetInteractionLayer(notnull IEntity worldEntity, int mask1, int mask2, bool enable);
13proto native bool dGetInteractionLayer(notnull IEntity worldEntity, int mask1, int mask2);
14
16proto native vector dGetGravity(notnull IEntity worldEntity);
18proto native void dSetGravity(notnull IEntity worldEntity, vector g);
20proto native void dSetTimeSlice(notnull IEntity worldEntity, float timeSlice);
21
27//proto native int dMaterialClone(string target, string source, int material_index)
28//proto native int dMaterialGetType(string source)
29//proto native int dMaterialSetType(string source, int material_index)
30
32{
33 string Name;
35 vector Frame[4] = {Vector(1, 0, 0), Vector(0, 1, 0), Vector(0, 0, 1), Vector(0, 0, 0)};
36 int ParentNode = -1;
38 int LayerMask; //<Bit mask of layers we are in
39
40
41 void PhysicsGeomDef(string name, dGeom geom, string materialName, int layerMask)
42 {
43 Name = name;
44 Geometry = geom;
45 MaterialName = materialName;
46 LayerMask = layerMask;
47 }
48};
49
58proto bool dBodyCreateStaticEx(notnull IEntity ent, PhysicsGeomDef geoms[]);
59proto bool dBodyCreateGhostEx(notnull IEntity ent, PhysicsGeomDef geoms[]);
60
71proto bool dBodyCreateDynamicEx(notnull IEntity ent, vector centerOfMass, float mass, PhysicsGeomDef geoms[]);
72
74proto native void dBodyDestroy(notnull IEntity ent);
75
77proto native bool dBodyIsSet(notnull IEntity ent);
78
79proto native void dBodySetInteractionLayer(notnull IEntity ent, int mask);
80proto native int dBodyGetInteractionLayer(notnull IEntity ent);
81proto native void dBodySetGeomInteractionLayer(notnull IEntity ent, int index, int mask);
82proto native int dBodyGetGeomInteractionLayer(notnull IEntity ent, int index);
83
91
92proto native void dBodyActive(notnull IEntity ent, ActiveState activeState);
93proto native void dBodyDynamic(notnull IEntity ent, bool dynamic);
94proto native bool dBodyIsDynamic(notnull IEntity ent);
95
96proto native bool dBodyIsActive(notnull IEntity ent);
97proto native bool dBodyEnableGravity(notnull IEntity ent, bool enable);
98proto native void dBodySetDamping(notnull IEntity ent, float linearDamping, float angularDamping);
99proto native void dBodySetSleepingTreshold(notnull IEntity body, float linearTreshold, float angularTreshold);
100
101proto native bool dBodyIsSolid(notnull IEntity ent);
102proto native void dBodySetSolid(notnull IEntity ent, bool solid);
103
111proto native void dBodyEnableCCD(notnull IEntity body, float maxMotion, float sphereCastRadius);
115proto native void dBodySetLinearFactor(notnull IEntity body, vector linearFactor);
116
118proto native vector dBodyGetCenterOfMass(notnull IEntity body);
119
132proto native vector GetVelocity(notnull IEntity ent);
133
139proto native void SetVelocity(notnull IEntity ent, vector vel);
140
144proto native dBlock dBodyCollisionBlock(notnull IEntity ent1, notnull IEntity ent2);
145proto native void dBodyRemoveBlock(notnull IEntity worldEntity, dBlock block);
146
147proto native void dBodySetInertiaTensorV(notnull IEntity body, vector v);
148proto native void dBodySetInertiaTensorM(notnull IEntity body, vector m[3]);
149
150proto native float dBodyGetMass(notnull IEntity ent);
151proto native void dBodySetMass(notnull IEntity body, float mass);
152
153proto native void dBodyApplyTorqueImpulse(notnull IEntity ent, vector torqueImpulse);
155proto native float dBodyComputeImpulseDenominator(notnull IEntity ent, vector position, vector normal);
156proto native float dBodyComputeAngularImpulseDenominator(notnull IEntity ent, vector axis);
157proto native vector dBodyGetLocalInertia(notnull IEntity ent);
158
159proto void dBodyGetInvInertiaTensorWorld(notnull IEntity body, out vector inertiaTensorWS[3]);
160
164proto void dBodyApplyImpulseAt(notnull IEntity body, vector impulse, vector pos);
165
169proto void dBodyApplyImpulse(notnull IEntity body, vector impulse);
170
174proto void dBodyApplyForce(notnull IEntity body, vector force);
175
179proto void dBodyApplyForceAt(notnull IEntity body, vector pos, vector force);
180
181proto native void dBodyApplyTorque(notnull IEntity body, vector torque);
182
187
193proto void dBodySetAngularVelocity(notnull IEntity body, vector angvel);
194
198proto native void dBodySetTargetMatrix(notnull IEntity body, vector matrix[4], float timeslice);
199proto native float dBodyGetKineticEnergy(notnull IEntity body);
200
201proto native vector dBodyGetVelocityAt(notnull IEntity body, vector globalpos);
203
210proto native dGeom dGeomCreateBox(vector size);
211
213proto native dGeom dGeomCreateSphere(float radius);
214
216proto native dGeom dGeomCreateCapsule(float radius, vector extent);
217
219proto native dGeom dGeomCreateCylinder(float radius, vector extent);
220
222proto native void dGeomDestroy(dGeom geom);
223
224//proto native int dBodyAddGeom(notnull IEntity body, dGeom geom, vector frame[4], string material, int interactionLayer);
225// find a geometry by its name and returns its index or -1 if the geometry wasn't found
226proto native int dBodyGetGeom(notnull IEntity ent, string name);
227// returns number of geometries of the entity
228proto native int dBodyGetNumGeoms(notnull IEntity ent);
230
236proto native dJoint dJointCreateHinge(notnull IEntity ent1, notnull IEntity ent2, vector point1, vector axis1, vector point2, vector axis2, bool block, float breakThreshold);
237proto native dJoint dJointCreateHinge2(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold);
238proto native dJoint dJointCreateSlider(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold);
239proto native dJoint dJointCreateBallSocket(notnull IEntity ent1, notnull IEntity ent2, vector point1, vector point2, bool block, float breakThreshold);
240proto native dJoint dJointCreateFixed(notnull IEntity ent1, notnull IEntity ent2, vector point1, vector point2, bool block, float breakThreshold);
241proto native dJoint dJointCreateConeTwist(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold);
242proto native dJoint dJointCreate6DOF(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold);
243proto native dJoint dJointCreate6DOFSpring(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold);
244proto native void dJointDestroy(dJoint joint);
245
246//only hinge joint
247proto native void dJointHingeSetLimits(dJoint joint, float low, float high, float softness, float biasFactor, float relaxationFactor);
248proto native void dJointHingeSetAxis(dJoint joint, vector axis);
249proto native void dJointHingeSetMotorTargetAngle(dJoint joint, float angle, float dt, float maxImpulse);
250
251//only cone-twist joint
252proto native void dJointConeTwistSetAngularOnly(dJoint joint, bool angularOnly);
253// setLimit(), a few notes:
254// _softness:
255// 0->1, recommend ~0.8->1.
256// describes % of limits where movement is free.
257// beyond this softness %, the limit is gradually enforced until the "hard" (1.0) limit is reached.
258// _biasFactor:
259// 0->1?, recommend 0.3 +/-0.3 or so.
260// strength with which constraint resists zeroth order (angular, not angular velocity) limit violation.
261// __relaxationFactor:
262// 0->1, recommend to stay near 1.
263// the lower the value, the less the constraint will fight velocities which violate the angular limits.
264proto native void dJointConeTwistSetLimit(dJoint joint, int limitIndex, float limitValue);
265proto native void dJointConeTwistSetLimits(dJoint joint, float _swingSpan1, float _swingSpan2, float _twistSpan, float _softness, float _biasFactor, float _relaxationFactor);
266
267//only 6DOF & 6DOFSpring.
274proto native void dJoint6DOFSetLinearLimits(dJoint joint, vector linearLower, vector linearUpper);
275proto native void dJoint6DOFSetAngularLimits(dJoint joint, vector angularLower, vector angularUpper);
276proto native void dJoint6DOFSetLimit(dJoint joint, int axis, float lo, float hi);
277
278//when stiffness == -1 && damping == -1, spring is disabled
279proto native void dJoint6DOFSpringSetSpring(dJoint joint, int axis, float stiffness, float damping);
280
281//only slider joint
282proto native void dJointSliderSetLinearLimits(dJoint joint, float lowerLimit, float upperLimit);
283proto native void dJointSliderSetAngularLimits(dJoint joint, float lowerLimit, float upperLimit);
284proto native void dJointSliderSetDirLinear(dJoint joint, float softness, float restitution, float damping);
285proto native void dJointSliderSetDirAngular(dJoint joint, float softness, float restitution, float damping);
286proto native void dJointSliderSetLimLinear(dJoint joint, float softness, float restitution, float damping);
287proto native void dJointSliderSetLimAngular(dJoint joint, float softness, float restitution, float damping);
288proto native void dJointSliderSetOrthoLinear(dJoint joint, float softness, float restitution, float damping);
289proto native void dJointSliderSetOrthoAngular(dJoint joint, float softness, float restitution, float damping);
290//if force == 0, motor is off
291proto native void dJointSliderSetLinearMotor(dJoint joint, float velocity, float force);
292proto native void dJointSliderSetAngularMotor(dJoint joint, float velocity, float force);
293proto native float dJointSliderGetLinearPos(dJoint joint);
294proto native float dJointSliderGetAngularPos(dJoint joint);
296
297//-----------------------------------------------------------------
298typedef int[] dMaterial;
299
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
TODO doc.
Definition EnScript.c:118
proto native float GetRelativeVelocityBefore(vector vel)
float PenetrationDepth
Definition EnPhysics.c:312
void PhysicsGeomDef(string name, dGeom geom, string materialName, int layerMask)
Definition EnPhysics.c:41
proto native void dJointSliderSetDirAngular(dJoint joint, float softness, float restitution, float damping)
proto native void dJointSliderSetAngularLimits(dJoint joint, float lowerLimit, float upperLimit)
proto native void dJointSliderSetLinearMotor(dJoint joint, float velocity, float force)
string MaterialName
Definition EnPhysics.c:37
int[] dMaterial
Definition EnPhysics.c:298
proto native void dJointSliderSetLimLinear(dJoint joint, float softness, float restitution, float damping)
proto native float GetRelativeVelocityAfter(vector vel)
float Impulse
Definition EnPhysics.c:314
proto native dJoint dJointCreateBallSocket(notnull IEntity ent1, notnull IEntity ent2, vector point1, vector point2, bool block, float breakThreshold)
proto native dJoint dJointCreateSlider(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold)
void Contact()
Definition EnPhysics.c:302
int MaterialIndex1
Definition EnPhysics.c:307
proto native dJoint dJointCreate6DOF(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold)
proto native dJoint dJointCreate6DOFSpring(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold)
dMaterial Material1
Definition EnPhysics.c:305
vector RelativeVelocityBefore
Definition EnPhysics.c:320
proto native void dJointHingeSetMotorTargetAngle(dJoint joint, float angle, float dt, float maxImpulse)
proto native void dJoint6DOFSetAngularLimits(dJoint joint, vector angularLower, vector angularUpper)
int Index2
Definition EnPhysics.c:310
vector Position
Definition EnPhysics.c:319
proto native void dJointSliderSetOrthoLinear(dJoint joint, float softness, float restitution, float damping)
void ~Contact()
Definition EnPhysics.c:303
proto native float dJointSliderGetAngularPos(dJoint joint)
proto native void dJointConeTwistSetAngularOnly(dJoint joint, bool angularOnly)
proto native void dJointSliderSetDirLinear(dJoint joint, float softness, float restitution, float damping)
vector Frame[4]
Definition EnPhysics.c:35
float RelativeNormalVelocityBefore
Definition EnPhysics.c:315
proto native float dJointSliderGetLinearPos(dJoint joint)
proto native void dJointSliderSetLimAngular(dJoint joint, float softness, float restitution, float damping)
vector Normal
Definition EnPhysics.c:318
float RelativeNormalVelocityAfter
Definition EnPhysics.c:316
proto native dJoint dJointCreateConeTwist(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold)
proto native dJoint dJointCreateFixed(notnull IEntity ent1, notnull IEntity ent2, vector point1, vector point2, bool block, float breakThreshold)
proto native void dJointHingeSetLimits(dJoint joint, float low, float high, float softness, float biasFactor, float relaxationFactor)
int MaterialIndex2
Definition EnPhysics.c:308
proto native void dJointConeTwistSetLimit(dJoint joint, int limitIndex, float limitValue)
proto native void dJointDestroy(dJoint joint)
proto native void dJointSliderSetOrthoAngular(dJoint joint, float softness, float restitution, float damping)
proto native void dJoint6DOFSetLinearLimits(dJoint joint, vector linearLower, vector linearUpper)
dMaterial Material2
Definition EnPhysics.c:306
proto native void dJointHingeSetAxis(dJoint joint, vector axis)
proto native void dJoint6DOFSetLimit(dJoint joint, int axis, float lo, float hi)
proto native vector GetNormalImpulse()
proto native void dJointConeTwistSetLimits(dJoint joint, float _swingSpan1, float _swingSpan2, float _twistSpan, float _softness, float _biasFactor, float _relaxationFactor)
proto native void dJoint6DOFSpringSetSpring(dJoint joint, int axis, float stiffness, float damping)
int Index1
Definition EnPhysics.c:309
proto native dJoint dJointCreateHinge(notnull IEntity ent1, notnull IEntity ent2, vector point1, vector axis1, vector point2, vector axis2, bool block, float breakThreshold)
proto native void dJointSliderSetLinearLimits(dJoint joint, float lowerLimit, float upperLimit)
proto native void dJointSliderSetAngularMotor(dJoint joint, float velocity, float force)
vector RelativeVelocityAfter
Definition EnPhysics.c:321
proto native dJoint dJointCreateHinge2(notnull IEntity ent1, notnull IEntity ent2, vector matrix1[4], vector matrix2[4], bool block, float breakThreshold)
proto native dGeom dGeomCreateCylinder(float radius, vector extent)
Creates cylinder geometry.
proto native dGeom dGeomCreateSphere(float radius)
Creates sphere geometry.
proto native dGeom dGeomCreateCapsule(float radius, vector extent)
Creates capsule geometry.
proto native int dBodyGetNumGeoms(notnull IEntity ent)
proto native int dBodyGetGeom(notnull IEntity ent, string name)
proto native void dGeomDestroy(dGeom geom)
Destroys geometry.
proto native dGeom dGeomCreateBox(vector size)
Creates box geometry.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
proto native void dSetInteractionLayer(notnull IEntity worldEntity, int mask1, int mask2, bool enable)
int[] dJoint
Definition EnPhysics.c:7
proto native IEntity dGetDynamicBody(notnull IEntity worldEnt, int index)
proto native int dGetNumDynamicBodies(notnull IEntity worldEnt)
int[] dGeom
Definition EnPhysics.c:6
proto native vector dGetGravity(notnull IEntity worldEntity)
Gets global gravity.
proto native bool dGetInteractionLayer(notnull IEntity worldEntity, int mask1, int mask2)
int[] dBlock
Definition EnPhysics.c:8
proto native void dSetTimeSlice(notnull IEntity worldEntity, float timeSlice)
Changes fixed time-slice. Default is 1/40, thus simulation runs on 40fps. With smaller values,...
proto native void dSetGravity(notnull IEntity worldEntity, vector g)
Changes global gravity.
proto native bool dBodyEnableGravity(notnull IEntity ent, bool enable)
proto native vector dBodyGetVelocityAt(notnull IEntity body, vector globalpos)
proto native void dBodyEnableCCD(notnull IEntity body, float maxMotion, float sphereCastRadius)
proto native void dBodyApplyTorque(notnull IEntity body, vector torque)
proto native void dBodyApplyTorqueImpulse(notnull IEntity ent, vector torqueImpulse)
proto bool dBodyCreateGhostEx(notnull IEntity ent, PhysicsGeomDef geoms[])
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
proto native void dBodySetSleepingTreshold(notnull IEntity body, float linearTreshold, float angularTreshold)
proto native int dBodyGetGeomInteractionLayer(notnull IEntity ent, int index)
proto native void dBodySetTargetMatrix(notnull IEntity body, vector matrix[4], float timeslice)
Sets target transformation. If timeslice == dt (simulation step delta time), it will happen in next s...
proto native void dBodyDestroy(notnull IEntity ent)
Destroys attached physics body.
proto native void dBodyActive(notnull IEntity ent, ActiveState activeState)
proto native bool dBodyIsActive(notnull IEntity ent)
proto native void dBodySetDamping(notnull IEntity ent, float linearDamping, float angularDamping)
proto void dBodyGetInvInertiaTensorWorld(notnull IEntity body, out vector inertiaTensorWS[3])
proto void dBodyApplyImpulse(notnull IEntity body, vector impulse)
Applies impuls on a rigidbody (origin)
proto native void dBodyDynamic(notnull IEntity ent, bool dynamic)
proto native void dBodySetSolid(notnull IEntity ent, bool solid)
proto native float dBodyComputeImpulseDenominator(notnull IEntity ent, vector position, vector normal)
proto bool dBodyCreateStaticEx(notnull IEntity ent, PhysicsGeomDef geoms[])
proto void dBodyApplyImpulseAt(notnull IEntity body, vector impulse, vector pos)
Applies impuls on a pos position in world coordinates.
proto native void dBodySetInteractionLayer(notnull IEntity ent, int mask)
proto bool dBodyCreateDynamicEx(notnull IEntity ent, vector centerOfMass, float mass, PhysicsGeomDef geoms[])
proto native void dBodySetInertiaTensorV(notnull IEntity body, vector v)
proto native float dBodyGetKineticEnergy(notnull IEntity body)
proto native vector dBodyGetLocalInertia(notnull IEntity ent)
proto native void dBodySetMass(notnull IEntity body, float mass)
proto native vector dBodyGetCenterOfMass(notnull IEntity body)
returns center of mass offset
proto native void SetVelocity(notnull IEntity ent, vector vel)
Sets linear velocity (for Rigid bodies)
proto native void dBodySetLinearFactor(notnull IEntity body, vector linearFactor)
proto native void dBodySetInertiaTensorM(notnull IEntity body, vector m[3])
proto native vector dBodyGetInvInertiaDiagLocal(notnull IEntity ent)
proto native float dBodyGetMass(notnull IEntity ent)
proto void dBodySetAngularVelocity(notnull IEntity body, vector angvel)
Changed an angular velocity.
proto native float dBodyComputeAngularImpulseDenominator(notnull IEntity ent, vector axis)
proto native void dBodySetGeomInteractionLayer(notnull IEntity ent, int index, int mask)
proto native bool dBodyIsDynamic(notnull IEntity ent)
proto vector dBodyGetAngularVelocity(notnull IEntity body)
Gets angular velocity for a rigidbody.
proto native bool dBodyIsSet(notnull IEntity ent)
Has the entity attached physics body?
proto void dBodyApplyForce(notnull IEntity body, vector force)
Applies constant force on a rigidbody (origin)
ActiveState
state of a rigidbody
Definition EnPhysics.c:86
proto native dBlock dBodyCollisionBlock(notnull IEntity ent1, notnull IEntity ent2)
Disables collisions between two entities.
proto native void dBodyRemoveBlock(notnull IEntity worldEntity, dBlock block)
proto void dBodyApplyForceAt(notnull IEntity body, vector pos, vector force)
Applies constant force on a position.
proto native bool dBodyIsSolid(notnull IEntity ent)
proto native int dBodyGetInteractionLayer(notnull IEntity ent)
@ ACTIVE
Definition EnPhysics.c:87
@ INACTIVE
Definition EnPhysics.c:88
@ ALWAYS_ACTIVE
Definition EnPhysics.c:89