[Help Request]Display a text over a SceneNode

Nexam

01-09-2008 22:37:18

I want to Display a text over a SceneNode (Like Name in Wow)

I have looking on the Wiki.. I found very usefull thinks like that:

http://www.ogre3d.org/wiki/index.php/MovableText
But it's in C++ and i can't translate it to C#...

Other way, get X,Y screen coord of a Mesh in order to display an overlay:
public static bool ProjectSizeAndPos(Camera cam, Vector3 pos, float rad, out float x, out float y, out float cx, out float cy)
{
Vector3 eyeSpacePos = cam.GetViewMatrix(true) * pos;
// z < 0 means in front of cam
if (eyeSpacePos.z < 0)
{
// calculate projected pos
Vector3 screenSpacePos = cam.ProjectionMatrix * eyeSpacePos;
x = screenSpacePos.x;
y = screenSpacePos.y;
// calculate projected size
Vector3 spheresize = new Vector3(rad, rad, eyeSpacePos.z);
spheresize = cam.ProjectionMatrix * spheresize;
cx = spheresize.x;
cy = spheresize.y;
return true;
}
else
{
cx = 0;
cy = 0;
x = (-eyeSpacePos.x > 0) ? -1 : 1;
y = (-eyeSpacePos.y > 0) ? -1 : 1;
return false;
}
}


but i didn't find way to use it correctly too....



Some Help ?

ultra2

21-09-2008 17:51:41

I have the same problem...

I am trying to rewrite the c++ code to c#. ( http://www.ogre3d.org/wiki/index.php/MovableText ).

help if sy has solution pls!

WarehouseJim

22-09-2008 11:37:43

I'm going to have to the same thing soon.... unfortunately not just now, so I can't help too much, but I'll see if I can get a chance to flick through the C++ and give some pointers.

Beauty

22-09-2008 12:07:13

It would be also interesting to me (and many other users I think).

But I not even could port a smaller code. (I know only less about C++)
The most I have done for the Easy debug text snippit.
Here is my try (to a similar problem).
http://www.ogre3d.org/wiki/index.php/Mo ... ng_example

Beauty

22-09-2008 12:30:34

For your second way - maybe this will help you. It works with a ray query between the object and the camera.
http://www.ogre3d.org/wiki/index.php/MO ... ingExample

Bostich

23-09-2008 20:42:20

Hi Guys,

some good an some bad news :P

the good one first:

I finally made it to compile Mogre with the new class MovableText. (olee :D, was very painfuel^^).

the bad news:

i can see the text, everything looks good, expected the fuckin fact that the text always displays _BELOW_ the attached node -.-.

I really dont know why^^

anyway here is the compiled mogre version with movabletext class

http://www.file-upload.net/download-1133075/Release.rar.html

It's scanned with antivir, but feel free to scan it again (who knows? :8)


last but not least, little codesnipped to use it :P

Entity ent = base._sceneMgr.CreateEntity("Robot", "robot.mesh");
SceneNode node = base._sceneMgr.RootSceneNode.CreateChildSceneNode("RobotNode");
node.AttachObject(ent);
_camera.LookAt(node.Position);
MovableText msg = new MovableText("txt001", "Terminator","BlueHighway",4,new ColourValue(200,50,200));
msg.SetTextAlignment(MovableText.HorizontalAlignment.H_CENTER, MovableText.VerticalAlignment.V_ABOVE);//this seems useless,coz always below in game
msg.AdditionalHeight = 2.0f;

node.AttachObject(msg);


Bostich

//edit:
Oh it works like a charm :


msg.AdditionalHeight = 80.0f


will do the "trick" 8)

Beauty

24-09-2008 01:34:10

very nice :D

Can you please publish your ported source code?
I would like to add it to the wiki.

The source code would be better than the compiled library.
Then it's independent from further Ogre versions and code improvements are possible. Also it's good to have, if someone made individually changes to the Mogre code and want to compile it with MovableText, too.



:!:... oh, just in the moment I see that GermanDZ added a port of MovableText to the Wiki.
www.ogre3d.org/wiki/index.php/MOGRE_MovableText

Is this the code you used or did you do a second port?

Beauty

24-09-2008 01:50:52

By the way:

It's not recommended to use Ogre internal members (Sinbad told me that). Ogre internals begins with underscore (e.g. _sceneMgr)

So better store the reference to the SceneManager in a variable at creating and use the methods with it.
Use this code instead of that above:
// create
SceneManager sceneMgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC);
Camera cam = sceneMgr.CreateCamera("Camera");
// ...
// use
Entity ent = base.sceneMgr.CreateEntity("Robot", "robot.mesh");
SceneNode node = sceneMgr.RootSceneNode.CreateChildSceneNode("RobotNode");
node.AttachObject(ent);
cam.LookAt(node.Position);

Bostich

24-09-2008 07:40:21

