Skip to main content

2D overlay for Canvas3D - window resize problem

7 replies [Last post]
scubed
Offline
Joined: 2006-09-20

I have overridden the Canvas3D class to add capability to draw in 2D. I'm using a J3DGraphics2D object. I draw to a buffer and finally do a drawAndFlushImage to draw 2D graphics over a Canvas3D. (I'm placing the 2D entities relative to the bounds of the J3DGraphics2D.)

Works fine until I manually resize the host JFrame. The 3D part draws as expected in the resized window, but the 2D stuff is drawn stretched (if the window was expanded). I am using theView.setWindowResizePolicy(View.VIRTUAL_WORLD) which seems to affect only the 3D part.

Grasping at straws I drew a rectangle (not part of the scene) to the Graphics2D object (not the buffer) obtained from the overridden Canvas3d; THEN the 2D stuff is drawn as expected (not stretched or compressed) BUT it is drawn in its original location (relative to the original Bounds of the J3DGraphics2D object). The Bounds of the J3DGraphics2D are unchanged despite the fact that the JFrame holding the overridden Canvas3D was resized.

So, there are two issues.

1. How to get the 2D entities to draw without distortion after a resize (without drawing the unwanted rectangle to the J3DGraphics2D object).

2. How to obtain a new J3DGraphics2D object that reflects the new size of the window. (A new J3DGraphics2D obtained after the resize still has the old size.)

And a general question...at what point is a View object available? (Not when the constructor for the overridden class runs, but only apparently after something has actually been rendered.) I ask because it is the View object that has the setWindowResizePolicy method that I use. It seems that I can't set the policy before the first render. This can't be so.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
David Grace

Hi J,

I tried using MediaContainer first but for some reason that I could not
determine even though I used the same MediaContainer to create 2
PointSounds, the MediaContainers that come through to the JOALMixer end up
being 2 different objects. Also two different MediaContainers could point to
the same resource (Do you think they should share the buffer in this case?).
Now I now the code works for a URL object it will be easy for me to extend
it to work with URLString as well.

As for releasing the buffer (and other JOAL resources) I think it is a bit
more complex than that. At the moment the JOALMixer does not release
resources (this is an outstanding issue). I think that the JOALMixer should
release resources when the scheduler sends a call to clear() but I am not
completely sure yet of the lifecycle for a sample. I do not have an example
where clear() is ever called so I haven't been able to test when clear() is
actually called. I have put a function in JOALSample (which is not called at
the moment) which has the code to release resources use by JOAL.

I think there is a code freeze at the moment but this issue will be the next
to be fixed in the JOALMixer.

Dave.

-----Original Message-----
From: Joerg Plewe [mailto:plewe@hardcode.de]
Sent: Wednesday, June 20, 2007 7:50 AM
To: interest@java3d.dev.java.net
Subject: Re: Reuse of JOAL buffers possible?

Hi David!

Thanks for the quick response. Your solution basically works for me, but
I have some suggestions:

- it only works if the MediaContainer is provided with an URL object.
But it also might contain an URL-string only. From my point of view it
should be sufficient to maintain the MediaContainer itself in the
hashmap, not the URL object. I feel that would also represent the nature
of a MediaContainer being a NodeComponent better.
- what about using a WeakReference for the HashMap? This would allow to
release unused buffers at some point?

Thanks for your help,

- J

David Grace schrieb:
> Hi Joerg,
>
> I have uploaded a fix for bug 500. Can you check whether this works for
you
> and get back to me?
>
> Many thanks,
>
> Dave.
>
>
>
> -----Original Message-----
> From: Joerg Plewe [mailto:plewe@hardcode.de]
> Sent: Tuesday, June 19, 2007 4:23 AM
> To: interest@java3d.dev.java.net
> Subject: Reuse of JOAL buffers possible?
>
>
> When creating a Java3D PointSound (or other sound nodes), the JOALSamples
> loads
> the sound data given in a MediaContainer. In my case, having 100 airplanes
> in
> the scene means that the sound file has to be loaded 100 times.
>
> Wouldn't it be possible to reuse a loaded buffer?
>
> - J
>
>
>
> See also https://java3d.dev.java.net/issues/show_bug.cgi?id=500
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
> For additional commands, e-mail: interest-help@java3d.dev.java.net
>
>

--
Joerg Plewe
http://www.hardcode.de
'Life is hard and then you die.'

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
For additional commands, e-mail: interest-help@java3d.dev.java.net

--
Message protected by MailGuard: e-mail anti-virus, anti-spam and content
filtering.
http://www.mailguard.com.au/mg

--
Message protected by MailGuard: e-mail anti-virus, anti-spam and content filtering.
http://www.mailguard.com.au/mg

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
For additional commands, e-mail: interest-help@java3d.dev.java.net

Joerg Plewe

When creating a Java3D PointSound (or other sound nodes), the JOALSamples loads
the sound data given in a MediaContainer. In my case, having 100 airplanes in
the scene means that the sound file has to be loaded 100 times.

