EntityPick, EntityAlpha, EntityOrder

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
auser
Enthusiast
Enthusiast
Posts: 195
Joined: Wed Sep 06, 2006 6:59 am

EntityPick, EntityAlpha, EntityOrder

Post by auser »

EntityPick(EntityID,range)
What: Returns the nearest entity ahead of the specified entity
Why: For example to avoid that one tank is shooting another one if a huge building is between them and would make shooting at that moment looks like cheating or like your NPC doesn't have much brain or to avoid your spaceship-turret is shooting through your own ship if the enemy is flying around you.

Code: Select all

if EntityDistance(enemyEntity,victimEntity) < maxrange And EntityPick(myEntity,maxrange) = my_expected_victim
  createBullet()
else
  search_for_victim()
endif 

EntityAlpha(entityID,value)
What: Make it possible to fade the alpha from an entity by value.
Why: For example if a spaceship owns a shild (a sphere-mesh bigger then the ship-mesh) that should protect it from bullets but is just visible when it's hit by something and should fade out slowly to invisible state again afterwards.

Code: Select all

if myship_collision = 1
  shieldAlpha.f = 0.5
  EntityAlpha(shieldSphereID,shieldAlpha.f)
else
  if shieldAlpha.f  > 0
    shieldAlpha.f = shieldAlpha.f - 0.1
    EntityAlpha(shieldSphereID,shieldAlpha.f)
  endif
endif

EntityOrder(entityID,RenderOrderNumber)
What: Specify when the entity should be drawn to make it able to push objects visible in the far distance (even if they are not so far away to get out of range). I know this from Blitz3D - don't know if something similiar is possible with Ogre as well
Why: For example to glue a small moon-sphere or some shaded atmosphere-plane relative to your players camera that would be drawn always behind your terrain and even your clouds or glowing bullets that are flying far away, ... So even if it's always near your players cam it always looks huge and in the far distance because it's drawn before the other stuff. That would even make it easy to avoid your "moon" would be cut by your terrain by mistake if you have a wide visible range. It's similar to some skybox ... but even should be able to be visible behind your sky.

Code: Select all

EntityOrder(Stars_SkyDomeEntity,4)
EntityOrder(Moon_RotatingSphereEntity,3)
EntityOrder(Atmosphere_PlaneEntity,2) ; Transparent shaded Sprite or Plane drawn in front of the cam
EntityOrder(Clouds_Planeentity,1) ; Sprite or Plane somewhat above the cam that should never be able to cut the Atmosphere
Foreach everything_else()
  EntityOrder(everything_else()\entity,0) ; default anyway for everything else
Next

Greetings,
auser
troy
User
User
Posts: 51
Joined: Sat May 31, 2003 2:59 pm

Re: EntityPick, EntityAlpha, EntityOrder

Post by troy »

+1 for EntityAlpha(entity.l, alpha.f)! It would be nice to have such function in the 3D command-set. It's a pretty commonly used function in many other 3D engines. I wonder why OGRE/PB still doesn't have it.
--
troy
Post Reply