Skip to main content

LG3D Question#2 (Netbeans integration)

6 replies [Last post]
ahamza
Offline
Joined: 2006-03-13
Points: 0

Hi again

This one is mainly for Paul Byrne, but if you know something please tell us!

We are integrating lg3d-core into netbeans as part of our UI-Builder project (we call it Plethora). Now to run it as an editor in netbeans we create wrapper projects for lg3d-core plus any other dependency. The problem is that the lg3d-core jar archive must be invoked with parameters as in the lg3d-dev.bat file for windows.

How to we include these parameters in a plugin-suite and where do we put the config files (lgcfg) for it to work?

By the way I want to thank Paul Byrne and Charlie Hunt (you must have heard of him) who have helped us on every step thus far. Hopefully when we are past these basics and we will not bother you so much..

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ahamza
Offline
Joined: 2006-03-13
Points: 0

Thanks Paul. We'll get back to you later on developments.

paulby
Offline
Joined: 2003-06-13
Points: 0

I've done this a couple of times and am currently working on a general solution to starting lg3d programatically.

Here is the current startup code

[code]
public class Lg3dConnector extends javax.swing.JPanel {

private AppConnectorPrivate appConnector;
private static Lg3dConnector connector = null;
private Semaphore lg3dStarted = new Semaphore(0);

/** Creates new form Lg3dConnector */
public Lg3dConnector() {
initComponents();
startLG3D();
try {
System.out.println("Waiting for lg3d to start");
lg3dStarted.acquire();
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}

private void startLG3D() {
String configURL = getClass().getClassLoader().getResource("org/jdesktop/lg3d/beans/internal/resource/etc/lg3dui/lgconfig_1p_nox.xml").toExternalForm();
String projectDir = configURL.substring(0, configURL.lastIndexOf("etc"));

System.setProperty("lg.universeFactory", "org.jdesktop.lg3d.beans.internal.BeansUniverseFactory");
System.setProperty("lg.configurl",configURL);
System.setProperty("lg.etcdir",projectDir+"/etc/");

System.setProperty("j3d.sortShape3DBounds", "true");

BeansUniverseFactory.addUniverseListener( new BeansUniverseFactory.UniverseListener() {
public void universeCreated( Canvas3D c3d ) {
Lg3dConnector.this.add("Center",c3d);
appConnector = AppConnectorPrivate.getAppConnector();
}
});

Thread main = new Thread() {
public void run() {
org.jdesktop.lg3d.displayserver.Main.main(null);
System.out.println("************Main returned");
lg3dStarted.release();
}
};
main.start();
}

public static Lg3dConnector getConnector() {
if (connector==null)
connector = new Lg3dConnector();
return connector;
}

public void addFrame3D(Frame3D frame) {
System.out.println("Adding frame -------------------------------------------");
appConnector.addFrame3D(frame);
}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
//
private void initComponents() {

setLayout(new java.awt.BorderLayout());

}//

// Variables declaration - do not modify
// End of variables declaration

}

[/code]

And the UniverseFactory

[code]
public class BeansUniverseFactory implements UniverseFactoryInterface {

private Logger logger = Logger.getLogger("lg.displayserver");
private Canvas3D c3d=null;

private static UniverseListener listener = null;

public ConfiguredUniverse createUniverse(URL configURL) {
GraphicsConfiguration config =
ConfiguredUniverse.getPreferredConfiguration();

c3d = new Canvas3D(config);

ConfiguredUniverse ret = new com.sun.j3d.utils.universe.ConfiguredUniverse(c3d);
View view = ret.getViewer().getView();
view.setWindowEyepointPolicy(View.RELATIVE_TO_COEXISTENCE);
view.setWindowMovementPolicy(View.VIRTUAL_WORLD);
view.setWindowResizePolicy(View.VIRTUAL_WORLD);
view.setScreenScalePolicy(View.SCALE_EXPLICIT);
view.setCoexistenceCenteringEnable(true);
view.setWindowEyepointPolicy(View.RELATIVE_TO_WINDOW);
view.setWindowMovementPolicy(View.PHYSICAL_WORLD);
view.setFrontClipDistance(0.01f);
view.setBackClipDistance(10f);

ViewPlatform vp = ret.getViewingPlatform().getViewPlatform();
vp.setViewAttachPolicy(View.NOMINAL_SCREEN);

c3d.getScreen3D().setPhysicalScreenHeight(0.360f);
c3d.getScreen3D().setPhysicalScreenWidth(0.288f);

ret.getViewingPlatform().setNominalViewingTransform();

c3d.setSize(250,250);

// URL url = null;
// try {
// url = new URL("file:///c:/paulby/code/java_net/lg3d/venice/lg3d-core/src/etc/lg3d/displayconfig/j3d1x1");
// } catch(MalformedURLException mue) {
// mue.printStackTrace();
// }
//
// ConfiguredUniverse ret = new ConfiguredUniverse(url);
// c3d = ret.getViewer().getView().getCanvas3D(0);
// Container cont = c3d.getParent();
// Window w = SwingUtilities.getWindowAncestor(c3d);
// cont.remove(c3d);
// w.setVisible(false);
// w.dispose();

if (listener!=null)
listener.universeCreated(c3d);
else
throw new RuntimeException("No Canvas3D listener registered");

return ret;
}

public static void addUniverseListener(UniverseListener l) {
listener = l;
}

public interface UniverseListener {
public void universeCreated( Canvas3D canvas );
}

}
[/code]

Hope that helps....

Mohamed El Geish

Did anyone make this work? I tried but it didn't work.

On 8/24/06, lg3d@javadesktop.org wrote:
>
> I've done this a couple of times and am currently working on a general
> solution to starting lg3d programatically.
>
> Here is the current startup code
>
> [code]
> public class Lg3dConnector extends javax.swing.JPanel {
>
> private AppConnectorPrivate appConnector;
> private static Lg3dConnector connector = null;
> private Semaphore lg3dStarted = new Semaphore(0);
>
> /** Creates new form Lg3dConnector */
> public Lg3dConnector() {
> initComponents();
> startLG3D();
> try {
> System.out.println("Waiting for lg3d to start");
> lg3dStarted.acquire();
> } catch (InterruptedException ex) {
> ex.printStackTrace();
> }
> }
>
> private void startLG3D() {
> String configURL =
> getClass().getClassLoader().getResource("org/jdesktop/lg3d/beans/internal/resource/etc/lg3dui/lgconfig_1p_nox.xml").toExternalForm();
> String projectDir = configURL.substring(0, configURL.lastIndexOf
> ("etc"));
>
> System.setProperty("lg.universeFactory", "
> org.jdesktop.lg3d.beans.internal.BeansUniverseFactory");
> System.setProperty("lg.configurl",configURL);
> System.setProperty("lg.etcdir",projectDir+"/etc/");
>
> System.setProperty("j3d.sortShape3DBounds", "true");
>
> BeansUniverseFactory.addUniverseListener( new
> BeansUniverseFactory.UniverseListener() {
> public void universeCreated( Canvas3D c3d ) {
> Lg3dConnector.this.add("Center",c3d);
> appConnector = AppConnectorPrivate.getAppConnector();
> }
> });
>
> Thread main = new Thread() {
> public void run() {
> org.jdesktop.lg3d.displayserver.Main.main(null);
> System.out.println("************Main returned");
> lg3dStarted.release();
> }
> };
> main.start();
> }
>
> public static Lg3dConnector getConnector() {
> if (connector==null)
> connector = new Lg3dConnector();
> return connector;
> }
>
> public void addFrame3D(Frame3D frame) {
> System.out.println("Adding frame
> -------------------------------------------");
> appConnector.addFrame3D(frame);
> }
>
> /** This method is called from within the constructor to
> * initialize the form.
> * WARNING: Do NOT modify this code. The content of this method is
> * always regenerated by the Form Editor.
> */
> //
> private void initComponents() {
>
> setLayout(new java.awt.BorderLayout());
>
> }//

>
>
> // Variables declaration - do not modify
> // End of variables declaration
>
> }
>
> [/code]
>
> And the UniverseFactory
>
> [code]
> public class BeansUniverseFactory implements UniverseFactoryInterface {
>
> private Logger logger = Logger.getLogger("lg.displayserver");
> private Canvas3D c3d=null;
>
> private static UniverseListener listener = null;
>
> public ConfiguredUniverse createUniverse(URL configURL) {
> GraphicsConfiguration config =
> ConfiguredUniverse.getPreferredConfiguration();
>
> c3d = new Canvas3D(config);
>
> ConfiguredUniverse ret = new
> com.sun.j3d.utils.universe.ConfiguredUniverse(c3d);
> View view = ret.getViewer().getView();
> view.setWindowEyepointPolicy(View.RELATIVE_TO_COEXISTENCE);
> view.setWindowMovementPolicy(View.VIRTUAL_WORLD);
> view.setWindowResizePolicy(View.VIRTUAL_WORLD);
> view.setScreenScalePolicy(View.SCALE_EXPLICIT);
> view.setCoexistenceCenteringEnable(true);
> view.setWindowEyepointPolicy(View.RELATIVE_TO_WINDOW);
> view.setWindowMovementPolicy(View.PHYSICAL_WORLD);
> view.setFrontClipDistance(0.01f);
> view.setBackClipDistance(10f);
>
> ViewPlatform vp = ret.getViewingPlatform().getViewPlatform();
> vp.setViewAttachPolicy(View.NOMINAL_SCREEN);
>
> c3d.getScreen3D().setPhysicalScreenHeight(0.360f);
> c3d.getScreen3D().setPhysicalScreenWidth(0.288f);
>
> ret.getViewingPlatform().setNominalViewingTransform();
>
> c3d.setSize(250,250);
>
> // URL url = null;
> // try {
> // url = new URL("
> file:///c:/paulby/code/java_net/lg3d/venice/lg3d-core/src/etc/lg3d/displ...
> ");
> // } catch(MalformedURLException mue) {
> // mue.printStackTrace();
> // }
> //
> // ConfiguredUniverse ret = new ConfiguredUniverse(url);
> // c3d = ret.getViewer().getView().getCanvas3D(0);
> // Container cont = c3d.getParent();
> // Window w = SwingUtilities.getWindowAncestor(c3d);
> // cont.remove(c3d);
> // w.setVisible(false);
> // w.dispose();
>
> if (listener!=null)
> listener.universeCreated(c3d);
> else
> throw new RuntimeException("No Canvas3D listener registered");
>
> return ret;
> }
>
> public static void addUniverseListener(UniverseListener l) {
> listener = l;
> }
>
> public interface UniverseListener {
> public void universeCreated( Canvas3D canvas );
> }
>
> }
> [/code]
>
> Hope that helps....
> [Message sent by forum member 'paulby' (paulby)]
>
> http://forums.java.net/jive/thread.jspa?messageID=146410
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@lg3d.dev.java.net
> For additional commands, e-mail: interest-help@lg3d.dev.java.net
>
>

--
--
The content of this document is classified as Confidential and Proprietary
Information. The recipient hereby is committed to hold in strict confidence
the contents of this (e-mail, document, information) and not to disclose to
any third party without the prior written consent. Recipient will be held
liable for any unauthorized disclosure. If you have received this message in
error, please notify the sender by return e-mail and delete the message in
its entirety, including any attachments.

Mohamed El-Geish
AUC SU IT Unit Co-ordinator
(+2) 012-361-9904
[att1.html]

paulby
Offline
Joined: 2003-06-13
Points: 0

I've added working code to a branch in cvs.

cvs co -r appkit lg3d-core lg3d-demo-apps

from lg3d-core 'ant run-appkittest' will start the example.

This is early code that has not have an API review yet so there is a good chance it will change before being integrated into HEAD.

paulby
Offline
Joined: 2003-06-13
Points: 0

I screwed up, the appkit branch is busted. It will take me a couple of days (at least) to fix so bare with me.

Applogies

Paul

cymryjian
Offline
Joined: 2008-10-05
Points: 0

Greetings:

I'm new to Java3D but not to Java and JMF.

I'm a bit configured on how to import a recently saved SceneGraph from the SceneGraphFileWriter using the SceneGraphFileReader. The data saved and created a 396kb file.

I'm using the SimpleUniverse, but need to import the saved data for an application (Game) and the original idea was to create the models, levels, etc. then create a Java3D file to store the "level" data.

Am I right to assume that I need to use the ConfiguredUniverse instead of the SimpleUniverse to reload the saved data from the disk?

Do you know of any place that has coding examples that I could look at to get a feel of how to tackle my problem?

Cheers,
-Cymryjian.