tiggus
Topic Author
Posts: 12
Joined: 14 Oct 2013, 18:31

multiple labels for moving 3d objects

24 Oct 2013, 00:28

I'm trying to figure out the best way to assign name labels and healthbars to multiple 3d objects in my scene in conjunction with my fairly static 2d ui.

Looking at the Primitives sample it looks like you are setting x and y position of the label manually every update, is this the most efficient or is there a way to parent the label to a 3d object? I'm still a bit unclear as to whether I can/should do this with Projection or not.

here is the snippet from Primitives which I am referencing where you update position of the "Selected" textblock every frame:
Vector3 scPos = Camera.main.WorldToScreenPoint(this.mSelectedObject.transform.position);
this.mSelLblTrans.SetX(scPos.x - 28);
this.mSelLblTrans.SetY(Camera.main.pixelHeight - scPos.y - 7);
 
tiggus
Topic Author
Posts: 12
Joined: 14 Oct 2013, 18:31

Re: multiple labels for moving 3d objects

24 Oct 2013, 07:48

May have answered my own question but if you can confirm, it looks like the best approach might be to simply parent a billboard plane to the 3d objects(characters) and apply a RenderTexture to them. My only concern is this will result in a NoesisPanel per character, will this have any adverse effects?

Assume maybe 20 on screen at a time maximum.
 
User avatar
sfernandez
Site Admin
Posts: 1920
Joined: 22 Dec 2011, 19:20

Re: multiple labels for moving 3d objects

24 Oct 2013, 12:54

I think that the Primitives sample approach will be more efficient. Updating the position of 20 UI elements shouldn't be a costly operation (probably you are already updating the 20 healthbars each frame).

The only justification for having a render texture for each label is if you want that labels can be occluded by other 3D objects.
 
tiggus
Topic Author
Posts: 12
Joined: 14 Oct 2013, 18:31

Re: multiple labels for moving 3d objects

25 Oct 2013, 00:47

Well it is not just occlusion but also problematic for scaling the size of the health bar and name. If the user zooms the camera in/out or the character walks into the distance the ui control is going to remain the same size and not scale with the character.
 
User avatar
jsantos
Site Admin
Posts: 2907
Joined: 20 Jan 2012, 17:18
Contact:

Re: multiple labels for moving 3d objects

26 Oct 2013, 19:36

Having a NoesisGUI panel per character is not problematic per se. The problem is that you need a Texture for each panel (in fact a render texture, that are less efficient). In your case, you mention 20 visible characters, but I imagine that you could have thousands of characters not visible. We manage the visibility of NoesisGUI panel (they are ignored when they are out of camera) but having thousand of textures doesn't seem to be a good idea. You would have to implement a mechanism to swap in/out the textures used for the visible characters. Another minor detail is that your GUI won't scale as you zoom in/out (because you are always rendering to a fixed resolution texture).

For the alternative, using a XAML and updating the positions of each panel, you could use a parent 3D matrix in the xaml that matches your camera matrix. We don't have a sample for this yet but it should be easy to setup.
 
tiggus
Topic Author
Posts: 12
Joined: 14 Oct 2013, 18:31

Re: multiple labels for moving 3d objects

27 Oct 2013, 18:39

Thanks for the detailed reply, if you could provide an example of the matrix approach I think it would be helpful to quite a few people since this requirement(character labels) is quite common.
 
User avatar
sfernandez
Site Admin
Posts: 1920
Joined: 22 Dec 2011, 19:20

Re: multiple labels for moving 3d objects

02 Nov 2013, 00:32

Thanks for the detailed reply, if you could provide an example of the matrix approach I think it would be helpful to quite a few people since this requirement(character labels) is quite common.
Could you please attach an image of what you are trying to achieve?
This way I can understand better your scenario and can help you with the xaml.

Maybe is something like this screenshot:
DawngateUI.jpg

Who is online

Users browsing this forum: No registered users and 1 guest