Skip to main content

LG3D Question#1( SwingNode )

5 replies [Last post]
ahamza
Offline
Joined: 2006-03-13

Hi all,

I have a terrible question: I've been trying to alter the SwingNodeTest example to attach the TestPanel to a simple FuzzyEdgePane instead of the complex ClothTest geometry.How is this done optimally? I get strange runtime errors (LG3D logs), and here is my ClothSwingNodeGeometry class:

////////////////////////////////////////////
class ClothSwingNodeGeometry extends SwingNodeRenderer {

private Appearance swingAppearance;

private /*ClothTest*/FuzzyEdgePanel body;

public ClothSwingNodeGeometry() {

width3D = 0.04f;
height3D = 0.03f;

swingAppearance = new Appearance();
TextureAttributes texAttr = new TextureAttributes();
texAttr.setTextureMode(TextureAttributes.MODULATE);

swingAppearance.setTextureAttributes(texAttr);

swingAppearance.setCapability(Appearance.ALLOW_TEXTURE_WRITE);

body = new FuzzyEdgePanel(width3D, height3D, 0.0005f, swingAppearance, false, 0, 0, 0, 0, true);

// body = new ClothTest(width3D, height3D, swingAppearance);

// ControlFrame controlFrame = new ControlFrame(body);

//controlFrame.setVisible(true);

addChild(body);

}

public void textureChanged(Texture2D texture) {

swingAppearance.setTexture(texture);

}

}
////////////////////////////////////////////

Below is a smmary of what I understand of basic SwingNode usage:

1)Create a subclass of SwingNodeRenderer (call this A) which in turn creates a geometry having a writable texture and uses addChild() to add it to itself.

2) Create a new instance of a SwingNode passing object "A" to the SwingNode constructor.

3) The SwingNodeRenderer child class "A" we described should have a public textureChanged method.

4) The geometry body in SwingNodeRenderer child "A" must extend BrancGroup

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
paulby
Offline
Joined: 2003-06-13

What errors are you seeing in the logs ?

ahamza
Offline
Joined: 2006-03-13

Note: line 239 is the FuzzyEdgePanel constructor (you had it commented in your code)

WARNING: Failed to start: org.jdesktop.lg3d.apps.hamza.swingnode.SwingNodeTest
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jdesktop.lg3d.utils.action.AppLaunchAction$1.run(AppLaunchAction.java:83)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoSuchMethodError: org.jdesktop.lg3d.utils.shape.FuzzyEdgePanel.(FFFLorg/jdesktop/lg3d/sg/Appearance;ZIIIIZ)V
at org.jdesktop.lg3d.apps.hamza.swingnode.SwingNodeTest$MySwingNodeGeometry.(SwingNodeTest.java:239)
at org.jdesktop.lg3d.apps.hamza.swingnode.SwingNodeTest.(SwingNodeTest.java:109)
at org.jdesktop.lg3d.apps.hamza.swingnode.SwingNodeTest.main(SwingNodeTest.java:83)

hideya
Offline
Joined: 2003-07-22

Hi ahamza,

The following error means...[code]Caused by: java.lang.NoSuchMethodError: org.jdesktop.lg3d.utils.shape.FuzzyEdgePanel.(FFFLorg/jdesktop/lg3d/sg/Appearance;ZIIIIZ)V[/code]
the following constructor is not available:[code]body = new FuzzyEdgePanel(width3D, height3D, 0.0005f, swingAppearance, false, 0, 0, 0, 0, true);[/code]
It seems that you compiled your code against one of older LG3D (possibly 0.7.x) but running using a newer version (0.8.x?) We sometimes make API changes between versions. Please be sure to use the latest version (or use the same version when you compile and run). If you do so, you would be able to catch such errors at compilation time.

As for the fix, please try the following line and see if it works fine:[code]
body = new FuzzyEdgePanel(width3D, height3D, swingAppearance);[/code]
Hope this helps,
hideya

hideya
Offline
Joined: 2003-07-22

Hi ahamza,

It looks that you picked up the code from commented out lines in SwingNodeTest.java. I've updated the usage examples of FuzzyEdgePanel there to follow the latest API.

Also, it looks like you just need a simple rectangular plane that shows SwingPanel. In that case, you may want to try out the default SwingNode shape by just saying:[code]SwingNode swingNode = new SwingNode(); // no SwingNodeRenderer object need to be provided[/code]

hideya

ahamza
Offline
Joined: 2006-03-13

Thanks, that new constructor (with 3 args) did it. I was using the 0.80 libraries and running on 0.81.