OK, sorry I overlooked that the ImageComponent2D is a SceneGraphObject.
So all I needed to do was call
textImage.setCapability(ImageComponent2D.ALLOW_IMAGE_WRITE);
Anyway, I got it to work, it's really neat to be able to animate the texture!
Jason
On Tue, 12 Nov 2002 12:50:01 -0700, Jason Cheatham <[EMAIL PROTECTED]> wrote:
>I'm trying to animate a texture but am getting the following exception in my attempt
>to do so:
>Exception occurred during Behavior execution:
>javax.media.j3d.CapabilityNotSetException: ImageComponent2D: no capability to set
>image
>
>First off, I don't know how to set this capability if I'm using the TextureLoader
>class, since there are no methods that I know of in the ImageComponent2D class.
>
>Secondly, I don't know why I'm even getting this exception since I'm not calling the
>set method in the ImageComponent2D class (see code below). The exception is occuring
>from the line:
>m_imageComponent.updateData(this,0, 0, m_width, m_height);
>in the processStimulus method.
>
>Lastly, am I even going about this in the right way to animate a texture?
>
>Thanks,
>
>Jason
>
>Here are some samples of code.
>
>TextureLoader textLoad = new TextureLoader(image, TextureLoader.BY_REFERENCE ,new
>java.awt.Container());
>ImageComponent2D textImage = textLoad.getImage();
>Texture2D texture = new Texture2D(Texture2D.BASE_LEVEL,
> Texture.RGB,
> textImage.getWidth(),
> textImage.getHeight());
>texture.setImage(0, textImage);
>
>...
>
>m_textureBehavior = new TextureBehavior();
>m_textureBehavior.setSchedulingBounds(BoundingSphere());
>textImage.updateData(m_textureBehavior,0,0,textImage.getWidth(),textImage.getHeight());
>contentBranch.addChild(m_textureBehavior);
>
>public class TextureBehavior extends Behavior implements ImageComponent2D.Updater{
> private WakeupOnElapsedFrames wFrame = new WakeupOnElapsedFrames(0);
> private WakeupCriterion[] warray = { wFrame};
> private WakeupCondition w = new WakeupOr(warray);
>
> private ImageComponent2D m_imageComponent = null;
> private int m_width=0;
> private int m_height=0;
> /** Creates a new instance of TextureInterpolator */
> public TextureBehavior() {
> }
> public void initialize() {
> wakeupOn(w);
> }
> public void updateData(ImageComponent2D imageComponent, int x, int y, int width,
>int height)
> {
> if(m_imageComponent == null )
> {
> m_imageComponent = imageComponent;
> }
> m_width = width;
> m_height = height;
>
> System.out.println("Called");
>
>
> }
> public void processStimulus(Enumeration criteria) {
> WakeupCriterion genericEvt;
>
> while (criteria.hasMoreElements()) {
> genericEvt = (WakeupCriterion) criteria.nextElement();
> if (genericEvt instanceof WakeupOnElapsedFrames) {
> if(m_imageComponent!= null )
> {
> m_imageComponent.updateData(this,0, 0, m_width, m_height);
> }
> }
> }
> wakeupOn(w);
> }
>
>}
>
> ==========================================================================
>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".
===========================================================================
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".