![]() |
|
|||||||
| Development Help Help for building applications or diagnosing problems with WWJ |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jun 2007
Posts: 4
![]() |
Hello,
I am trying to draw my own colored cylinder at the Earth's Surface in WorldWind. So I copied the JOGL drawing code from the Open GL calls in render() Method in Cylinder.java to my own cylinder class. When I draw a cylinder with the Cylinder class and then move the globe(with the mouse), the cylinder will immediately be re-rendered. The problem is: when I use my own cylinder class to draw a cylinder and then move the glob the cylinder is ONLY re-rendered some time AFTER releasing the mouse button. That means, the cylinder stays in its old position a little while, which looks ugly and is weird... My question: do I have to register my own cylinder class (it implements the interface "Renderable" as the existing Cylinder class) at some sort of SelectListener, PositionLister oder RenderingListener ??? maybe there is somewhere a statement like " if xxx instanceof Cylinder" or a check for the package "gov.nasa.worldwind.geom" ? When I look into Cylinder.java there is nothing been done in this direction. Maybe it is done "internally" in one of the xxxRenderer classes ? (IconRenderer, TrackRenderer etc ?) Which one is the "main" rendering class or the "RenderableRender" class ??? Now following: Code in my render method: (how do you create "Code :" rectangles in the forum posts ? Hello, I am trying to draw my own colored cylinder at the Earth's Surface in WorldWind. So I copied the JOGL drawing code from the Open GL calls in render() Method in Cylinder.java to my own cylinder class. When I draw a cylinder with the Cylinder class and then move the globe(with the mouse), the cylinder will immediately be re-rendered. The problem is: when I use my own cylinder class to draw a cylinder and then move the glob the cylinder is ONLY re-rendered some time AFTER releasing the mouse button. That means, the cylinder stays in its old position a little while, which looks ugly and is weird... My question: do I have to register my own cylinder class (it implements the interface "Renderable" as the existing Cylinder class) at some sort of SelectListener, PositionLister oder RenderingListener ??? maybe there is somewhere a statement like " if xxx instanceof Cylinder" or a check for the package "gov.nasa.worldwind.geom" when registering to those listeners ? When I look into Cylinder.java there is nothing been done in this direction. Maybe it is done "internally" in one of the xxxRenderer classes ? (IconRenderer, TrackRenderer etc ?) Which one is the "main" rendering class or the "RenderableRender" class ??? Now following: Code in my render method public void render(DrawContext dc) { GL gl = dc.getGL(); // gl.glPushAttrib(GL.GL_ENABLE_BIT | GL.GL_TRANSFORM_BIT); //line above commented out because: when using this line there is NO //Re-Rendering of my own cylinder any more !!! // Strangely in Cylinder.java this is used... //cylinder central line gl.glBegin(GL.GL_LINES); gl.glColor3d(1.0, 0.0, 0.0); gl.glVertex3d(bottomCenter.x(), bottomCenter.y(), bottomCenter.z()); gl.glVertex3d(topCenter.x(), topCenter.y(), topCenter.z()); gl.glEnd(); //depth test and modelview matrix ? gl.glEnable(GL.GL_DEPTH_TEST); gl.glMatrixMode(GL.GL_MODELVIEW); //save old matrix gl.glPushMatrix(); //center point bottom circle of cylinder gl.glTranslated(bottomCenter.x(), bottomCenter.y(), bottomCenter.z()); //rotate around Y Axis according to longitude dc.getGL().glRotated(p.getLongitude().ge tDegrees(), 0, 1, 0); //rotate around X Axis in correct direction according to latitude dc.getGL().glRotated(Math.abs(p.getLatit ude().getDegrees()), Math.signum(p.getLatitude().getDegrees() ) * -1, 0, 0); //draw cylinder "on" prepared(?) Quadric GLUquadric quad = dc.getGLU().gluNewQuadric(); double height = topCenter.distanceTo(bottomCenter); dc.getGLU().gluQuadricDrawStyle(quad, GLU.GLU_LINE); dc.getGLU().gluCylinder(quad, radius, radius, height, 30, 30); dc.getGLU().gluDeleteQuadric(quad); //load old matrix and attributes gl.glPopAttrib(); gl.glPopMatrix(); } all coordinate calculations done outside to rendering methods, similar to Cylinder.java Please take a look at Cylinder.java (in world wind java sdk sources) too ! bomberman |
|
|
|
|
|
#2 |
|
WWJ Consultant
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
![]() |
How do you get your cylinder to render ? - is it added to a RenderableLayer that is in the Model LayerList ?
Something like this ? Code:
// A renderable layer with a myCylinder renderable
public RenderableLayer myLayer() {
RenderableLayer layer = new RenderableLayer();
layer.addRenderable(new myCylinder(...));
return layer
}
Last edited by patmurris; 06-07-2007 at 01:14 AM. |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Jun 2007
Posts: 4
![]() |
yes it is added to a renderable layer like that.
by the way, I now simply copied the code from the Cylinder.java render method to another renderable-derived class... and that seems to work Did I mention I read and typed the code manually before ? Maybe I missed something or something was in the wrong order. bomberman |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Rendering RenderableObjectLists | nigel_ht | Developers' Corner | 2 | 05-05-2007 10:05 PM |
| 3D rendering | PostFatal | Developers' Corner | 3 | 02-05-2006 02:19 AM |
| height (vertical) 3d rendering | Guest_Daniel_* | WorldWind General | 4 | 02-22-2005 01:33 PM |
| Looking for DirectX Volume Rendering Package | Shirley Cohen | WorldWind General | 0 | 12-10-2004 02:02 AM |
| Button to turn elevation rendering on or off | Jacob | Suggestion Box | 2 | 12-02-2004 12:01 AM |