JAVA3D MON PROPRE UNIVERS . . .

cs_tds Messages postés 351 Date d'inscription mercredi 21 janvier 2004 Statut Membre Dernière intervention 9 décembre 2004 - 18 mars 2004 à 12:32
dmaillet Messages postés 500 Date d'inscription mercredi 20 août 2003 Statut Membre Dernière intervention 11 juillet 2007 - 11 mai 2005 à 10:46
Voilà, je ne parviens pas à bouger dans mon univers (VirtualUniverse). Je ne veux pas utiliser SimpleUniverse parce que certaines objects view... sont isLive == true et je ne peux donc pas changer des capabilities...

VOICI MON UNIVERSE
*****************
package SystemeSolaire;

import com.sun.j3d.utils.universe.ViewingPlatform;
import javax.vecmath.Vector3f;

import javax.media.j3d.BranchGroup;
import javax.media.j3d.Canvas3D;
import javax.media.j3d.Locale;
import javax.media.j3d.PhysicalBody;
import javax.media.j3d.PhysicalEnvironment;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.View;
import javax.media.j3d.ViewPlatform;
import javax.media.j3d.VirtualUniverse;

public class UniverseBuilder extends Object{

// User-specified canvas
private Canvas3D canvas;
// Scene graph elements to which the user may want access
private BranchGroup vpRoot = new BranchGroup();
private VirtualUniverse universe;
private Locale locale;
private TransformGroup vpTrans;
private View view;

/**
* Constructeur
* @author B@ron (IPL)
* @param Canvas3D
* @version 1.0
* @since 1.4
*/
public UniverseBuilder(Canvas3D c) {

this.canvas = c;
//Establish a virtual universe that has a single
// hi-res Locale

universe = new VirtualUniverse();
locale = new Locale(universe);

// Create a PhysicalBody and PhysicalEnvironment object

PhysicalBody body = new PhysicalBody();
PhysicalEnvironment environment = new PhysicalEnvironment();


view = new View();
view.addCanvas3D(c);
view.setPhysicalBody(body);
view.setPhysicalEnvironment(environment);

// Create a BranchGroup node for the view platform
BranchGroup vpRoot = new BranchGroup();

// Create a ViewPlatform object, and its associated
// TransformGroup object, and attach it to the root of the
// subgraph. Attach the view to the view platform.
Transform3D t = new Transform3D();
t.set(new Vector3f(0.0f, 0.0f, 2.0f));
ViewPlatform vp = new ViewPlatform();
vpTrans = new TransformGroup(t);
view.attachViewPlatform(vp);
vpTrans.addChild(vp);
vpRoot.addChild(vpTrans);

// Attach the branch graph to the universe, via the
// Locale. The scene graph is now live!
locale.addBranchGraph(vpRoot);
}

/**
* addBranchGraph
* @author B@ron (IPL)
* @param BranchGroup
* @version 1.0
* @since 1.4
*/
public void addBranchGraph(BranchGroup bg) {
locale.addBranchGraph(bg);
}

/***********************/
/* LES GET ET LES SETS */
/***********************/
public VirtualUniverse getVirtualUniverse(){ return universe; }
public Locale getLocale (){ return locale; }
public TransformGroup getTransformGroup (){ return vpTrans; }
public View getView (){ return view; }
public Canvas3D getCanvas3D (){ return canvas; }
public BranchGroup getBranchRoot (){ return vpRoot; }
}

VOICI SIMPLEUNIVERSE (DE JAVA)
***************************
///////////////////////////////////////////////////////////
// DeJaved by mDeJava v1.0. Copyright 1999 MoleSoftware. //
// To download last version of this software: //
// http://molesoftware.hypermatr.net //
// e-mail:molesoftware@mail.ru //
///////////////////////////////////////////////////////////
// JAD JavaDecompiler by Pavel Kuznetsov //
// www.geocities.com/SiliconValley/Bridge/8617/jad.html //
///////////////////////////////////////////////////////////

package com.sun.j3d.utils.universe;

import java.awt.*;
import java.net.URL;
import java.security.AccessController;
import javax.media.j3d.*;

// Referenced classes of package com.sun.j3d.utils.universe:
// ViewingPlatform, Viewer, LocaleFactory