Wouldn't it be possible to reuse a loaded buffer?

- J

See also https://java3d.dev.java.net/issues/show_bug.cgi?id=500

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
For additional commands, e-mail: interest-help@java3d.dev.java.net

David Grace

Hi Joerg,

I have uploaded a fix for bug 500. Can you check whether this works for you
and get back to me?

Many thanks,

Dave.

-----Original Message-----
From: Joerg Plewe [mailto:plewe@hardcode.de]
Sent: Tuesday, June 19, 2007 4:23 AM
To: interest@java3d.dev.java.net
Subject: Reuse of JOAL buffers possible?

When creating a Java3D PointSound (or other sound nodes), the JOALSamples
loads
the sound data given in a MediaContainer. In my case, having 100 airplanes
in
the scene means that the sound file has to be loaded 100 times.

Wouldn't it be possible to reuse a loaded buffer?

- J

See also https://java3d.dev.java.net/issues/show_bug.cgi?id=500

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
For additional commands, e-mail: interest-help@java3d.dev.java.net

--
Message protected by MailGuard: e-mail anti-virus, anti-spam and content
filtering.
http://www.mailguard.com.au/mg

--
Message protected by MailGuard: e-mail anti-virus, anti-spam and content filtering.
http://www.mailguard.com.au/mg

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
For additional commands, e-mail: interest-help@java3d.dev.java.net

Joerg Plewe

Hi David!

Thanks for the quick response. Your solution basically works for me, but
I have some suggestions:

- it only works if the MediaContainer is provided with an URL object.
But it also might contain an URL-string only. From my point of view it
should be sufficient to maintain the MediaContainer itself in the
hashmap, not the URL object. I feel that would also represent the nature
of a MediaContainer being a NodeComponent better.
- what about using a WeakReference for the HashMap? This would allow to
release unused buffers at some point?

Thanks for your help,

- J

David Grace schrieb:
> Hi Joerg,
>
> I have uploaded a fix for bug 500. Can you check whether this works for you
> and get back to me?
>
> Many thanks,
>
> Dave.
>
>
>
> -----Original Message-----
> From: Joerg Plewe [mailto:plewe@hardcode.de]
> Sent: Tuesday, June 19, 2007 4:23 AM
> To: interest@java3d.dev.java.net
> Subject: Reuse of JOAL buffers possible?
>
>
> When creating a Java3D PointSound (or other sound nodes), the JOALSamples
> loads
> the sound data given in a MediaContainer. In my case, having 100 airplanes
> in
> the scene means that the sound file has to be loaded 100 times.
>
> Wouldn't it be possible to reuse a loaded buffer?
>
> - J
>
>
>
> See also https://java3d.dev.java.net/issues/show_bug.cgi?id=500
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
> For additional commands, e-mail: interest-help@java3d.dev.java.net
>
>

--
Joerg Plewe
http://www.hardcode.de
'Life is hard and then you die.'

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
For additional commands, e-mail: interest-help@java3d.dev.java.net

Thierry Milard (free)

Hello Joerg and hello David,
I am using JOAL and I am really not master all these sound issues.
I have an issue that relly bothers me.
May I have your thougts about this one ?

Here is what I do:
1) I convert a few mp3 files to wav files. With javazoom:
[mp3spi1.9.4/jar // tritonus_share-0.3.6.jar // jl1.0.jar]
2) I use Joal to play those newly created wav files ...

- Question number one:
"I think joal can only play wav files. I am right ? (I think I am ...for
this one)"

- Question number 2 :
When I use some mp3 files, joal plays very well the wav file (converted
from original mp3).
_But sometimes_, other mp3 files don't play with joal (I mean wav file
converted from mp3):
there are no java exception, just ... no noise playing.
Note: what is surprising is that when I play the problematic wav file
into Winamp player ...well it reads it fine! (I hear something)

Do you have one idea to what is hapening to me ? what did I do wrrong ?
Did I forget to put a jar, a dll ?
for exemple I use to have javalayer.jar , lame_encoder.dll
lametritonus.dll are they usefull .But I got read of them .. should I
put them back ?

Thank you for the time.
Thierry, Paris

I
I wold like to know know it is not
Joerg Plewe a écrit :
> Hi David!
>
> Thanks for the quick response. Your solution basically works for me,
> but I have some suggestions:
>
> - it only works if the MediaContainer is provided with an URL object.
> But it also might contain an URL-string only. From my point of view it
> should be sufficient to maintain the MediaContainer itself in the
> hashmap, not the URL object. I feel that would also represent the
> nature of a MediaContainer being a NodeComponent better.
> - what about using a WeakReference for the HashMap? This would allow
> to release unused buffers at some point?
>
> Thanks for your help,
>
> - J
>
> David Grace schrieb:
>> Hi Joerg,
>>
>> I have uploaded a fix for bug 500. Can you check whether this works
>> for you
>> and get back to me?
>>
>> Many thanks,
>>
>> Dave.
>>
>>
>>
>> -----Original Message-----
>> From: Joerg Plewe [mailto:plewe@hardcode.de] Sent: Tuesday, June 19,
>> 2007 4:23 AM
>> To: interest@java3d.dev.java.net
>> Subject: Reuse of JOAL buffers possible?
>>
>>
>> When creating a Java3D PointSound (or other sound nodes), the
>> JOALSamples
>> loads
>> the sound data given in a MediaContainer. In my case, having 100
>> airplanes
>> in
>> the scene means that the sound file has to be loaded 100 times.
>>
>> Wouldn't it be possible to reuse a loaded buffer?
>>
>> - J
>>
>>
>>
>> See also https://java3d.dev.java.net/issues/show_bug.cgi?id=500
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
>> For additional commands, e-mail: interest-help@java3d.dev.java.net
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
For additional commands, e-mail: interest-help@java3d.dev.java.net

David Grace

Hi Thierry,

At the moment the JOALMixer only works with wav files. If you like can you
send me a copy privately of a wav file which does not work for you and I can
do some testing with it and get back to you.

As for mp3 and ogg vorbis I do plan to enable them in the future, probably
ogg vorbis first as there is good documentation on using ogg vorbis with
JOAL so it should be relatively easy. I am basically waiting to get the
remaining bugs ironed out using wav files before moving on to compressed
formats.

Dave.

-----Original Message-----
From: Thierry Milard (free) [mailto:t.milard@free.fr]
Sent: Wednesday, June 20, 2007 9:31 AM
To: interest@java3d.dev.java.net
Subject: Re: Reuse of JOAL buffers possible?

Hello Joerg and hello David,
I am using JOAL and I am really not master all these sound issues.
I have an issue that relly bothers me.
May I have your thougts about this one ?

Here is what I do:
1) I convert a few mp3 files to wav files. With javazoom:
[mp3spi1.9.4/jar // tritonus_share-0.3.6.jar // jl1.0.jar]
2) I use Joal to play those newly created wav files ...

- Question number one:
"I think joal can only play wav files. I am right ? (I think I am ...for
this one)"

- Question number 2 :
When I use some mp3 files, joal plays very well the wav file (converted
from original mp3).
_But sometimes_, other mp3 files don't play with joal (I mean wav file
converted from mp3):
there are no java exception, just ... no noise playing.
Note: what is surprising is that when I play the problematic wav file
into Winamp player ...well it reads it fine! (I hear something)

Do you have one idea to what is hapening to me ? what did I do wrrong ?
Did I forget to put a jar, a dll ?
for exemple I use to have javalayer.jar , lame_encoder.dll
lametritonus.dll are they usefull .But I got read of them .. should I
put them back ?

Thank you for the time.
Thierry, Paris

I
I wold like to know know it is not
Joerg Plewe a écrit :
> Hi David!
>
> Thanks for the quick response. Your solution basically works for me,
> but I have some suggestions:
>
> - it only works if the MediaContainer is provided with an URL object.
> But it also might contain an URL-string only. From my point of view it
> should be sufficient to maintain the MediaContainer itself in the
> hashmap, not the URL object. I feel that would also represent the
> nature of a MediaContainer being a NodeComponent better.
> - what about using a WeakReference for the HashMap? This would allow
> to release unused buffers at some point?
>
> Thanks for your help,
>
> - J
>
> David Grace schrieb:
>> Hi Joerg,
>>
>> I have uploaded a fix for bug 500. Can you check whether this works
>> for you
>> and get back to me?
>>
>> Many thanks,
>>
>> Dave.
>>
>>
>>
>> -----Original Message-----
>> From: Joerg Plewe [mailto:plewe@hardcode.de] Sent: Tuesday, June 19,
>> 2007 4:23 AM
>> To: interest@java3d.dev.java.net
>> Subject: Reuse of JOAL buffers possible?
>>
>>
>> When creating a Java3D PointSound (or other sound nodes), the
>> JOALSamples
>> loads
>> the sound data given in a MediaContainer. In my case, having 100
>> airplanes
>> in
>> the scene means that the sound file has to be loaded 100 times.
>>
>> Wouldn't it be possible to reuse a loaded buffer?
>>
>> - J
>>
>>
>>
>> See also https://java3d.dev.java.net/issues/show_bug.cgi?id=500
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
>> For additional commands, e-mail: interest-help@java3d.dev.java.net
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
For additional commands, e-mail: interest-help@java3d.dev.java.net

--
Message protected by MailGuard: e-mail anti-virus, anti-spam and content
filtering.
http://www.mailguard.com.au/mg

--
Message protected by MailGuard: e-mail anti-virus, anti-spam and content filtering.
http://www.mailguard.com.au/mg

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
For additional commands, e-mail: interest-help@java3d.dev.java.net

bryanr
Offline
Joined: 2006-08-28

I would be interested in a solution to this as well. I experience the same stretching characteristics when I draw 2D text on the canvas.