Hi Alvaro,

I don't know, if this does help you, but my application is setting the
clipping distances like the following:

My 3D-Scene consists of several layers (like in CAD or GIS-Systems)
Each layer has a bounding box. Out of this bounding box I am
calculating an approximate middle point for my current scene.
Then I am calculating the distance, which is necessary to go back
along the z-Axis to see the entire scene. With this distance I am
moving the viewing platform. My actual 3D-Objects are live somewhere near
(0,0,0). I am calculating this distance in the following method:

    /**
     * Calculates the values for InitialPosition from the WorldBox
     * and range
     * of baseheight
     */
    public void setInitialPosition(WorldBox wb) {
        this.wb=wb;
        // middle of WorldBox
        this.xm=(wb.getLrx()+wb.getUlx())/2;
        this.ym=(wb.getUly()+wb.getLry())/2;
        // default of field of view is PI/4 in Java3D
        // disBaseHeight is depending from viewing frustum
        if (wb instanceof WorldVolume) {
            WorldVolume wv = (WorldVolume) wb;
            baseHeightdiff = wv.uz - wv.lz;
        }
        else baseHeightdiff = 0;

        float distBaseHeight;
        if (gis3dView == null) {
            distBaseHeight =
                (float) (baseHeightdiff/Math.atan(Math.PI/8.d));
        }
        else {
            distBaseHeight =
                (float) 
(baseHeightdiff*gis3dView.getHeightScale()/Math.atan(Math.PI/8.d));
        }

        // distXYRange is depending from viewing frustum
        float distXYRange =
                (float)((wb.getLrx()-wb.getUlx())/Math.atan(Math.PI/8.d));

        // get the greater of both, to see entire scene
        if (distBaseHeight > distXYRange)
            this.dist = distBaseHeight;
        else {
            this.dist = distXYRange;
        }
    }


I am calculating my font and back clipping distances out of dist:

double back=intposcurrent.getDist()+intposcurrent.getDist()/8.0d;
double front = (intposcurrent.getDist()-intposcurrent.getDist()/2.0)/7.0;

------------- back clipping plane

   ------
   |  . |      (0,0,0)                  -
   |    |                               |
   ------                                       |
------------- front clippping plane     |
                                        |
                                        |
                                         calculated distance
                                        |
                                        |
                                        |
                                        |
                                        |
                                        |
      .      viewing platform           -




In my case it happens to be that the ratio between the distances is a lot
smaller than 3000. But I am thinking of adding a check for the ratio.
Additionally it would be possible to calculate the smallest and greatest z
out of the bounding box, instead of just adding a part of the calculated
distance (the values above are just try and error values which are fitting
my needs).

Another problem I had, was zooming into the scene without the objects
being clipped. So I am adjusting the front and back clipping planes, while
zooming on the fly. For this I extended MouseZoome and overloaded the
method transformChanged():

    /**
     * Adjust clipping planes
     *
     * @see Method getFrontClipDistance() in class GIS3dView
     */
    public void transformChanged(Transform3D transform) {
        Vector3d v3d = new Vector3d();
        transform.get(v3d);
        double dist = v3d.z;
        double newfront = (v3d.z-v3d.z/2.0)/7.0;
        if (newfront < 0) {
            newfront = -newfront;
        }
        double newback = newfront * 500;
        view.setFrontClipDistance(newfront);
        view.setBackClipDistance(newback);
    }

Here I am setting the back plane with a ratio of 500 after the front
plane.

Desiree

oooooooooooooooooooooooooooooooooooooooooooooooo
Desiree Hilbring

Institut fuer Photogrammetrie und Fernerkundung
Universitaet Karlsruhe, Germany
email: [EMAIL PROTECTED]
# 0721 6083676
oooooooooooooooooooooooooooooooooooooooooooooooo


On Wed, 23 May 2001, alvaro zabala wrote:

> Desiree, only a question.
> How do you get the nearest point to your ViewingPlatform?
>
> I'm in a terrain (QuadArray), of 10 x 10 Km., and I want to view the
> furthest side (at 10000 m from the init)
>
> I tried these lines (suggest of Renoir)
>
> double radius = 100.0;
> vista.setFrontClipDistance(radius*(2.0/5000.0));
>  vista.setBackClipDistance(radius*2.0);
>
> and the result is in the atachment-
>
>
>
> -----Mensaje original-----
> De: Desiree Hilbring <[EMAIL PROTECTED]>
> Para: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> Fecha: mi�rcoles 23 de mayo de 2001 18:02
> Asunto: Re: [JAVA3D] Test program (fwd) for Grafic card question
>
>
> >>
> >> If that doesn't work in your main application then we can try keeping the
> >forward/back clip ratio
> >> to a constant.  I see from your later mail you have used this solution.
> >Are you keeping the
> >> ratio to 3000 or a smaller number?
> >
> >I was using this all the time in my main application and was playing
> >around with a ratio between 500 and 3000. Desiree
> >
> >>
> >> cheers,
> >>
> >> Chris
> >>
> >>
> >> --
> >>                   ,--_|\
> >>                  /  Oz  \
> >> Chris Thorne    :)_.--._/
> >> [EMAIL PROTECTED]     v
> >>
> >>
> >
> >===========================================================================
> >To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> >of the message "signoff JAVA3D-INTEREST".  For general help, send email to
> >[EMAIL PROTECTED] and include in the body of the message "help".
>

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to