1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| public BranchGroup construitScene()
{
BranchGroup BG = new BranchGroup();
Scene scene_telecharger = null;
try
{
ObjectFile fichier_scene= new ObjectFile();
scene_telecharger = fichier_scene.load("chemin...........obj");
}
catch(Exception e)
{
System.out.println("fichier introuvable ");
}
Color3f couleur = new Color3f(1.0f,1.0f,1.0f);
AmbientLight lumiére = new AmbientLight(couleur);
BoundingSphere zone_eclairer = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 500);
lumiére.setInfluencingBounds(zone_eclairer);
BG.addChild(lumiére);
Shape3D forme3D = new ColorCube(0.3);
TransformGroup TG2 = new TransformGroup();
Transform3D rotation1 = new Transform3D();
// comme un timeur qui exécute une action a chque 4 seconde
Alpha timer_declencheur = new Alpha(-1,2000);
// 0.0f----> Math*PI*2.0 = rotation de 0 a 2PI
RotationInterpolator mouvement_de_rotation =new RotationInterpolator( timer_declencheur,TG,rotation1,0.0f,(float)Math.PI*2.0f);
//definir la zone de mouvement
BoundingSphere region_de_mouvement = new BoundingSphere(new Point3d(0.0,0.0,0.0),100.0);
mouvement_de_rotation.setSchedulingBounds(region_de_mouvement);
TG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
TG.addChild(scene_telecharger.getSceneGroup());
TG.addChild(mouvement_de_rotation);
BG.addChild(TG);
BG.compile();
return BG;
} |
Partager