This may not be quite what you had in mind but what you are describing
sounds a lot like a visualization technique that I refer to as
"constant size" objects, where you want the object to be positioned in
world space but to always appear at a constant size. The following
excerpt is from a VRML proto that does this. It is written mostly in
javascript. I haven't had a chance to port it to Java 3D yet but will
be doing so in the near future for a book I'm writting on 3D user
interfaces. You might be able to get what you want from it.
"Shape" is the target object that is being maintained at constant
size. updateShapeScale() computes the desired scale factor of the
target object given the viewing parameters.
--jon
# ConstantSizeFilter - Constant Size Filter
#
# Given the world position of the target shape <shapePosition>, the
apparent
# size of the shape expressed as a fraction of the display size
<constantSize>,
# and the world position <eyePosition>, rotation <eyeRotation> and
# field-of-view <eyeFieldOfView> of the eye, the filter outputs a
shape scale
# factor <oShapeScale> that will maintain a constant-size appearance
for the
# target shape regardless of distance, orientation, field-of-view, or
display
# position.
#
# shapePosition The world position of the target shape after being
# subjected to all transforms.
# constantSize The apparent size of a unit size target shape
expressed as
# a fraction of the display size, which is maintained
# independent of distance and field of view. If less than
# or equal to zero, constant size is disabled.
# eyePosition The world position of the eye (i.e. Viewpoint).
# eyeRotation The world rotation of the eye (i.e. Viewpoint).
# eyeFieldOfView The field of view of the eye (i.e. Viewpoint)
expressed as
# an angle in radians.
# oShapeScale The scale factor required to maintain the target shape
at
# a constant size.
...
url "vrmlscript:
function iShapePosition(value) {
//print( 'ConstantSizeFilter: ShapePosition=' + _ShapePosition );
_ShapePosition = value;
updateShapeScale();
}
function iEyePosition(value) {
//print( 'ConstantSizeFilter: EyePosition=' + _EyePosition );
_EyePosition = value;
updateShapeScale();
}
function iEyeRotation(value) {
//print( 'ConstantSizeFilter: EyeRotation=' + _EyeRotation );
_EyeRotation = value;
updateShapeScale();
}
function iConstantSize(value) {
//print( 'ConstantSizeFilter: ConstantSize=' + _ConstantSize );
_ConstantSize = value;
updateShapeScale();
}
function iEyeFieldOfView(value) {
//print( 'ConstantSizeFilter: EyeFieldOfView=' + _EyeFieldOfView );
_EyeFieldOfView = value;
updateFovTan();
updateShapeScale();
}
function initialize() {
_ShapePosition = dummy.shapePosition;
_EyePosition = dummy.eyePosition;
_EyeRotation = dummy.eyeRotation;
_EyeFieldOfView = dummy.eyeFieldOfView;
_ConstantSize = dummy.constantSize;
updateFovTan();
updateShapeScale();
}
function updateFovTan() {
// this accounts for the scaling formula FOV
half-angle and
// the display size half-height
_FovTan = 2.0 * Math.tan(_EyeFieldOfView/2.0);
}
function updateShapeScale() {
// translate eye rotation into normalized eye
direction vector
_EyeDir.x = 0;
_EyeDir.y = 0;
_EyeDir.z = -1;
_EyeDir = _EyeRotation.multVec(_EyeDir);
// compute shape vector from eye position to shape
_ShapeVec.x = _ShapePosition.x - _EyePosition.x;
_ShapeVec.y = _ShapePosition.y - _EyePosition.y;
_ShapeVec.z = _ShapePosition.z - _EyePosition.z;
// compute dist from eye plane to shape as the dot
product
dist = _EyeDir.x*_ShapeVec.x + _EyeDir.y*_ShapeVec.y +
_EyeDir.z*_ShapeVec.z;
// compute scale factor from distance and FOV
if(_ConstantSize <= 0.0 || dist <= 0.0)
scale = 1.0;
else
scale = _ConstantSize * dist * _FovTan;
//print( 'ConstantSizeFilter: scale=' + scale + ' dist=' + dist );
_ShapeScale.x = scale;
_ShapeScale.y = scale;
_ShapeScale.z = scale;
oShapeScale = _ShapeScale;
}
"
} # SCRIPT
> Date: Wed, 28 Jul 1999 21:02:24 -0700
> From: Eric Hawthorne <[EMAIL PROTECTED]>
> Subject: Math problem
>
> I'm trying to dynamically adjust the bounds of a scene graph object so that the
> "apparent" size
> (i.e. percentage of the field-of-view i.e. span of the object in pixels)
> remains the same
> no matter what the VWorld "z" distance from the object to the eyepoint is.
>
> That is, I'm trying to "undo" the shrinkage due to perspective.
>
> Reason why is I'm trying to make a Raster Shape3D pickable.
> Now don't worry, I've got the performance aspect of this covered.
>
> I need help figuring out the amount by which I should shrink or expand the
> bounding box
> of the object as the view moves toward or away from the object.
> (I'm going to use a Billboard to make sure the boundingbox stays with a face
> facing the view.)
>
> So far, I know how to get the eyepoint position in VWorld coords, so I can
> calculate the VWorld distance from the object to the eyepoint.
> I think I also know how to calculate what the size of the bounds should be
> (in VWorld coords) if the "z" position of the object were right up forward at
> the image plate "z".
>
> Can anyone help with what function of the VWorld distance I should use
> in expanding the bounds of the object as the object recedes further into the
> scene.
> Part of what I don't understand is how the viewing projection works and what
> the
> effect of that projection on my expansion function should be.
>
> Eric
>
____________________ Peculiar Technologies ____________________
Jon Barrilleaux 3800 Lake Shore Ave. Purveyors of
[EMAIL PROTECTED] Oakland, CA 94610 Alternate Reality
510.444.4370 voc Augmented Simulation
510.444.0231 fax www.augsim.com and 3D Solutions
===========================================================================
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".