Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (429)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (468)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Text2D, Text3D in Xith3D?  (Read 4134 times)
0 Members and 1 Guest are viewing this topic.
Offline palmer

Junior Newbie




Java games rock!


« Posted 2003-10-29 14:47:42 »

Hi all.  I've attempted to port my Java3D app to Xith3D.  It's great to find a familar scenegraph API in Xith3D.  Please keep hammer away at this.  

I don't see anything like the Java3D Text2D nor Text3D classes for getting text easily into an app.  As someone who hasn't done much JOGL programming, nor OpenGL programming, I can't see as easy a way to do this.

Does Xith3D plan to include these Text classes?  Or, can someone point me to an easy means to get text into my app?

Thanks,
-Andrew
Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #1 - Posted 2003-10-29 15:38:08 »

Text2D is a part of com.sun.j3d.utils.geometry package, and source for it should be somewhere in src of Java3D SDK, so it should be easy to port it to Xith3D, and neither OpenGL nor JOGL skills required to do so.

Regarding Text3D, this is not implemented for a moment, but [as for me] there are plans to do so. Anyway, any help in this area would be great.

Yuri

Yuri Vl. Gushchin
JProof Group
Offline palmer

Junior Newbie




Java games rock!


« Reply #2 - Posted 2003-10-29 22:04:07 »

Thanks for the suggestion.  The Text2D port looked simple, but my attempt at it renders garbled text into Xith3D, oops, and I can't say why.

The original Text2D class contains the following comment about the width and height of the BufferedImage:
     
// Need to make width/height powers of 2 because of Java3d texture
// size restrictions
     int pow = 1;
     for (int i = 1; i < 32; ++i) {
         pow *= 2;
         if (width <= pow)
           break;
     }
     width = Math.max (width, pow);

     pow = 1;
     for (int i = 1; i < 32; ++i) {
         pow *= 2;
         if (height <= pow)
           break;
     }
     height = Math.max (height, pow);

Anyone know how this applies in Xith3D?  My attempts at tinkering with it didnt' work.

Thanks,
-Andrew
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #3 - Posted 2003-10-30 07:22:45 »

Yes, generally width and height of the images (used for textures) have to be power of 2, unless we will implement support for non-pow-2 OpenGL extension support [which is optional].

Yuri

P.S. And you should use the latest version of Xith3D from CVS because of it contains important fix for small images of sizes < 2x2

Yuri Vl. Gushchin
JProof Group
Offline DjaZia

Senior Newbie




Build once, run everywhere!


« Reply #4 - Posted 2003-10-31 07:32:54 »

Is there a precise list of:
- what Xith3D will contain?
- what has been (or is currently) developed?
- what left to be developed?

It may be useful for people (which are not tagged as developers) who wants to bring their little help to build Xith3D.
They can check the list, develop their piece (ex: Text2D) and submit their code to a developer who check it, test it and integrate it into Xith3D.

Just a thought  Wink

DJ

DZ Ecrew member
Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #5 - Posted 2003-10-31 07:38:47 »

Yes, agree - such list will be great to have.

How do you think it should look - as a comparison to Java3D, list of features or ... ?

I was thinking about comparison to Java3D once, but there are some features that do not exist in Java3D [as well as some that will never be implemented]. (BTW, I never started with this...)

Also I think if we make such a list, we should also make tests/demos for all the features listed.

Yuri

Yuri Vl. Gushchin
JProof Group
Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #6 - Posted 2003-10-31 07:39:50 »

Also the sticky topic "Xith3D features" was created exacly for these purposes.

Yuri Vl. Gushchin
JProof Group
Offline DjaZia

Senior Newbie




Build once, run everywhere!


« Reply #7 - Posted 2003-10-31 07:58:58 »

Quite true but we have no view of what is currently developed, and what has to be developed.
The list may look like the one in "Xith3D features" but with columns like:
- Name of the feature
- Stat:
   - TD: to Develop,
   - IP: Development in progress + Name of the persons working on it,
   - FN: Development finshed
- Test: Name of the test case where the feature is tested
- Bugs: list of the issues to be resolved for this feature

Anyway, something like that  Grin

I know it's quite of work behind to keep it updated but it will be great  Wink

DJ

DZ Ecrew member
Offline Jens

Senior Member




Java for games!


« Reply #8 - Posted 2003-10-31 08:04:08 »

Yuri, you did a great job in the past weeks. Unfortunately we can't edit David's feature list to add your own changes (and possibly your ToDo list). I suggest to either move the feature list to question 12 (currently) of the xith.org FAQ or to create a new section "feature list" in the docs section of xith.org.

Xith3D Getting Started Guide (PDF,HTML,Source)
Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #9 - Posted 2003-10-31 08:15:33 »

Quote
- Name of the feature
- Stat:
   - TD: to Develop,
   - IP: Development in progress + Name of the persons working on it,  
   - FN: Development finshed
