Confused programmer seeking Batik advice.... Before I start into asking 
for advice, I'll need to describe what we're trying to do.

The code that we're working on operates on number of levels, and we'd 
like SVG content to be available on all of those. At the core of this we 
are doing 3D graphics rendering and want to put SVG content into the 3D 
environment - either as textures or overlays, or for simpler items like 
2D text in the 3D environment. How we're doing the 3D rendering is 
probably inconsequential, but for the moment it's using Java3D, but may 
well also include GL4Java and/or custom OpenGL wrappers. Either way, we 
need a extremely precise low-level control over the texture generation 
process.

There are at least 2 open source (LGPL) projects involved in using this 
process . At the lowest level is my j3d.org code repository. This does a 
lot of very low-level 3D graphics stuff. I need to control every texture 
on every frame - up to and including syncing animation systems (eg SMIL 
animated textures). At a much higher level is the Xj3D project, which is 
taking the VRML97/X3D specifications and providing a renderer for them. 
X3D has an XML encoding, so we can also include SVG textures directly 
into the file and animate those using the X3D scripting process etc etc. 
  In this system, SVG is used as both a texture source, and for our 
implementation of the 2D text node requirements.

So, hopefully you can see where I'm going here - we're looking at Batik 
and it's rendering process and trying to work out "how low can you go?". 
  Just how much of Batik can we throw away and still get something 
rendered.

Our most basic requirement is: given our DOM parsed document, how simply 
can we get a BufferedImage instance out of it (ideally, we'd actually 
like a RenderedImage instance so that maybe we can use the JDK 1.4 
VolatileImage stuff so we can blit this stuff directly on the video card 
every frame rather than needing to transfer across the bus every frame 
when we're animating stuff).

Reading through the archives, I can see lots of suggestions about using 
ImageTranscoders to create an Image instance. For us, that is not 
appropriate because there is a lot of extra image and object creation 
going on. In addition, there is a lot of caching being done too. We 
don't want that. Object creation kills framerates (allocation time, plus 
GC afterwards). Caching is not wanted as we will be managing our own 
caching of everything. Document parsing is not wanted because we are 
doing our own stuff too (we're playing with DOM Level3 implementations 
as well as a bunch of other custom stuff for the network handling that 
doesn't involve the Java core APIs).

So, where are we at? Basically, we've taken what we think is the lowest 
level approach possible, but would like to know if there is any more 
that we can strip out. In addition, we want to include the generated 
image with texture transparency for the background colour, which we 
don't seem to be able to do.

The code looks roughly like this:

    build shared GVTBridge & builder instances

    build DOM document
    Create buffered image with our height & width. ARGB image
    Get Graphics2D with Batik GraphicsUtil
    Build GraphicsNode instance with GVTBuilder
    setup background colors etc

    while(rendering)
      make changes to DOM scene graph
      GraphicsNode.paint(graphics2d instance)
      return image and update J3D Texture2D instance.

For some reason, the GVT code seems to be ignoring our background colour 
settings and other oddities. I can't quite put my finger on it ATM as 
I'm still learning what Batik does for a few things. They aren't 
immediately obvious from the source.


For those interested, here's the two projects:

http://code.j3d.org/
http://www.web3d.org/TaskGroups/source/xj3d.html

-- 
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, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to