wireframe mode

Is it possible?

Erm ?

Please specify your question a bit more precise ;D

Sure is Wireframe rendering possible …

  • Jens

Do you mean:

glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

??

If so… yes. You can do that.

And to switch back to solid mode, use :

glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

:slight_smile:
++
Chman

I want to render my aster with a vireframe instead of filled quadrants


package dts.client.impspace;

import org.lwjgl.opengl.GL;

import dts.client.e3d.StaticModel;
import dts.client.e3d.Texture;
import dts.client.e3d.Coord;

public class Aster extends StaticModel {
      
      private double _radius;      
      private Texture _texture;
      private int            _n=100;//precision of grade divisions
      private Coord _coord = new Coord(0.0f,0.0f,0.0f);
      public Aster(float radius,Texture texture)
      {
            super();
            //setRotation(new Coord(-90.0f,1.0f,0.0f));
            _radius=radius;
            _texture=texture;
            compile();
      }
      
      public void compile()
      {
            GL.glNewList(_handle,GL.GL_COMPILE);
            GL.glColor3f(1.0f,1.0f,1.0f);
            this.render(0);
            GL.glEndList();
      }
      
      public void draw(long t)
      {
            //processPosition();
            GL.glColor3f(1.0f,1.0f,1.0f);
            GL.glCallList(_handle);
      }
      
      public void render(int mode)
      {
            super.render(mode);
// TODO : redo without GLU            int quadric=GLU.gluNewQuadric();
//            GLU.gluQuadricNormals(quadric,GLU.GLU_SMOOTH);
//            GLU.gluQuadricTexture(quadric, true);
            _texture.bind();
//            GLU.gluSphere(quadric,_radius,60,60);
            
            //dont want to change varible name lazy
            double r      = _radius;
            int n      = _n;
            Coord  c      = _coord;
            
            final double PI       = Math.PI;
            final double TWOPI = Math.PI *2.0f;
            final double PID2       = Math.PI * 0.5f;

            int i,j;
            double theta1,theta2,theta3;
            //Coord e,p;
            Coord e= new Coord();
            Coord p= new Coord();
            
            if (r < 0)
                  r = -r;
            if (n < 0)
               n = -n;
            if (n < 4 || r <= 0) {
               GL.glBegin(GL.GL_POINTS);
               GL.glVertex3f(c.getX(),c.getY(),c.getZ());
               GL.glEnd();
               return;
            }
            for (j=0;j<n/2;j++) {
               theta1 = j * TWOPI / n - PID2;
               theta2 = (j + 1) * TWOPI / n - PID2;

               GL.glBegin(GL.GL_QUAD_STRIP);
               for (i=0;i<=n;i++) {
                    theta3 = i * TWOPI / n;
             
                    e.setX((float)(Math.cos(theta2) * Math.cos(theta3)));
                    e.setY((float)(Math.sin(theta2)));
                    e.setZ((float)(Math.cos(theta2) * Math.sin(theta3)));
                    p.setX((float)(c.getX() + r * e.getX()));
                    p.setY((float)(c.getY() + r * e.getY()));
                    p.setZ((float)(c.getZ() + r * e.getZ()));

                    GL.glNormal3f(e.getX(),e.getY(),e.getZ());
                    GL.glTexCoord2f(i/(float)n,2*(j+1)/(float)n);
                    GL.glVertex3f(p.getX(),p.getY(),p.getZ());

                    e.setX((float)(Math.cos(theta1) * Math.cos(theta3)));
                    e.setY((float)(Math.sin(theta1)));
                    e.setZ((float)(Math.cos(theta1) * Math.sin(theta3)));
                    p.setX((float)(c.getX() + r * e.getX()));
                    p.setY((float)(c.getY() + r * e.getY()));
                    p.setZ((float)(c.getZ() + r * e.getZ()));

                    GL.glNormal3f(e.getX(),e.getY(),e.getZ());
                    GL.glTexCoord2f(i/(float)n,2*j/(float)n);
                    GL.glVertex3f(p.getX(),p.getY(),p.getZ());
               }
               GL.glEnd();
            }
      }
}




nm added this and it worked

GL.glPolygonMode(GL.GL_FRONT_AND_BACK,GL.GL_LINE);

