Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3509 Members - Latest Member: lioneltenel

27. May 2012, 03:18:00 am
Xith3D CommunityGeneral CategorySupport (Moderator: Marvin Fröhlich)Attach Widget to 3D-Object?
Pages: [1]
Print
Author Topic: Attach Widget to 3D-Object?  (Read 1045 times)
oeh766
Just dropped in

Offline Offline

Posts: 11


View Profile
« on: 20. February 2008, 07:04:11 pm »


Hi,

what would be the best way to attach a widget to a 3d object? The widget (e.g., a label) should always be placed a bit below the position the object is rendered (or its center).

Or, is there any function to simply convert a Node to a screen position?

Regards

Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #1 on: 20. February 2008, 07:43:40 pm »

The easiest way would be to create a FixedSizeBilboard, apply a StaticTransform to it and put it into the same TransformGroup as the tagged Shape.

Marvin
Logged
oeh766
Just dropped in

Offline Offline

Posts: 11


View Profile
« Reply #2 on: 21. February 2008, 04:08:58 pm »


Thanks for the hint. However, I tried that, and this is what happens:

Code:
Font font = Font.getFont("serif");

FixedSizedBillboard bb = FixedSizedBillboardFactory.createConstantSizedTextBillboard(entity.label, TextAlignment.CENTER_CENTER.ordinal(), font, Colorf.CYAN);


Result:

java.lang.NullPointerException
   at sun.font.FontDesignMetrics$MetricsKey.init(Unknown Source)
   at sun.font.FontDesignMetrics.getMetrics(Unknown Source)
   at sun.java2d.SunGraphics2D.getFontMetrics(Unknown Source)
   at org.xith3d.loaders.texture.TextureCreator.getTextMetrics(TextureCreator.java:474)
   at org.xith3d.loaders.texture.TextureCreator.createTexture(TextureCreator.java:538)
   at org.xith3d.loaders.texture.TextureCreator.createTexture(TextureCreator.java:619)
   at org.xith3d.scenegraph.primitives.FixedSizedBillboardFactory.createConstantSizedTextBillboard(FixedSizedBillboardFactory.java:189)
   at net.xeoh.dashboard.visualbacktracking.impl.gui3d.adapter.xith.utils.GeometryUtils.newSimpleLabel(GeometryUtils.java:139)
   at net.xeoh.dashboard.visualbacktracking.impl.gui3d.adapter.xith.utils.GeometryUtils.doAddEntity(GeometryUtils.java:170)
   at net.xeoh.dashboard.visualbacktracking.impl.gui3d.adapter.xith.utils.NodeUtils.processEntity(NodeUtils.java:57)
   at net.xeoh.dashboard.visualbacktracking.impl.gui3d.adapter.xith.utils.NodeUtils.processEntity(NodeUtils.java:70)
   at net.xeoh.dashboard.visualbacktracking.impl.gui3d.adapter.xith.utils.NodeUtils.processWorld(NodeUtils.java:47)
   at net.xeoh.dashboard.visualbacktracking.impl.gui3d.adapter.xith.XITHAdapter.updateFromWorld(XITHAdapter.java:158)
   at net.xeoh.dashboard.visualbacktracking.impl.gui3d.ShellXITH$1.update(ShellXITH.java:117)
   at org.xith3d.loop.UpdaterImpl.update(UpdaterImpl.java:73)
   at org.xith3d.loop.RenderLoop.prepareNextFrame(RenderLoop.java:691)
   at org.xith3d.loop.RenderLoop.loopIteration(RenderLoop.java:728)
   at org.xith3d.loop.RenderLoop.update(RenderLoop.java:788)
   at org.xith3d.loop.UpdatingThread.nextIteration(UpdatingThread.java:473)
   at org.xith3d.loop.RenderLoop.nextIteration(RenderLoop.java:817)
   at org.xith3d.loop.RenderLoop.loop(RenderLoop.java:852)
   at org.xith3d.loop.UpdatingThread.run(UpdatingThread.java:526)
   at org.xith3d.loop.RenderLoop.run(RenderLoop.java:875)
   at java.lang.Thread.run(Unknown Source)

Any ideas?
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #3 on: 21. February 2008, 05:17:31 pm »

Hmm... No. I guess, you had a look at the FixedSizeBilboardTest class (xith-tk, render folder), did you?

At least the TextAlignment.CENTER_CENTER.ordinal() parameter is wrong. This is 4, which is an alignment parameter, that doesn't exist at this place. Please use
TextureCreator.TEXT_ALIGNMENT_HORIZONTAL_LEFT
TextureCreator.TEXT_ALIGNMENT_HORIZONTAL_CENTER
TextureCreator.TEXT_ALIGNMENT_HORIZONTAL_RIGHT

But even using 4 doesn't cause this exception for me. Does the testcase work for you?

Marvin
Logged
oeh766
Just dropped in

Offline Offline

Posts: 11


View Profile
« Reply #4 on: 21. February 2008, 05:22:28 pm »



Sorry, was a stupid mistake.

The problem was I got the font object the wrong way: Not Font.getFont(name) has to be used, but new Font(name, ...).

But thanks a lot anyway.
Logged
minikidder
Just dropped in

Offline Offline

Posts: 7



View Profile
« Reply #5 on: 07. December 2011, 12:11:23 am »

thanks for this, I found the test as: org.xith3d.test.render.BillboardTest  in xith-tk
It is awesome!

I even like the programming concepts of how things are done !!!
Logged

defaults man, they are evil ...
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic