Jump to content

CameraUnproject Entity Labels


Marleys Ghost
 Share

Recommended Posts

First, how did I set up the overhead labels for the NPC's (and player) as seen in this video.

 

 

I think this was the easiest part of that particular exercise. It was managed in the 2D drawing section of the main loop (just before the Flip() command) using the CameraUnproject command:

 

SetBlend(BLEND_ALPHA)
SetColor(Vec4(0,1,0,1))
Local Label:TVec3 = EntityPosition(player)
Local playerlabel:TVec3 = CameraUnproject(fw.Main.camera, Vec3(Label.x, Label.y+5, Label.z))
DrawText("Player", playerlabel.x, playerlabel.y)
SetColor(Vec4(1,1,1,1))
SetBlend(0)

 

For the NPC's I added a check to see if that particular NPC was culled or not, otherwise you end up with NPC labels floating all over the place like a swarm of bees. This was easy to implement using the EntityCulled command:

 

SetBlend(BLEND_ALPHA)
SetColor(Vec4(1,0,0,1))	
Local Label:TVec3 = EntityPosition(BUG)
Local NPClabel:TVec3 = CameraUnproject(fw.Main.camera, Vec3(Label.x, Label.y+4, Label.z))
If EntityCulled( BUG, fw.Main.camera) = 0
DrawText("Bug", NPClabel.x, NPClabel.y)
End If
SetColor(Vec4(1,1,1,1))
SetBlend(0)

 

The main reason I was using labels was basically to keep an eye on what a bug was "thinking". I hope this will be of some use to someone.

 

The second request was for a demo .exe of the app from the video, I have uploaded a demo here:

 

 

http://www.megaupload.com/?d=OL1WYURM

 

 

Set the screen resolution, number of bugs, post FX, music and stats via the applications launcher. WASD to move shift to run space to jump. Or use my lazy move by pressing the right mouse button. The mouse wheel will zoom in and out from a first person POV to third and then on to CIA spy satellite mode lol

 

One of the best ways to learn the engine, for me was to go through all the commands found HERE one at a time, see what they do, have a play and think about how they could be used.

  • Upvote 1

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

Additional tip:

 

If you want to centre your label, above the models origin, in this instance for the player, change:

 

 

DrawText("Player", playerlabel.x, playerlabel.y) 

to:

 

DrawText("Player", playerlabel.x-TextWidth("Player")/2, playerlabel.y)

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

Hi Pix, well I never really left, just busy with my project "elsewhere" so to speak, but had to go through a load of assets to convert to a "particular" format and came across my Bmax code archives and thought some might be of use to others in the Bmax community here, glad it was. Have some more for later and will probably stumble across other things tucked away. :lol:

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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.

 Share

×
×
  • Create New...