Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - rjm49

#1
Hi, apologies if this has been discussed before, please point me to the relevant thread if so.

I have constructed a bunch of Object3Ds which sit together, and what I want to do is "group" them, then centre the group in my world (based on the geometry of the objects inside it) and rotate it around (0,0,0).

I'm aware that there is not a "group" concept as such, so I was wondering if it is good practice to use a dummy object for such a purpose?  Or whether it would be better to merge the objects (although they are tran'd/rot'd relative to each other which I guess a merge would undo).

I guess I can think of a couple of ways you might do it, and I just wanted to check for the best practice.  Any suggestions?
#2
Support / Re: Eccentric billboards
May 10, 2012, 01:03:11 PM
I see, that explains it.  Yes, setting the rotation pivot back to (0,0,0) brings success - many thanks Egon.
#3
Support / Re: Eccentric billboards
May 09, 2012, 10:41:37 PM
Thanks Thomas!  OK, we're in business.

To help me see what's going on, I built a basic set of "axes" using a line plotter algorithm, and I put these at the centre of the "Hello World" spinning cube demo (i.e. all centred at (0,0,0)), made the cube a bit transparent so that you can see everything.  There's also a little Cone at the end of the x-axis.  That is there simply to help you work out which way everything is pointing.



First, I create a quad, add it to world and as child of box, but I don't "build()" it:

//box and axes already created, omitted for space
Object3D label = new Object3D(2);

SimpleVector upperLeft=new SimpleVector(0,-1,0);
SimpleVector upperRight=new SimpleVector(1,-1,0);
SimpleVector lowerLeft=new SimpleVector(0,0,0);
SimpleVector lowerRight=new SimpleVector(1,0,0);

// Front
label.addTriangle(upperLeft,0,0, lowerLeft,0,1, upperRight,1,0);
label.addTriangle(upperRight,1,0, lowerLeft,0,1, lowerRight,1,1);

//label.setTexture("demo texture");
label.setBillboarding(true);

world.addObject(label);
box.addChild(label);
box.build();
//label.build();


i.e. it creates a square quad with lower-left corner at (0,0,0).  The quad doesn't move, the cube and axes spin round it.  So far so good:


But obviously this is no use if I want a label, as I have to texture it.  So I "setTexture()" and "build()" by uncommenting those lines in the listing above.  My texture is terrible, but that's not the real problem here :)

When I run the programme I see this:


The label is now "off centre" and I cannot understand why.  It moves in a weird way that is hard to describe, like it is eccentric to (0,0,0).  It seems that "build()" is doing this, rather than the texturing step.

In order to try to understand this better, I moved the camera round to (0,-6,0) to get a "plan" view.  Then I see the following, without "build()":


With "build()":


I added the red circle myself - that is the "attachment" point, i.e. the billboard pivots around this point (looks like (0,0,0.5) in cube-space) as the whole cube assembly spins.

Since I've not done any translations, I am a bit confused by this!  I cannot see why it would make any difference just to do the "build()" and it certainly doesn't give the result I would expect.  Any explanations of what is happening here would be most welcome.
#4
Support / Re: Eccentric billboards
May 09, 2012, 05:41:22 PM
Hi Marlon,  I do understand the billboarding concept.  There is a specific case I am working with that does not behave as expected.

I am happy to go into code, but it would probably be much easier if I could post images.
#5
Support / Eccentric billboards
May 09, 2012, 04:42:15 PM
I want to label objects (and parts of objects) in my world using billboards.  I'm not talking about blitting, I want the labels to have a z co-ordinate, but they should stay attached to their object.  For some reason they don't work as I'd expect.

I have created a demo to explain the situation, but I'm not sure how to get the screenshots onto this forum.  Lots of other people have done so, so there must be a way.  Any suggestions?

Thanks!
#6
Support / Re: jPCT rendering into JavaFX 2.0
March 13, 2012, 12:58:31 PM
I'm using software at the moment.
#7
Support / Re: jPCT rendering into JavaFX 2.0
March 08, 2012, 06:12:54 PM
Hi Egon, thanks for the quick response.  Yes, I should clarify:

javafx.scene.image.Image is the approximate equivalent of java.awt.Image;

javafx.scene.image.ImageView is a component (in JavaFX called a Node) for viewing Images;

Image works mainly as a loader class - you can feed a URL or InputStream into it to populate it with image data.  ImageView#setImage() then takes an Image and displays it (you can crop/rotate it etc using ImageView's utility methods).

A point of note however:  javafx.scene.image.Image is not compatible/interchangeable with java.awt.Image!  Indeed there is no official backward-compatibility between Swing/AWT/SWT/Java2D/Java3D and JavaFX 2.0. (Back in JavaFX 1.x they had a special Node that let you show Swing components in JavaFX.  In 2.0 only the other way round is true!)

I have had limited success with two approaches:

A) repeated acquiring (snapping) a java.awt.BufferedImage from jPCT, converting this into a JavaFX Image, and using imageView.setImage(imageFromjPCT) to set the new content.  For this I have to run a thread to do the rendering loop in jPCT, and another thread to do the "snaps".  JavaFX has another thread doing its GUI stuff.

B) I have also tried the "other way round" with the jPCT thread "pushing" images to JavaFX by way of a method call.  Then you don't need a "snapping" thread.  Again, JavaFX has its own thread doing its GUI stuff.

Both approaches tend to hang on the JavaFX side after about a minute, and version (A) has a habit of not initialising properly (thread non-safety I think).  JavaFX does not have a "game loop" model, its threading is implicit, so I cannot just call out for a new jPCT frame every time JavaFX "refreshes".

Having re-read all this, I suspect this is more a JavaFX problem than a jPCT one.  I just wondered whether there was preferred way of extracting BufferedImages from a running jPCT thread in a nice thread-safe manner.

Thanks!
#8
Support / jPCT rendering into JavaFX 2.0
March 07, 2012, 03:48:34 PM
Hi folks/Gruess Gott,

I'm new to jPCT and liking it!  Such compact and no-nonsense toolkits are so rare these days.  I have come from Java3D, which I can only conclude was never designed to actually be used by anyone.

I am trying to integrate jPCT with JavaFX 2.0.  This is because JavaFX's 3D own features cannot be used on my XP netbook (Mobile Intel 945 Express graphics chipset), even with all latest drivers.  A shame, given how common these chipsets are.

So the aim of my project - to get jPCT rendering onto a JavaFX Image, so that it can be viewed (via ImageView) as a panel showing jPCT 3D coolness, in the JavaFX scene.

I have achieved this, but not in a satisfactory/stable way.  Before we go into details of my horrid hacks, I'd be interested to hear if anyone else has had a go at this, and/or whether there is a "standard approach" to such a thing.

In the case of my project, I am trying to simply display the jPCT HelloWorld "spinning cube", in a single ImageView in the JavaFX scene.  So I need to get frames from jPCT and update the Image/ImageView repeatedly to animate it.  Not trying to do event handling or anything at this point.

I am happy to delve into code, I firstly just want to see if anyone else has had a go, or thought about it?

Thanks/Danke!

Russell (rjm49)