public class SimpleUniverse extends VirtualUniverse
{

protected Locale locale = null;
protected Viewer viewer[] = null;

public SimpleUniverse()
{
this(null, 1, null, null);
}

public SimpleUniverse(int i)
{
this(null, i, null, null);
}

public SimpleUniverse(Canvas3D canvas3d)
{
this(null, 1, canvas3d, null);
}

public SimpleUniverse(Canvas3D canvas3d, int i)
{
this(null, i, canvas3d, null);
}

public SimpleUniverse(HiResCoord hirescoord, int i, Canvas3D canvas3d, URL url)
{
this(hirescoord, i, canvas3d, url, null);
}

public SimpleUniverse(HiResCoord hirescoord, int i, Canvas3D canvas3d, URL url, LocaleFactory localefactory)
{
viewer = null;
createLocale(hirescoord, localefactory);
ViewingPlatform viewingplatform = new ViewingPlatform(i);
viewingplatform.setUniverse(this);
viewer = new Viewer[1];
viewer[0] = new Viewer(canvas3d);
viewer[0].setViewingPlatform(viewingplatform);
locale.addBranchGraph(viewingplatform);
}

public SimpleUniverse(ViewingPlatform viewingplatform, Viewer viewer1)
{
this(viewingplatform, viewer1, null);
}

public SimpleUniverse(ViewingPlatform viewingplatform, Viewer viewer1, LocaleFactory localefactory)
{
viewer = null;
createLocale(null, localefactory);
viewingplatform.setUniverse(this);
viewer = new Viewer[1];
viewer[0] = viewer1;
viewer[0].setViewingPlatform(viewingplatform);
locale.addBranchGraph(viewingplatform);
}

SimpleUniverse(HiResCoord hirescoord, LocaleFactory localefactory)
{
viewer = null;
createLocale(hirescoord, localefactory);
}

private void createLocale(HiResCoord hirescoord, LocaleFactory localefactory)
{
if(localefactory != null)
{
if(hirescoord != null)
locale = localefactory.createLocale(this, hirescoord);
else
locale = localefactory.createLocale(this);
}
else
if(hirescoord != null)
locale = new Locale(this, hirescoord);
else
locale = new Locale(this);
}

public Locale getLocale()
{
return locale;
}

public Viewer getViewer()
{
return viewer[0];
}

public ViewingPlatform getViewingPlatform()
{
return viewer[0].getViewingPlatform();
}

public Canvas3D getCanvas()
{
return getCanvas(0);
}

public Canvas3D getCanvas(int i)
{
return viewer[0].getCanvas3D(i);
}

public void addBranchGraph(BranchGroup branchgroup)
{
locale.addBranchGraph(branchgroup);
}

public static GraphicsConfiguration getPreferredConfiguration()
{
GraphicsConfigTemplate3D graphicsconfigtemplate3d = new GraphicsConfigTemplate3D();
String s = (String)AccessController.doPrivileged(new Object() /* anonymous class not found */
class _anm1 {}

);
if(s != null)
if(s.equals("REQUIRED"))
graphicsconfigtemplate3d.setStereo(1);
else
if(s.equals("PREFERRED"))
graphicsconfigtemplate3d.setStereo(2);
return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration(graphicsconfigtemplate3d);
}

public void cleanup()
{
viewer[0].getView().removeAllCanvas3Ds();
viewer[0].setViewingPlatform(null);
removeAllLocales();
Viewer.clearViewerMap();
}
}

HELP ME :'(

B@ron

22 réponses

sofien007 Messages postés 26 Date d'inscription samedi 16 octobre 2004 Statut Membre Dernière intervention 25 novembre 2008 1
11 mai 2005 à 10:42
Merci pour la reponse mais je n'ai PickMouseTranslate.

Pouvez me le donner ou bien donner moi svp un lien ou je vais le trouvé



Merci
0
dmaillet Messages postés 500 Date d'inscription mercredi 20 août 2003 Statut Membre Dernière intervention 11 juillet 2007
11 mai 2005 à 10:46
Dsl, c'est PickTranslateBehavior le nom exact.

-------------------
dams
-------------------
0
Rejoignez-nous