multiple labels for moving 3d objects
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:
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:
Code: Select all
Vector3 scPos = Camera.main.WorldToScreenPoint(this.mSelectedObject.transform.position);
this.mSelLblTrans.SetX(scPos.x - 28);
this.mSelLblTrans.SetY(Camera.main.pixelHeight - scPos.y - 7);
Re: multiple labels for moving 3d objects
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.
Assume maybe 20 on screen at a time maximum.
-
-
sfernandez
Site Admin
- Posts: 2065
- Joined:
Re: multiple labels for moving 3d objects
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.
The only justification for having a render texture for each label is if you want that labels can be occluded by other 3D objects.
Re: multiple labels for moving 3d objects
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.
Re: multiple labels for moving 3d objects
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.
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.
Re: multiple labels for moving 3d objects
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.
-
-
sfernandez
Site Admin
- Posts: 2065
- Joined:
Re: multiple labels for moving 3d objects
Could you please attach an image of what you are trying to achieve?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.
This way I can understand better your scenario and can help you with the xaml.
Maybe is something like this screenshot: