Jump to content
Aily

minib3d (Blitz3D) collisions in Leadwerks (bMax only)

Recommended Posts

Ok, it was long time ago when i start my gamedev playing with Blitz3D.

It have very simple commands, and make casual game on it very easy.

 

When i bought Leadwerks it was very cool that it's handle most Blitz3D commands, and same handy for me.

 

But...

 

Collisions system some confused me. But nothing was to do - i start to use Leadwerks Newton based collisions.

 

It realy rocks! Anyone want to have realistic physics in personal project.

 

But Newton have some complexity in charachter controls, that's why Josh maked his own. All cool, Leadwerks controller very good for FPS games, or strategy, RPG - where charachter must walk on ground and be realistic.

 

Working with Last Chapter and couple external projects i was found some complex places in charachter controller:

 

1. Swept collisions doesn't working

 

a: If i will make game where my hero can fall from high places - he will fly by through florground (someone here saw this bug when robot in Last Chapter stacking in blocks)

 

b: If enemy can punch player - it make very much velocity to push charachter controller, and player can just fly through thinn wall behind him.

 

2. If geometry of stair vertical faces will be not 90 degrees (0,1,0 vector), controller can handle it as heavy slope, and don't want to walk there

 

You can put small boxes (bricks) to ground, and little turn it randomly - controller will stacking in it, and "step height" value doesn't matter to him.

 

3. Casual games need casual charachter, and in 2.5D jump'n'run platformer - some complex to stay controller on one value by axis, but leave physics responce to it.

 

If geometry of physics world in such game will be not perpendicular each other - it make controller slide to leftright, and put it to z=0 value not be so handy.

 

Or lets say it will by TDS when you fly by helicopter on one height from earth - collision with ground mountains will slide controller topdown. Same problem.

 

4. Controller have rectangle form by side

 

Ok, we making RPG for example, and our hero walk little out platform, as i expecting - it slide down from it, but default controller will still stay over platform break. (Seems like Quake2 known bug)

 

Ufff... it's harder on not native languge when i thinking in top of text smile.png

 

What can i say, minib3d (Blitz3D) collisions not so powerfull as Newton system, but, as answers on my notes:

 

1. minib3d collisions always swept

2. Moveble body in minib3d is sphere or egg, so it good working with rough geometry

3. Wee simple PositionEntity body,entityx(body),entityy(body),0 and it never go anyway from z=0

4. Egg form, do you remember wink.png

 

....

 

At last i connected minib3d and Leadwerks, it have same commands and conflict with each other, so i little rewrote minib3d library. Now there each command have "bb" prefix, and types too

 

Like

 

cam=bbCreateCamera()
bbMoveEntity cam,0,0,-10

 

or

 

 

ent:bbtEntity=bbCreateCube()

 

Leadwerks as you guess can be any version.

 

So code to connect them is very simple - i calculating moving of minib3d bodies, next set Leadwerks meshes to minib3d bodies positions.. and i have Blitz3D with full Leadwerks featurestongue.png

 

tiny example

 

' init both Leadwerks and minib3d
Framework leadwerks.engine
Import sidesign.minib3d

registerabstractpath AppDir	   ' Leadwerks

' Helper function to get position/rotation of minib3d tEntity and set it to Leadwerks tEntity
Global tmp:tvec3=vec3()
Function align_as(lw_entity:tentity,bb_entity:bbtentity)

tmp.x=bbentityx(bb_entity)
tmp.y=bbentityy(bb_entity)
tmp.z=bbentityz(bb_entity)
PositionEntity lw_entity,tmp

tmp.x=bbentitypitch(bb_entity)
tmp.y=bbentityyaw(bb_entity)
tmp.z=bbentityroll(bb_entity)
RotateEntity lw_entity,tmp
End Function

' basic inits
Graphics 800,600		 ' Leadwerks
createworld		   ' Leadwerks

lw_cam=CreateCamera()		' Leadwerks
MoveEntity lw_cam,vec3(0,0,-2)	  ' Leadwerks

' createing minib3d pivot and Leadwerks cube, in main loop we will rotate minib3d pivot, and set Leadwerks cube to this pivot orientation
bb_body=bbCreatePivot()		' minib3d
lw_cube=CreateCube()		' Leadwerks

Repeat
If KeyHit(key_escape) Or AppTerminate() End

bbturnentity bb_body,1,2,3	  ' minib3d
align_as lw_cube,bb_body

RenderWorld		  ' Leadwerks

Flip 1
Forever

 

complied minib3d module - just unpack to mod folder (ahh, known minib3d bug with TurnEntity there fixed wink.png)

 

To see minib3d API - just look at Blitz3D online help

sidesign.mod.rar

Share this post


Link to post

This is nice :)

I tried something similar a while ago, with just feeding the minib3d colision tree (wich is written in cpp as far as i remember) with a leadwerks surface. But this was not working like i wanted, your solution looks smarter.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...