Skip to content
This repository has been archived by the owner on Mar 4, 2023. It is now read-only.

Commit

Permalink
Vistas estructura
Browse files Browse the repository at this point in the history
  • Loading branch information
Lifka committed Apr 25, 2016
1 parent eaded63 commit 196248c
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 70 deletions.
4 changes: 2 additions & 2 deletions SistemaSolar/src/sistemaSolar/Estrella.java
Expand Up @@ -58,12 +58,12 @@ public void makeTransform(Canvas3D canvas){
TransformGroup rota = getRotartransform(rotacion_false,1);

// PICK
PickForStop ps = new PickForStop(canvas);
/* PickForStop ps = new PickForStop(canvas);
ps.stopTransform(this);
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), radio_false/4);
ps.setSchedulingBounds(bounds);
rota.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
rota.addChild(ps);
rota.addChild(ps);*/
// END PICK

rota.addChild(esfera);
Expand Down
16 changes: 4 additions & 12 deletions SistemaSolar/src/sistemaSolar/Gui.java
Expand Up @@ -7,10 +7,8 @@
package sistemaSolar;

import com.sun.j3d.utils.universe.SimpleUniverse;
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GraphicsConfiguration;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
Expand Down Expand Up @@ -97,16 +95,13 @@ public static void main(String[] args) {
// Crear Simple Universe
Universo universe = new Universo(new String(), canvas);
// Sale de nuestra propia clase
SimpleUniverse simpleUniverse = universe.createUniverso();
universe.createUniverso();

// Crear los astros
universe.crearSistemaSolar();
HashMap<String,Astro> astros = universe.getAstros();
ArrayList<Astro> astros_array = universe.getAstrosArray();

// Hacemos visible la ventana
// visualizationWindows.setVisible(true);

// Creamos el árbol
BranchGroup raiz = new BranchGroup();

Expand All @@ -126,8 +121,6 @@ public static void main(String[] args) {
grupoArotar.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);


BoundingSphere bounds = new BoundingSphere();

// Añadimos la luz puntual al sol
LuzPuntual lp = new LuzPuntual(new Color3f(Color.WHITE));
grupoArotar.addChild(lp);
Expand All @@ -153,15 +146,14 @@ public static void main(String[] args) {
((Planeta)astros.get("tierra")).cloudEnabled(true, "src/texturas_planetas/cloud.png");


simpleUniverse.getViewingPlatform().setNominalViewingTransform();

raiz.addChild(background);
raiz.addChild(new Nave().getNaveBranch());
raiz.compile();
simpleUniverse.addBranchGraph(raiz);

universe.locale.addBranchGraph(raiz);
/*
Gui windows1 = new Gui(canvas, "Planta fija", PLANTA);
Gui windows2 = new Gui(canvas2, "Vistas", VISTAS);
Gui windows2 = new Gui(canvas2, "Vistas", VISTAS);*/
}

}
82 changes: 54 additions & 28 deletions SistemaSolar/src/sistemaSolar/Universo.java
Expand Up @@ -21,14 +21,15 @@
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.Canvas3D;
import javax.media.j3d.Locale;
import javax.media.j3d.Material;
import javax.media.j3d.PhysicalBody;
import javax.media.j3d.PhysicalEnvironment;
import javax.media.j3d.PointLight;
import javax.media.j3d.Texture;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.View;
import javax.media.j3d.ViewPlatform;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;
Expand All @@ -41,6 +42,8 @@ public class Universo {
final int TRASLADO_SOL = 200000;
final int TRASLADO_ORB = 200000;
final float ESCALE = 0.1f;
Locale locale;



public Universo (String archivo_text,Canvas3D aCanvas){
Expand Down Expand Up @@ -263,63 +266,87 @@ public void crearSistemaSolar(){
}




public SimpleUniverse createUniverso(){

/*********** VIEWINGPLATFORM **********/
/*
/*********** VIEWINGPLATFORM **********/

// Creamos lo que hace que se vean las cosas, manualmente, para poder asignarlo
// y personalizarlo
ViewingPlatform viewingPlatform = new ViewingPlatform();
// ViewingPlatform viewingPlatform = new ViewingPlatform();
// Radio de activación
viewingPlatform.getViewPlatform().setActivationRadius(100f);

/* viewingPlatform.getViewPlatform().setActivationRadius(100f);
*/
// Transformación de vista -> dónde se está , a dónde se mira , Vup
TransformGroup viewTransformGroup = viewingPlatform.getViewPlatformTransform();
/* TransformGroup viewTransformGroup = viewingPlatform.getViewPlatformTransform();
Transform3D viewTransform3D = new Transform3D ( );
viewTransform3D.lookAt (new Point3d (0 ,10 ,0 ),
new Point3d (0, 0, 0), new Vector3d (0 ,0 ,-1));
viewTransform3D.invert();
viewTransformGroup.setTransform(viewTransform3D);

// Mover la cámara con el ratón
OrbitBehavior orbit = new OrbitBehavior (aCanvas, OrbitBehavior.REVERSE_ALL);
*/
// Mover la cámara con el ratón*************
/* OrbitBehavior orbit = new OrbitBehavior (aCanvas, OrbitBehavior.REVERSE_ALL);
orbit.setSchedulingBounds(new BoundingSphere (new Point3d (0.0f, 0.0f , 0.0f) , 100.0f));
orbit.setZoomFactor(5.0f);
viewingPlatform.setViewPlatformBehavior(orbit);
viewingPlatform.setViewPlatformBehavior(orbit);*/
//*******************************************


/************** VIEWER **************/

/*
Viewer viewer = new Viewer(aCanvas);
View view = viewer.getView();
view.setFieldOfView(Math.toRadians(45));
view.setBackClipDistance(50.0);
*/

/*
Viewer viewer = new Viewer(aCanvas);
View viewPlanta = viewer.getView();
// return (new SimpleUniverse(viewingPlatform,viewer));


public void createUniverso(){
SimpleUniverse simpleUniverse = new SimpleUniverse();
locale = new Locale(simpleUniverse);
// BranchGroup vistas = new BranchGroup();
//vistas.addChild(getViewPlanta());
//simpleUniverse.getViewingPlatform().setNominalViewingTransform();
//locale.addBranchGraph(vistas);

}

public TransformGroup getViewPlanta(){
// TransformGroup para posicionar y orientar la vista
Transform3D transformPlanta = new Transform3D ();
transformPlanta.lookAt(new Point3d(0, 10, 0), new Point3d (0, 0, 0),
new Vector3d(0, 0, -1));

transformPlanta.invert();

TransformGroup tgPlanta = new TransformGroup(transformPlanta);
ViewPlatform vpPlanta = new ViewPlatform();

tgPlanta.addChild(vpPlanta);

// Definición de la vista paralela

View viewPlanta = new View();
viewPlanta.setPhysicalBody(new PhysicalBody());
viewPlanta.setPhysicalEnvironment(new PhysicalEnvironment());
viewPlanta.setProjectionPolicy(View.PARALLEL_PROJECTION);
viewPlanta.setProjectionPolicy(View .PARALLEL_PROJECTION);
viewPlanta.setScreenScalePolicy(View.SCALE_EXPLICIT);
viewPlanta.setScreenScale(0.1);
viewPlanta.setFrontClipDistance(10);
viewPlanta.setBackClipDistance(-10);
viewPlanta.attachViewPlatform(viewingPlatform.getViewPlatform());
viewPlanta.setScreenScale(0.01);
viewPlanta.setFrontClipDistance(0.1);
viewPlanta.setBackClipDistance(20);

*/
viewPlanta.addCanvas3D(aCanvas);
viewPlanta.attachViewPlatform(vpPlanta);

return (new SimpleUniverse(viewingPlatform,viewer));

return tgPlanta;
}



public BranchGroup createBackground(){

Background background = new Background();
Expand Down Expand Up @@ -348,5 +375,4 @@ public BranchGroup createBackground(){
return backgroundBranch;
}


}
28 changes: 0 additions & 28 deletions SistemaSolar/src/sistemaSolar/Visualization.java

This file was deleted.

0 comments on commit 196248c

Please sign in to comment.