Well, I've wanted to do this for a bit, but just about eleven days ago I decided to begin working on it. The actual programming started probably about nine days ago or so. Anyways, without further ado...
XenoPhysics
This is a plugin aimed at programmers who wish to have professional control over the dynamics within their games. This plugin utilizes Havok Physics and Havok Animation, two extremely high quality dynamics libraries. Havok supports outstanding rigid body physics, as well as amazing Character control and vehicle simulation. If you have ever played: Half-Life 2, Counter-Strike: Source, Team Fortress 2, Portal, Left 4 Dead, Left 4 Dead 2, Halo 2, Halo 3, Halo 3: ODST, Dead Rising, BioShock, Condemned 2, Dead Space, Fallout 3, The Elder Scrolls IV: Oblivion, Far Cry 2 then you have definitely used Havok.
As of right now I have implemented 96 commands within XenoPhysics. These include commands for rigid bodies, character controllers, and vehicles.
Some features I wish to highlight:
Character Controllers
Very high quality
Ability to move objects (but not infinitely strong)
Integrated ability to move forward, backward, left, and right.
Integrated ability to jump.
Integrated ability to crouch.
Integrated ability to climb ladders (ladders can be any rigid body that you call the "xeno set rigid body as ladder" command on)
Vehicles
Amazing amounts of variables to be set - optional. You can set data about the vehicles engine, it's transmission, it's aerodynamics, it's steering, each individual wheel (you can have an arbitrary amount of wheels also. You can have as many axles as you want as well and apply wheels to each axle)
Integrated vehicle camera command set - simply call "xeno make camera" and then position and point your camera with the following commands:
xeno get camera position x(id)
xeno get camera position y(id)
xeno get camera position z(id)
xeno get camera point x(id)
xeno get camera point y(id)
xeno get camera point z(id)
This allows for seamless vehicle integration into DarkBasic Professional. Gone are the days where it takes you lines upon lines of code to create vehicles. You can do that with just one line now, with the preset vehicles I am including.
Simple command set for controlling vehicles:
xeno vehicle accelerate id, amount
xeno vehicle turn id, amount
xeno vehicle reverse id
xeno vehicle hand brake id
Presets for vehicles will include (will most likely expand):
Four wheeled vehicle
Six wheeled vehicle
Motorcycle
Tank
This plugin will allow you to finally achieve the professional quality physics you see in games today. Ever wanted a game to control like Halo? Well now it's feasible with my plugin. You no longer have to mess with intricate forces to move your player correctly, or deal with your character being simply incapable of certain tasks.
For now that is all I have implemented. This is a complete list of commands within my plugin at the moment:
xeno start
xeno start Flag
xeno start Flag, BroadPhaseWorldSize
xeno start Flag, BroadPhaseWorldSize, MemoryAllocation
xeno set gravity Gravity
xeno set gravity GravityX, GravitY, GravityZ
xeno set time step TimeStep
xeno update
xeno end
xeno make rigid body static box ID
xeno make rigid body static sphere ID
xeno make rigid body static cylinder ID
xeno make rigid body static capsule ID
xeno make rigid body static mesh ID
xeno make rigid body dynamic box ID
xeno make rigid body dynamic box ID, Mass
xeno make rigid body dynamic sphere ID
xeno make rigid body dynamic sphere ID, Mass
xeno make rigid body dynamic cylinder ID
xeno make rigid body dynamic cylinder ID, Mass
xeno make rigid body dynamic capsule ID
xeno make rigid body dynamic capsule ID, Mass
xeno delete rigid body ID
xeno set rigid body position ID, X, Y, Z
xeno set rigid body rotation ID, X, Y, Z
xeno set rigid body mass ID, Mass
xeno set rigid body linear velocity ID, X, Y, Z
xeno get rigid body linear velocity x(ID)
xeno get rigid body linear velocity y(ID)
xeno get rigid body linear velocity z(ID)
xeno set rigid body angular velocity ID, X, Y, Z
xeno get rigid body angular velocity x(ID)
xeno get rigid body angular velocity y(ID)
xeno get rigid body angular velocity z(ID)
xeno get rigid body point velocity x(ID, X, Y, Z)
xeno get rigid body point velocity y(ID, X, Y, Z)
xeno get rigid body point velocity z(ID, X, Y, Z)
xeno add rigid body linear impulse ID, X, Y, Z
xeno add rigid body point impulse ID, X, Y, Z, PointX, PointY, PointZ
xeno add rigid body angular impulse ID, X, Y, Z
xeno set rigid body linear damping ID, Damping
xeno get rigid body linear damping(ID)
xeno set rigid body angular damping ID, Damping
xeno get rigid body angular damping(ID)
xeno set rigid body gravity factor ID, Gravity
xeno get rigid body gravity factor(ID)
xeno set rigid body max linear velocity ID, MaxVelocity
xeno get rigid body max linear velocity(ID)
xeno set rigid body max angular velocity ID, MaxVelocity
xeno get rigid body max angular velocity(ID)
xeno set rigid body allowed penetration depth ID, Depth
xeno get rigid body allowed penetration depth(ID)
xeno set rigid body friction ID, Friction
xeno get rigid body friction(ID)
xeno set rigid body restitution ID, Restitution
xeno get rigid body restitution(ID)
xeno set rigid body as ladder ID, Flag
xeno is rigid body ladder(ID)
xeno make character controller ID, Height, Radius
xeno make character controller ID, Height, Radius, CrouchHeight
xeno make character controller ID, Height, Radius, CrouchHeight, Speed
xeno make character controller ID, Height, Radius, CrouchHeight, Speed, JumpHeight
xeno make character controller ID, Height, Radius, CrouchHeight, Speed, JumpHeight, Strength
xeno make character controller ID, Height, Radius, CrouchHeight, Speed, JumpHeight, Strength, MaxSlope
xeno delete character controller ID
xeno set character controller position ID, X, Y, Z
xeno get character controller position x(ID)
xeno get character controller position y(ID)
xeno get character controller head position(ID)
xeno get character controller position z(ID)
xeno set character controller rotation ID, Angle
xeno get character controller rotation ID
xeno move character controller forward ID
xeno move character controller backward ID
xeno move character controller left ID
xeno move character controller right ID
xeno character controller jump ID
xeno character controller crouch ID
xeno enable character controller ID
xeno disable character controller ID
xeno make vehicle ID
xeno vehicle accelerate ID, Speed
xeno vehicle turn ID, Speed
xeno vehicle reverse ID
xeno vehicle hand brake ID
xeno make camera ID
xeno get camera position x(ID)
xeno get camera position y(ID)
xeno get camera position z(ID)
xeno get camera point x(ID)
xeno get camera point y(ID)
xeno get camera point z(ID)
xeno get camera fov(ID)
Those are all the commands for now. Assuming I didn't forget anything, if you have questions let me know.
For now, I'll leave you with a very very basic demo I wrote in about two minutes as well as its source code so you can see what a program written with this plugin looks like. You need the latest DirectX redistributable installed (august I think)
Please note - the demo is not supposed to be flashy. At all. It is graphically dull, in fact. The beauty lies within the physics.
If there are problems with the demo let me know.
Controls:
Controls while in vehicle:
w - accelerate
s - reverse
a - turn left
d - turn right
space - brake
left mouse button + right mouse button - get out of vehicle
Controls while on foot:
w - move forward
s - move backward
a - move left
d - move right
space - jump
control - crouch
left mouse button only - get in vehicle
Code:
sync on
sync rate 60
xeno start
rem Create Ground
make object box 1, 300, 1, 300
xeno make rigid body static box 1
make object box 2, 4, 1, 2
color object 2, rgb(0, 40, 128)
xeno make rigid body dynamic box 2
xeno set rigid body position 2, 0, 2, 5
xeno make vehicle 2, 2
xeno make camera 2, 2
make object cube 3, 1
color object 3, rgb(0, 128, 0)
xeno make rigid body dynamic box 3
xeno set rigid body position 3, 5, 4, 0
make object cube 4, 1
color object 4, rgb(0, 128, 0)
xeno make rigid body dynamic box 4
xeno set rigid body position 4, 10, 2, 0
xeno make character controller 1, 1, 1, 0.5, 10, 2, 150
xeno set character controller position 1, 0, 4, 0
xeno disable character controller 1
cameraX as float
cameraY as float
cameraZ as float
yAngle as float
xAngle as float
lookSpeed as float = 0.2
inVehicle as integer = 1
hide mouse
do
position mouse screen height() / 2, screen width() / 2
xeno update
if inVehicle = 0 and mouseclick() = 1
inVehicle = 1
xeno disable character controller 1
endif
if inVehicle = 1 and mouseclick() = 3
inVehicle = 0
xeno enable character controller 1
x# = object position x(2)
y# = object position y(2) + 2
z# = object position z(2)
yAngle = 0
xAngle = 0
xeno set character controller position 1, x#, y#, z#
endif
if (inVehicle = 1)
if keystate(17)
xeno vehicle accelerate 2, -1
endif
if keystate(31)
xeno vehicle accelerate 2, 1
endif
if keystate(30)
xeno vehicle turn 2, 2
endif
if keystate(32)
xeno vehicle turn 2, -2
endif
if spacekey()
xeno vehicle hand brake 2
endif
cameraX = xeno get camera position x(2)
cameraY = xeno get camera position y(2)
cameraZ = xeno get camera position z(2)
px# = xeno get camera point x(2)
py# = xeno get camera point y(2)
pz# = xeno get camera point z(2)
point camera px#, py#, pz#
else
if keystate(17)
xeno move character controller forward 1
endif
if keystate(31)
xeno move character controller backward 1
endif
if keystate(30)
xeno move character controller left 1
endif
if keystate(32)
xeno move character controller right 1
endif
if spacekey()
xeno character controller jump 1
endif
if controlkey()
xeno character controller crouch 1
endif
cameraX = xeno get character controller position x(1)
cameraY = xeno get character controller head position(1)
cameraZ = xeno get character controller position z(1)
yAngle = wrapvalue(yAngle + mousemovex() * lookSpeed)
xAngle = wrapvalue(xAngle + mousemovey() * lookSpeed)
xeno set character controller rotation 1, yAngle
rotate camera xAngle, yAngle, 0
endif
position camera cameraX, cameraY, cameraZ
sync
loop
Looking forward to any responses! (I wish there was a preview post option...)
XenoPhysics - A Havok Wrapper for DarkBasic Pro. In progress.