heh… next question… if I want to show the wires as well as the texture… how would I proceed… I plan to use the wires and longtitude and latitude

Draw it twice; once with textures, the second time, using line mode.

Cas :slight_smile:

Changed it to this… I render it twice… but should i create two asters?



package dts.client.impspace;

import org.lwjgl.opengl.GL;

import dts.client.e3d.StaticModel;
import dts.client.e3d.Texture;
import dts.client.e3d.Coord;

public class Aster extends StaticModel {
      
      private double _radius;      
      private Texture _texture;
      private int            _n=50;//precision of grade divisions
      private Coord _coord = new Coord(0.0f,0.0f,0.0f);
      public Aster(float radius,Texture texture)
      {
            super();
            //setRotation(new Coord(-90.0f,1.0f,0.0f));
            _radius=radius;
            _texture=texture;
            compile();
      }
      
      public void compile()
      {
            GL.glNewList(_handle,GL.GL_COMPILE);
            GL.glColor3f(1.0f,1.0f,1.0f);
            this.render(1);
            this.render(0);
            
            GL.glEndList();
      }
      
      public void draw(long t)
      {
            //processPosition();
            GL.glColor3f(1.0f,1.0f,1.0f);
            GL.glCallList(_handle);
      }
      
      public void render(int mode)
      {
            super.render(mode);
// TODO : redo without GLU            int quadric=GLU.gluNewQuadric();
//            GLU.gluQuadricNormals(quadric,GLU.GLU_SMOOTH);
//            GLU.gluQuadricTexture(quadric, true);
            _texture.bind();
//            GLU.gluSphere(quadric,_radius,60,60);
            
            //dont want to change varible name lazy
            double r      = _radius;
            int n      = _n;
            Coord  c      = _coord;
            
            final double PI       = Math.PI;
            final double TWOPI = Math.PI *2.0f;
            final double PID2       = Math.PI * 0.5f;
            if (mode==1)GL.glPolygonMode(GL.GL_FRONT_AND_BACK,GL.GL_LINE);
            
            if(mode==0)GL.glPolygonMode(GL.GL_FRONT_AND_BACK,GL.GL_FILL); 

            int i,j;
            
            double theta1,theta2,theta3;
            //Coord e,p;
            Coord e= new Coord();
            Coord p= new Coord();
            
            if (r < 0)
                  r = -r;
            if (n < 0)
               n = -n;
            if (n < 4 || r <= 0) {
               GL.glBegin(GL.GL_POINTS);
               GL.glVertex3f(c.getX(),c.getY(),c.getZ());
               GL.glEnd();
               return;
            }
            for (j=0;j<n/2;j++) {
               theta1 = j * TWOPI / n - PID2;
               theta2 = (j + 1) * TWOPI / n - PID2;

               GL.glBegin(GL.GL_TRIANGLE_STRIP);
               for (i=0;i<=n;i++) {
                    theta3 = i * TWOPI / n;
             
                    e.setX((float)(Math.cos(theta2) * Math.cos(theta3)));
                    e.setY((float)(Math.sin(theta2)));
                    e.setZ((float)(Math.cos(theta2) * Math.sin(theta3)));
                    p.setX((float)(c.getX() + r * e.getX()));
                    p.setY((float)(c.getY() + r * e.getY()));
                    p.setZ((float)(c.getZ() + r * e.getZ()));

                    GL.glNormal3f(e.getX(),e.getY(),e.getZ());
                    GL.glTexCoord2f(i/(float)n,2*(j+1)/(float)n);
                    GL.glVertex3f(p.getX(),p.getY(),p.getZ());

                    e.setX((float)(Math.cos(theta1) * Math.cos(theta3)));
                    e.setY((float)(Math.sin(theta1)));
                    e.setZ((float)(Math.cos(theta1) * Math.sin(theta3)));
                    p.setX((float)(c.getX() + r * e.getX()));
                    p.setY((float)(c.getY() + r * e.getY()));
                    p.setZ((float)(c.getZ() + r * e.getZ()));

                    GL.glNormal3f(e.getX(),e.getY(),e.getZ());
                    GL.glTexCoord2f(i/(float)n,2*j/(float)n);
                    GL.glVertex3f(p.getX(),p.getY(),p.getZ());
               }
               GL.glEnd();
            }
      }
}