Announcement

Collapse
No announcement yet.

Growing box like structures inside WWJ

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Growing box like structures inside WWJ

    I recently did some work on SurfaceShape and Polyline, and i came to try the 'filled' option for the latter, to draw 3D 'shaded' boxes in WWJ :



    I'am not sure it could scale efficiently to more complex models though
    My World Wind Java Blog & WW.net Plugins page

  • #2
    Hello,
    first of all I have to say thank you for the great job you do.
    I'm a student from Germany and at the moment I'm try to figure out how to visualize geo-data using World Wind. In the last couple of days I was busy with the examples. Then I tried your 3D-example mentioned above, but unfortunately my walls are transparent. I only can see the grid. Any suggestions/hints?

    Best regards
    Sebastian

    P.S.: I'm using Windows XP, NetBeans 5.5 and World Wind release 0.4.1

    Comment


    • #3
      The above example was more of a hack with version 0.2 of the SDK and doesn't work anymore. Try making your own renderable using gl primitives.
      My World Wind Java Blog & WW.net Plugins page

      Comment


      • #4
        OK, thanks for the info.

        Comment


        • #5
          Hiya I'm trying to do something similar. I got it working in 0.2 using very similar code to you, but now i'm using 0.4 and the only thing I can do is draw wireframe models as soon as I try to fill the polylines the lines turn to a seroes of dots and the polylines remain unfilled.

          I'm trying to draw complex models but I've broken all the faces down into coplaner surfaces. All faces are drawn clockwise (when looking at the face), and are closed polylines (last point = first point).

          What do you mean by gl primatives?
          my knowledge of 3d modelling is very basic.
          Any help would be greatly appreciated.
          Screenshots to follow.
          Last edited by randomyachtie; 01-05-2008, 07:28 AM.
          "It is probable that a greater number of monuments to the skill and industry of man will in the course of ages be collected together in the bed of the ocean, than will exist at any one time on the surface of the continents."

          Charles Lyell. 1832. The Principles of Geology

          Comment


          • #6
            Ok, having read the "drawing cones" thread it looks like I should be using gl primatives to do this. Help! I have no idea about gl can anyone point me to some good blogs or posts about how to do this in World Wind?

            Many Thanks
            Attached Files
            "It is probable that a greater number of monuments to the skill and industry of man will in the course of ages be collected together in the bed of the ocean, than will exist at any one time on the surface of the continents."

            Charles Lyell. 1832. The Principles of Geology

            Comment


            • #7
              I think you need to specify the points in counter-clockwise so that the normal. Maybe this is the problem when filling the model.

              To draw conex you can take a look at the "cylinder" class, it uses quadrics to deaw a cylinder but you can modify a bit to draw a cone.
              |---------------------------------------
              | http://www.acuriousanimal.com/
              |---------------------------------------
              | http://theballoonproject.blogspot.com
              |---------------------------------------
              | _ __
              | /_| ( _ _/'_ _
              |( |. __)(//)//(/(/()
              | _/
              |---------------------------------------

              Comment


              • #8
                Please can someone explain why polygons are no longer filled since version 0.2?

                Code:
                // Deck
                        List<Position> positionList = new ArrayList<Position>();
                        positionList.add(new Position(Angle.fromDegrees(50.300595), Angle.fromDegrees(-4.249881), 84));
                	positionList.add(new Position(Angle.fromDegrees(50.304534), Angle.fromDegrees(-4.240098), 84));
                	positionList.add(new Position(Angle.fromDegrees(50.305868), Angle.fromDegrees(-4.242309), 84));
                	positionList.add(new Position(Angle.fromDegrees(50.301929), Angle.fromDegrees(-4.252093), 84));
                	positionList.add(new Position(Angle.fromDegrees(50.300595), Angle.fromDegrees(-4.249881), 84));
                        Polyline Deck = new Polyline(positionList);
                        Deck.setColor(new Color(128,128,128));
                        Deck.setPathType(Polyline.LINEAR);
                        Deck.setFilled(true);
                        layer.addRenderable(Deck);
                This is my code to draw a polygon using the polyline class. I've been through the polyline class and setting filled should mean that it's drawn as a polygon and therefore filled?

                Can anyone help. If I change the order of the positions it makes no difference. I've tried to pick appart the polygon class but I'm strugling as my knowledge is very limited and I can't even find the basic gl functions such as gl.glBegin!

                Many thanks.
                "It is probable that a greater number of monuments to the skill and industry of man will in the course of ages be collected together in the bed of the ocean, than will exist at any one time on the surface of the continents."

                Charles Lyell. 1832. The Principles of Geology

                Comment


                • #9
                  Hi,
                  as I'm struggling with the same problem, I tried to use some gl primitives. Here's my work in progress:

                  Code:
                  import javax.media.opengl.GL;
                  import javax.media.opengl.*;
                  import javax.media.opengl.glu.GLU;
                  
                  import gov.nasa.worldwind.render.*;
                  import gov.nasa.worldwind.globes.Globe;
                  import gov.nasa.worldwind.geom.*;
                  
                  import java.awt.*;
                  
                  
                  /**
                   *
                   * @author Sebastian Böckmann
                   */
                  public class PLine implements Renderable {
                      
                      private final Vec4 pos1;
                      private final Vec4 pos2;
                      private final Vec4 pos3;
                      
                      /** Creates a new instance of PLine */
                      public PLine(Vec4 pos1, Vec4 pos2, Vec4 pos3) {
                          this.pos1 = pos1;
                          this.pos2 = pos2;
                          this.pos3 = pos3;
                      }
                      public void render(DrawContext dc) {
                          
                          javax.media.opengl.GL gl = dc.getGL();
                          
                          gl.glPushAttrib(GL.GL_ENABLE_BIT | GL.GL_TRANSFORM_BIT);
                          
                          gl.glBegin(javax.media.opengl.GL.GL_POLYGON);
                          gl.glVertex3d(this.pos1.x, this.pos1.y, this.pos1.z);
                          gl.glVertex3d(this.pos2.x, this.pos2.y, this.pos2.z);
                          gl.glVertex3d(this.pos3.x, this.pos3.y, this.pos3.z);
                          gl.glEnd();
                          
                          gl.glEnable(javax.media.opengl.GL.GL_DEPTH_TEST);
                          gl.glMatrixMode(javax.media.opengl.GL.GL_MODELVIEW);
                          gl.glPushMatrix();
                  
                          gl.glPopMatrix();
                          gl.glPopAttrib();
                      }
                  }
                  for testing

                  Code:
                   public void buildPLineExample() {
                              Vec4 myPos1;
                              Vec4 myPos2;
                              Vec4 myPos3;
                              Globe g = getWwd().getModel().getGlobe();
                              myPos1 = g.computePointFromPosition(Angle.fromDegreesLatitude(5),Angle.fromDegreesLongitude(5),10000d);
                              myPos2 = g.computePointFromPosition(Angle.fromDegreesLatitude(6),Angle.fromDegreesLongitude(5),10000d);
                              myPos3 = g.computePointFromPosition(Angle.fromDegreesLatitude(5.5),Angle.fromDegreesLongitude(5),30000d);
                              PLine myPLine = new PLine(myPos1, myPos2, myPos3);
                              myPLineLayer.addRenderable(myPLine);
                              myPLineLayer.setName("Polyline-Demo");
                              insertBeforeCompass(getWwd(), myPLineLayer);
                          }
                  As I'm new to gl-programming I don't know if this is the right way. So all suggestions are welcome.

                  Best regards
                  Sebastian
                  Last edited by sebastian_b; 01-05-2008, 03:19 PM.

                  Comment


                  • #10
                    Hi Sebastian, it seems right.
                    If you implement your own Renderable you need to take into account store the attributes and matrices you modify and restore it later to not affect other objects.
                    Only a note, in your example you are not modifying the modelview matrix, you are not rotating, translating or scaling nothing, then you don't need to push and pop de MODELVIEW matrix, it is redundant.

                    Bye.
                    |---------------------------------------
                    | http://www.acuriousanimal.com/
                    |---------------------------------------
                    | http://theballoonproject.blogspot.com
                    |---------------------------------------
                    | _ __
                    | /_| ( _ _/'_ _
                    |( |. __)(//)//(/(/()
                    | _/
                    |---------------------------------------

                    Comment


                    • #11
                      Thats the way to go Sebastian. Some lines in PLine.render are probably not necessary - and missplaced (glEnable depth, matrix mode and push matrix). You are on the right track.

                      What results do you get?
                      My World Wind Java Blog & WW.net Plugins page

                      Comment


                      • #12
                        Thanks everybody for the support. Based on your suggestions I altered the code as follows:

                        Code:
                        import javax.media.opengl.GL;
                        import javax.media.opengl.*;
                        import javax.media.opengl.glu.GLU;
                        
                        import gov.nasa.worldwind.render.*;
                        import gov.nasa.worldwind.globes.Globe;
                        import gov.nasa.worldwind.geom.*;
                        
                        import java.awt.*;
                        import java.util.*;
                        
                        
                        /**
                         *
                         * @author Sebastian Böckmann
                         */
                        public class PLine implements Renderable {
                            
                            private final Color color;
                            private final ArrayList<Vec4> vecList;
                            
                            /** Creates a new instance of PLine */
                            public PLine(ArrayList<Vec4> vecList, Color theColor) {
                                this.color = theColor;
                                this.vecList = vecList;
                            }
                            
                            public void render(DrawContext dc) {
                                javax.media.opengl.GL gl = dc.getGL();
                                
                                gl.glPushAttrib(javax.media.opengl.GL.GL_TEXTURE_BIT | javax.media.opengl.GL.GL_ENABLE_BIT
                                        | javax.media.opengl.GL.GL_CURRENT_BIT);
                                gl.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) color.getAlpha());
                                
                                gl.glBegin(javax.media.opengl.GL.GL_POLYGON);
                                for (int i = 0; i < this.vecList.size(); i++) {
                                    Vec4 currentVec4 = this.vecList.get(i);
                                    gl.glVertex3d(currentVec4.x, currentVec4.y, currentVec4.z);
                                }
                                gl.glEnd();
                                
                                gl.glPopAttrib();
                            }
                        }
                        the new code for testing:
                        Code:
                                public void buildPLineExample() {
                                    ArrayList<Vec4> vec4List = new ArrayList<Vec4>();
                                    Globe g = getWwd().getModel().getGlobe();
                                    
                                    vec4List.clear();
                                    vec4List.add(g.computePointFromPosition(Angle.fromDegreesLatitude(5),Angle.fromDegreesLongitude(5),10000d));
                                    vec4List.add(g.computePointFromPosition(Angle.fromDegreesLatitude(6),Angle.fromDegreesLongitude(5),10000d));
                                    vec4List.add(g.computePointFromPosition(Angle.fromDegreesLatitude(5.5),Angle.fromDegreesLongitude(5),30000d));
                                    
                                    PLine myPLine1 = new PLine(vec4List, Color.ORANGE);
                                    myPLineLayer.addRenderable(myPLine1);
                                    myPLineLayer.setName("Polyline-Demo1");
                                    insertBeforeCompass(getWwd(), myPLineLayer);
                                }
                        and a picture of the result (attached).
                        Bye.
                        Attached Files

                        Comment


                        • #13
                          sebastian

                          Thanks for your input, I took your code and modified it a bit to fit into my project and it worked! Thanks for your help.

                          Now I was just modifying it so that it would work with arrays of points, and I see you've done it to.

                          Thanks again and all the best with your project.
                          "It is probable that a greater number of monuments to the skill and industry of man will in the course of ages be collected together in the bed of the ocean, than will exist at any one time on the surface of the continents."

                          Charles Lyell. 1832. The Principles of Geology

                          Comment


                          • #14
                            Code:
                            private RenderableLayer buildHullLayer(WorldWindow wwd) {
                                    RenderableLayer layer = new RenderableLayer();
                                    ArrayList<Vec4> vec4List = new ArrayList<Vec4>();
                                    Globe g = wwd.getModel().getGlobe();
                                    //--------------------------------
                                    // Hull
                                    //--------------------------------
                                    // PortBow1
                                    vec4List.clear();
                                    vec4List.add(g.computePointFromPosition(Angle.fromDegrees(50.298282), Angle.fromDegrees(-4.258388), 114));
                                    vec4List.add(g.computePointFromPosition(Angle.fromDegrees(50.298335), Angle.fromDegrees(-4.257598), 114));
                                    vec4List.add(g.computePointFromPosition(Angle.fromDegrees(50.298721), Angle.fromDegrees(-4.257297), -20));
                                    GLFace HullFace1 = new GLFace(vec4List, Color.ORANGE);
                                    layer.addRenderable(HullFace1);
                            // PortBow2
                                    vec4List.clear();
                                    vec4List.add(g.computePointFromPosition(Angle.fromDegrees(50.298335), Angle.fromDegrees(-4.257598), 114));
                                    vec4List.add(g.computePointFromPosition(Angle.fromDegrees(50.298466), Angle.fromDegrees(-4.256470), 114));
                                    vec4List.add(g.computePointFromPosition(Angle.fromDegrees(50.298721), Angle.fromDegrees(-4.257297), -20));
                                    GLFace HullFace2 = new GLFace(vec4List, Color.ORANGE);
                                    layer.addRenderable(HullFace2);
                            layer.setName("Hull");
                                    return layer;
                                }
                            I'm using the above code to draw multiple polygons using Sebastians Pline class, but when I run the code I only see a single polygon and it's always the last one I make.

                            I guess that for there's a line missing in the code which means that the existing polygons are being removed each time a new one is made.

                            Any suggestions?
                            "It is probable that a greater number of monuments to the skill and industry of man will in the course of ages be collected together in the bed of the ocean, than will exist at any one time on the surface of the continents."

                            Charles Lyell. 1832. The Principles of Geology

                            Comment


                            • #15
                              You are using the same 'vec4list' for both structures
                              When your function finishes both GLFace object has a reference to the same vec4list objec with the same informacion, the last that you set.
                              |---------------------------------------
                              | http://www.acuriousanimal.com/
                              |---------------------------------------
                              | http://theballoonproject.blogspot.com
                              |---------------------------------------
                              | _ __
                              | /_| ( _ _/'_ _
                              |( |. __)(//)//(/(/()
                              | _/
                              |---------------------------------------

                              Comment

                              Working...
                              X