Hi Beauty,

Exclamation... oh, just in the moment I see that GermanDZ added a port of MovableText to the Wiki.
www.ogre3d.org/wiki/index.php/MOGRE_MovableText

Is this the code you used or did you do a second port?



Yes, i thought it was clear :D, sorry for that :).




By the way:

It's not recommended to use Ogre internal members (Sinbad told me that). Ogre internals begins with underscore (e.g. _sceneMgr)


Thanks for the small hint, but i know that ;). i have written a simple base class from where i derive my code snippets... i know that _variable isnt really c# name convention, but i started with those names, and now its hard to forget about :D....

Bostich

Beauty

24-09-2008 14:22:28

Thanks for the small hint, but i know that ;). i have written a simple base class from where i derive my code snippets... i know that _variable isnt really c# name convention, but i started with those names, and now its hard to forget about :D....

Ah, you mean these are self defined vars. I thought these are Ogre internal members.

GermanDZ

24-09-2008 19:41:01

I am not sure, but MovableText was working fine.


But another approach to the same/similar case is keep an overlay text aligned to the proyection of the node over the camera.

Bostich

24-09-2008 21:38:30

I am not sure, but MovableText was working fine.
Yes your source works perfectly :).

But another approach to the same/similar case is keep an overlay text aligned to the proyection of the node over the camera.

Will it also grow like the "fake billboard" ?


Bostich

Beauty

07-10-2008 22:54:55

anyway here is the compiled mogre version with movabletext class

http://www.file-upload.net/download-1133075/Release.rar.html

I wanted to test MovableText with my simple test application.
So I replaced the dll files with your ones and updated the dll link in Visual Studio.
But than I get a System.Runtime.InteropServices.SEHException.
OGRE EXCEPTION(7:InternalErrorException): Could not load dynamic library .\RenderSystem_Direct3D9. System Error: Couldn't find the called modul.

The file RenderSystem_Direct3D9.dll I also replaced with your one. With the old file it doesn't work, too.
My old files were Mogre 0.2.2 (Ogre 1.4.3). Your compiled files are version 1.4.8.
Any ideas?

Nexam

08-10-2008 09:26:26

Hey, it look fine :p

I'm going to test that soon.

Beauty

08-10-2008 12:12:08

Hey, it look fine :p
Can you take a screenshot? (or more than one) I would like to add it to the forum.
If you can scale your render window, maybe a small resolution (e.g. 300x200) would be better for the forum. Downscaling from big screenshots to small pictures decrease the quality.
You also can send it by e-mail to beautyod at gmx.de

Bostich

08-10-2008 13:55:17

Hi Beauty,

iam totaly sorry that i missed your problem :oops:

Have you tried it again to get this running?

I can post you an image this afternoon if you arent able to get this workin.

again, sorry that iam unable to see you post :roll:

Bostich

Beauty

08-10-2008 14:07:25

No problem for waiting :wink:

On yesterday I tried your files. There it didn't work.
The vc_redist 2008 patch is installed.
Maybe some other depencies are needed for newer Mogre versions?

Bostich

08-10-2008 14:32:55

Hi Beauty,

did you install the newest SP ?

And which version of VS did u run? Since 1.4.8 i run on vs 2008, cause get Mogre 1.4.8 running on 2005 was a nightmare -.-.

and on other dependencies - i cant remember exactly which i uses (tried soooo many :D)

If i got enough time today, i will send you a package with ALL dependecies i got in my application.

Bostich

Beauty

08-10-2008 14:53:38

For my target application I use VS 2005.
I also have VS 2008, but only the Express version.
The VS 2005 SP1 is installed.

Mogre itself I never compiled. (I know now this is configured for VS 2008.) I just use the libraries.

Don't worry, don't hurry. I have time :wink:

Bostich

08-10-2008 15:41:15

Hi again 8)

i also have only 2008 express edition, just for info.

Bostich

09-10-2008 19:04:39

Hi Beauty,

a bit later then expected.

http://www.file-upload.net/download-1170115/dllBase.rar.html

Includes all dlls that i have ever used. includes also a simple screenshot of movable text.

Robot with name terminator :lol: 8)


Bostich

bacardicola

08-12-2009 08:43:24

Hi,

sadly the link below is dead...



http://www.file-upload.net/download-1170115/dllBase.rar.html

Includes all dlls that i have ever used. includes also a simple screenshot of movable text.


Has everyone the compiled dlls with MoveableText included? And can upload it somewhere?

That would be very nice. Until now i havenĀ“t compile Ogre/Mogre from source and i would like to save the time for doing that.

Many thanks in advance

Kohedlo

24-06-2010 23:08:13

i use Movable text by bilboards with Mogre 1.71 . Its great but - move of text mirrored to move camera. When draw close to
the scene node with bb - this bb - is run and become small/ When node up - bb text go down. :cry: