Frederic Barachant wrote:
just a word about an error in the FAQ.
Entry 2 in texturing has a mistake:
"Java3D currently does not provide a mechanism to do a partial update of texture images."
Since 1.3, that is false. See ImageComponent2D.setSubImage(). That works wonderfully.
Thanks for spotting that. Fixed. Split the entry into two parts now -
one for updating and the other for byRef/memory consumption issues.

2. How do I generate/update dynamic textures?

I want to create a texture and then over time play with some pixels
without regenerating the entire image and then telling Java 3D to use
the new values.

Java3D 1.2 does not provide a mechanism to do a partial update of
texture images. 1.3 introduced the ImageComponent2D.setSubImage() method
to allow you to change part of a texture without needing to reconstruct
the whole texture object.

If you are using 1.3 then the call for the setSubImage() method takes an
image to use as the source data to be copied and the bounds to use from
that image and the bounds to copy into in the texture object. This is
the quickest way to update the textures.

If you need to use 1.2 then using ImageComponent with the flag
byReference and yUp is one way of achieving what you want. Using
byReference enables you to change a part of the image on the application
side.



3. Why does Java3D use so much memory for textures?

Like the rest of the scene graph structure, Java3D will make internal
copies of the data so that it is not effected by your application code
making changes to it. You can skip this intermediate copy by using the
BY_REFERENCE capabilities. The restriction here is that you are not
allowed to modify the contents of the data you hand Java3D unless it is
provided as certain critical times.

Using by reference with textures is subject to a number of other
conditions. Although you may have marked the texture as a by referenced
capability, Java3D may still make an internal copy. Currently on PCs,
Java3D will not make a copy of texture image for the following
combinations of BufferedImage format and ImageComponent format(ofcourse,
byReference and Yup should both be set to true)
BufferedImage format ImageComponentFormat
BufferedImage.TYPE_3BYTE_BGR ImageComponent.FORMAT_RGB8
ImageComponent.FORMAT_RGB
BufferedImage.TYPE_CUSTOM of form 3BYTE_RGB ImageComponent.FORMAT_RGB8
ImageComponent.FORMAT_RGB
BufferedImage.TYPE_CUSTOM of form 4BYTE_RGBA ImageComponent.FORMAT_RGBA8
ImageComponent.FORMAT_RGBA
BufferedImage.TYPE_BYTE_GRAY ImageComponent.FORMAT_CHANNEL8
On Solaris, the combinations below will not make a Java3D copy:
BufferedImage.TYPE_4BYTE_ABGR ImageComponent.FORMAT_RGBA8
ImageComponent.FORMAT_RGBA
BufferedImage.TYPE_CUSTOM of form 3BYTE_RGB ImageComponent.FORMAT_RGB8
ImageComponent.FORMAT_RGB
BufferedImage.TYPE_CUSTOM of form 4BYTE_RGBA ImageComponent.FORMAT_RGBA8
ImageComponent.FORMAT_RGBA
BufferedImage.TYPE_BYTE_GRAY ImageComponent.FORMAT_CHANNEL8

Note that an image associated with a live scene graph cannot be changed
for by reference images unless you use the
ImageComponent2D.TextureUpdater interface.

--
Justin Couch                         http://www.vlc.com.au/~justin/
Java Architect & Bit Twiddler              http://www.yumetech.com/
Author, Java 3D FAQ Maintainer                  http://www.j3d.org/
-------------------------------------------------------------------
"Humanism is dead. Animals think, feel; so do machines now.
Neither man nor woman is the measure of all things. Every organism
processes data according to its domain, its environment; you, with
all your brains, would be useless in a mouse's universe..."
                                              - Greg Bear, Slant
-------------------------------------------------------------------

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to