- Test: Name of the test case where the feature is tested
- Bugs: list of the issues to be resolved for this feature


Then maybe this should be in Issues database under specific component, such as Xith3D core [just thinking - don't treat as final idea]?

Also if someone will summarize my comments to CVS updates, it will I guess also help a lot (I always make very clear statement what has been changed and provide a test demonstrating new/changed feature).

Yuri

Yuri Vl. Gushchin
JProof Group
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #10 - Posted 2003-11-01 23:53:03 »

If you havn't already - subscribe to the CVS mailing list.  Then you can watch what classes change and read Yuri's comments which are always very clear (thanks Yuri!).

Will.

Offline Jens

Senior Member




Java for games!


« Reply #11 - Posted 2003-11-02 15:32:37 »

Back to the thread topic:

I can confirm that the Text2D class of Java3D is not directly usable. It seems to display the text several times and has strange artefacts. I just wanted to display the framerate on the screen without using Swing.

Xith3D Getting Started Guide (PDF,HTML,Source)
Offline DavidYazel

Junior Member




Java games rock!


« Reply #12 - Posted 2003-11-03 18:32:47 »

Yes this is on the todo list.  I tried porting sun's stuff too... yucky!  The best way to do this (and how I will probably do it) is to use a combination of suboverlay and billboard to keep it oriented.

Text2D is different from overlays in that it is embedded in the scene and gets smaller with distance.

BTW to put an FPS counter on the screen just use the overlay system that Xith3D has.

David Yazel
Xith3D Project Founder
http://xith3d.dev.java.net

It may look complicated, but in the end it is just a bunch of triangles
Offline Jens

Senior Member




Java for games!


« Reply #13 - Posted 2003-11-03 18:57:13 »

That's what I did in the end. I prepared a tutorial which contains an fps counter, which you can plug in your app by writing just one line. It uses UIWindow and will be in the Getting Started Guide soon.

There's a small documentation bug in UIOverlay: The explanation for this class is below "public class UIOverlay {", but should be above. Hope you can quickly fix this.

I didn't work directly with UIOverlay, but shouldn't it implement the UIOverlayInterface?

Btw. Good to see you back in the forum.  Smiley

Xith3D Getting Started Guide (PDF,HTML,Source)
Offline Planner1

Senior Newbie





« Reply #14 - Posted 2004-02-03 12:33:02 »

Did anything ever come of this? Has anyone successfully done 2D text without the UIOverlay system? I want to display the names of objects in the 3d world at various distances and locations around the object. Something like this would be helpful.
Offline StefanD2

Senior Newbie




Java games rock!


« Reply #15 - Posted 2004-02-03 17:27:29 »

Currently you use could a rectangle with a texture on it as a workaround.

The texture can be made by using Javas 2d features but make sure it becomes not bigger than 256x256 to support all graphics cards.
Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #16 - Posted 2004-02-04 06:25:02 »

...or even 128x128 (at least for VIA CLE266 on Linux in some modes)...

But there is always a possibility to split texture and geometry to smaller pieces, so you overcome this limitation.

Yuri

Yuri Vl. Gushchin
JProof Group
Offline gpothier

Senior Newbie




Say it no more!


« Reply #17 - Posted 2004-02-04 09:24:24 »

I am writing a few text-related classes. They are not terminated, but if you really need it badly I can give it to you. Maybe this can also serve as a starting point to implementing Text2D, although I am not familiar with that particular feature of Java3D.
There is no problem for me to give you that code, but as I planned to eventually give it to Xith3D when it gets decent (my code, not xith ;o), I think we should find a way to collaboratively improve it until it can be integrated into Xith.
What do you, and core Xith developpers, think?
Offline Planner1

Senior Newbie





« Reply #18 - Posted 2004-02-04 13:11:18 »

I had considered what is recommended above (drawing textures with 2d and billboarding them) but the Billboard class isn't fully implemented because Behaviours aren't in place yet. So there are a number of components I will have to derive to make this work. If you have code, I'm sure we'd all appreciate having a look at it and possibly contributing to its improvement. Perhaps post a URL for download?
Offline pedro

Junior Member




Java games rock!


« Reply #19 - Posted 2004-02-13 11:53:10 »


Has anyone successfully implemented text3d then?

any help woud be cool,

pedro
Offline Java Cool Dude

Senior Member




Java forever


« Reply #20 - Posted 2004-02-13 15:09:42 »

Well I use billboarding all the time in Xith3D, however it only serves to make my particles elements face the camera.
Here's what I do:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
    public void updateParticleLocation(){
      viewMatrix.getColumn(0, rightVector);
      viewMatrix.getColumn(1, upVector   );

      usefulVector.sub(upVector, rightVector);
      particleCoordinates[0].scaleAdd(particleSize, usefulVector, particleLocation);

      usefulVector.add(upVector, rightVector);
      particleCoordinates[1].scaleAdd(particleSize, usefulVector, particleLocation);

      usefulVector.add(upVector, rightVector);
      usefulVector.negate();
      particleCoordinates[2].scaleAdd(particleSize, usefulVector, particleLocation);

      usefulVector.sub(rightVector, upVector);
      particleCoordinates[3].scaleAdd(particleSize, usefulVector, particleLocation);
    }
Offline Planner1

Senior Newbie





« Reply #21 - Posted 2004-02-13 17:16:07 »

Getting billboarding to work in the program was a lot easier than I thought. Here's a simple code sample for people like me who thought it was hard to figure out:

1  
2  
3  
4  
5  
 Appearance billboardAppearance = new Appearance();
 billboardAppearance.setColoringAttributes(new ColoringAttributes(new Color3f(0.0f, 1.0f, 0.0f), ColoringAttributes.NICEST));
    Billboard billboard = new Billboard(Billboard.COORDINATES | Billboard.TEXTURE_COORDINATE_2, 500, 500);
    Shape3D billboardShape = new Shape3D(billboard, billboardAppearance);
    scaleGroup.addChild(billboardShape);


I haven't textured them yet but they work great.
Offline Java Cool Dude

Senior Member




Java forever


« Reply #22 - Posted 2004-02-13 18:07:16 »

That would give you a single billboarded quad mate, mine on the other hand could stretch to an infinite number
^
|
pushing it a bit I know Tongue
Offline gpothier

Senior Newbie




Say it no more!


« Reply #23 - Posted 2004-03-04 01:27:38 »

Sorry I'm late... Here is the code I currently use to display 2d text.
http://stgo.dyndns.org/com.xith3d.text.zip
See TextManager.createShape
Offline Java Cool Dude

Senior Member




Java forever


« Reply #24 - Posted 2004-03-04 01:39:09 »

Empty zip package?
Offline SpuTTer

Senior Member


Medals: 1


Lazy Middle Class Intellectual


« Reply #25 - Posted 2004-03-04 02:18:45 »

Zip works for me, maybe he was just uploading?

Sacramento Volleyball
"Whitty phrase goes here."
Offline gpothier

Senior Newbie




Say it no more!


« Reply #26 - Posted 2004-03-04 02:18:49 »

Sorry. It is fixed now.
Seems I need a zip crashcourse...
Offline pedro

Junior Member




Java games rock!


« Reply #27 - Posted 2004-04-18 01:42:37 »

Hi gpothier,

Great work with the text stuff! Thanks for making it available Grin  I was I trying to use it at this momenet, but the texture of the shape appears reflected on the screen. I'm trying to fix that, but it would be cool if you could give me a hint Tongue

In the FontManager class, you have the following to render the texture of a char of the string:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
char theChar = aString.charAt(i);
                  int theWidth = getWidth(theChar);
                 
                  int theBaseTexCoordIndex = (theChar - 32) * 4;
                 
                  float theCurrentX = aRenderLocation.getX();
                  int theVertexIndex = aRenderLocation.getVertexIndex();

aQuadArray.setCoordinate(theCurrentX, 0, 0);
                  aQuadArray.setCoordinate(theCurrentX, itsFontHeight, 0);
                  aQuadArray.setCoordinate(theCurrentX+theWidth, itsFontHeight, 0);                  
                  aQuadArray.setCoordinate(theCurrentX+theWidth, 0, 0);
                 
aQuadArray.setTextureCoordinates(0,
                                    theVertexIndex,
                                              itsTextureCoordinates,
                                                    theBaseTexCoordIndex, 4);
                                                     
     
                  ..



I don't really understand how the setTextureCoordinate method works... What's the meaning of  theBaseTexCoordIndex variable? and why the hell equals  (theChar - 32) * 4 ? Sorry to be annoying to ask all these simple questions.

I'm trying to get the font work with Billboards too.. Has anyone actually improved the Billboard class? I heard in the forum about people using Billboard to display labels.. how did people implement that?  I'm really considering using the amazing UIOverlay hack, but I fear that my already low FPS will drop a lot Sad





Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

theagentd (6 views)
2014-04-24 23:00:44

xsi3rr4x (83 views)
2014-04-15 18:08:23

BurntPizza (75 views)
2014-04-15 03:46:01

UprightPath (86 views)
2014-04-14 17:39:50

UprightPath (69 views)
2014-04-14 17:35:47

Porlus (86 views)
2014-04-14 15:48:38

tom_mai78101 (109 views)
2014-04-10 04:04:31

BurntPizza (169 views)
2014-04-08 23:06:04

tom_mai78101 (265 views)
2014-04-05 13:34:39

trollwarrior1 (216 views)
2014-04-04 12:06:45
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!