Thread Tools Display Modes
12-17-22, 08:04 PM   #1
fatrog
A Fallenroot Satyr
Join Date: Nov 2022
Posts: 21
Add frame in world view (like worldframe?)

Hello,

I'd like to create a small addon to add images on top of group members characters (eg. above nameplate). What do I need to read to learn how to do that? I have ended up playing around with the parent frame worldframe from the api

Lua Code:
  1. CreateFrame("Frame", nil, WorldFrame)

Is this the right way to go? If so, how do I set the coordinate to match the position above characters head? I can't find infos about it. I looked up nameplates addon to get inspiration, but I don't find what I'm looking for (or maybe just I don't know what to look at x) )

Thanks for any help
  Reply With Quote
12-17-22, 09:05 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
In general, you can't render anything in the 3D game world and in the past, Blizzard has taken steps to block attempts to make UI elements from appearing so.



The way NamePlates are handled is special. They're generated in two parts. First the C code creates an invisible frame in the UI system and does all the 3D translation into the 2D screenspace. This invisible frame is then handed to Lua through the NAMEPLATE_CREATED event. They are often reused as they exit and reenter view and are signaled as such by NAMEPLATE_ADDED and NAMEPLATE_REMOVED.

The DefaultUI listens for these and attaches a dummy CompactUnitFrame to them. These UnitFrames have their click handler disabled and clicks are actually processed by the invisible frame they're attached to.

See AddOns\Blizzard_NamePlates for the DefaultUI side of this.

Note NamePlates are the health bars that pop up when you get close to something if you have them enabled. The name text that's visible when NamePlates aren't there is rendered in the 3D world and can't be interacted with.



PS: Parenting to WorldFrame or the screenspace itself (represented by nil) just makes your frame ignore the UI scale setting, which is applied to UIParent. The base screenspace has a static height of 768 and a variable width depending on aspect ratio.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
12-20-22, 09:51 AM   #3
fatrog
A Fallenroot Satyr
Join Date: Nov 2022
Posts: 21
Ok, thank you so much for this great answer. I'll scour the Blizzard_NamePlates api.

So I guess I have to "cheat" to perform what I'm trying to do. I'll use distance with target, but I miss an information which is angle. Is there a way to raytrace the pov (or any other method) to know the view angle related to a target? If I could get this info, I could simple make a classic frame, print it on the lower background and move it with the pov events
  Reply With Quote
12-20-22, 09:38 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
People used to save the camera position into the presets and read the CVars related to them, but that was the first thing Blizzard blocked. Later they removed getting the character pitch, which broke a flight HUD addon I made a long time ago that would be really useful for today's dragonriding mechanic.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
12-22-22, 09:50 AM   #5
fatrog
A Fallenroot Satyr
Join Date: Nov 2022
Posts: 21
oh ok my dream addon sink into oblivion then

Thank you for your answers, that was very kind of you (and sorry for your addon)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Add frame in world view (like worldframe?)

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off