Justin:
A quite excellent tutorial! I think you have inspired me to pick a topic
and try something similar. Perhaps on transparency or particle systems or
some such thing.
Some quick comments:
1. End of chapter 2 (Collision Detection) does not have "next step" links
like are at the end of chapter 1.
2. I am unclear why you just don't ask java3d to pick the intersection for
you? In particular for terrain following, Java3d will even handle the
interpolation within the triangle to give the the exact point of
intersection. Maybe I am not understanding something, but the following
code works perfectly for walking on the ground, stairs, floors, etc.
Setup:
// build the picktools used to walk on surfaces
pickTool = new
PickTool(XithEngine.getEngine().getScene().getStructuresBG());
pickTool.setMode(PickTool.GEOMETRY_INTERSECT_INFO);
pickToolTerrain = new
PickTool(XithEngine.getEngine().getScene().getTerrainBG());
pickToolTerrain.setMode(PickTool.GEOMETRY_INTERSECT_INFO);
pickedT = new Transform3D();
Find ground:
/**
* Calculates the ground by sending a pickray straight down from the
current position
*/
void calcGround(Vector3d pos, float from) {
if (!pickGround) {
pos.y = XithEngine.map.getY((float)pos.x,(float)pos.z);
} else
try {
rayStart.x = pos.x;
rayStart.z = pos.z;
rayStart.y = pos.y+from;
// check to see if there is floor, stairs or other structure
beneath us
pickTool.setShapeRay( rayStart, rayVec );
PickResult floor = pickTool.pickClosest();
// if there is no structure, then check for the ground.
if (floor==null) {
pickToolTerrain.setShapeRay( rayStart, rayVec );
floor = pickToolTerrain.pickClosest();
}
// we have an intersection, so get the transformation matrix, get
the point
// and then transform it.
if (floor != null) {
floor.getObject().getLocalToVworld(pickedT);
Point3d point = floor.getIntersection(0).getPointCoordinates();
pickedT.transform(point);
pos.y = point.y;
} else
pos.y = XithEngine.map.getY((float)pos.x,(float)pos.z);
} catch (Exception e) {
// if (firstPickError) {
Log.log.println(LogType.EXCEPTION,"Exception Finding Ground : at
"+rayStart+" : "+e.getMessage());
firstPickError = false;
// }
pos.y = XithEngine.map.getY((float)pos.x,(float)pos.z);
}
}
-----Original Message-----
From: Justin Couch [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 16, 2001 9:13 AM
To: [EMAIL PROTECTED]
Subject: [JAVA3D] ANN: Collision Detection/Terrain tutorial
In response to popular demand, I've created a tutorial on how to
implement real collision avoidance and terrain following in Java 3D.
The new tutorial details the code to write a generalised collision
detection system for navigation. We also detail how to write a
generalised terrain
following navigation system too. This is designed to be a fairly
detailed
tutorial that is designed for an intermediate level programmer - we
assume that you know how to code in Java 3D and would like to really
build a useful application while avoiding piles of matrix and vector
equations. It also happens to document the system that the Xj3D codebase
uses - which is available from the j3d.org code repository.
The new tutorial can be found at
http://www.j3d.org/tutorials/collision/
--
Justin Couch http://www.vlc.com.au/~justin/
Freelance Java Consultant http://www.yumetech.com/
Author, Java 3D FAQ Maintainer http://www.j3d.org/
-------------------------------------------------------------------
"Humanism is dead. Animals think, feel; so do machines now.
Neither man nor woman is the measure of all things. Every organism
processes data according to its domain, its environment; you, with
all your brains, would be useless in a mouse's universe..."
- Greg Bear, Slant
-------------------------------------------------------------------
===========================================================================
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".