public override int Intersect(Vector3 rayPosition, Vector3 rayDirection, ref Object3DCommon obj, Matrix worldSpace) { Matrix myModelSpace = scalingMatrix * rotationMatrix * translationMatrix * worldSpace; // transform world space to object space Vector3 pickRayOriginTemp = new Vector3(rayPosition.X, rayPosition.Y, rayPosition.Z); Vector3 pickRayDirectionTemp = new Vector3(rayDirection.X, rayDirection.Y, rayDirection.Z); // convert ray from 3d space to model space pickRayOriginTemp.TransformCoordinate(Matrix.Invert(myModelSpace)); pickRayDirectionTemp.TransformNormal(Matrix.Invert(myModelSpace)); // check to see if I intersect int zDistance = CheckIntersect(pickRayOriginTemp, pickRayDirectionTemp); if (zDistance > 0) { obj = this; } if (_children != null) { foreach (Object3DCommon childObj in _children) { int newZDistance = childObj.Intersect(rayPosition, rayDirection, ref obj, myModelSpace); if (newZDistance > zDistance) { zDistance = newZDistance; } } } return(zDistance); }
public IObject3D Intersect(Vector3 rayPosition, Vector3 rayDirection, Matrix worldSpace) { Object3DCommon obj = null; int result = Intersect(rayPosition, rayDirection, ref obj, worldSpace); if (result < 0) { return(null); } else { return(obj); } }
public override int Intersect(Vector3 rayPosition, Vector3 rayDirection, ref Object3DCommon obj, Matrix worldSpace) { int zDistance = -1; //Matrix myModelSpace = worldSpace * manipulateMatrix; Matrix myModelSpace = Matrix.Multiply(scalingMatrix * rotationMatrix * translationMatrix, worldSpace); if (_children != null) { foreach (Object3DCommon childObj in _children) { int newZDistance = childObj.Intersect(rayPosition, rayDirection, ref obj, myModelSpace); if (newZDistance > zDistance) { zDistance = newZDistance; } } } return(zDistance); }
public override int Intersect( Vector3 rayPosition, Vector3 rayDirection, ref Object3DCommon obj, Matrix worldSpace ) { int zDistance = -1; //Matrix myModelSpace = worldSpace * manipulateMatrix; Matrix myModelSpace = Matrix.Multiply(scalingMatrix * rotationMatrix * translationMatrix, worldSpace); if (_children != null) { foreach (Object3DCommon childObj in _children) { int newZDistance = childObj.Intersect(rayPosition, rayDirection, ref obj, myModelSpace); if (newZDistance > zDistance) { zDistance = newZDistance; } } } return zDistance; }
public override int Intersect(Vector3 rayPosition, Vector3 rayDirection, ref Object3DCommon obj, Matrix worldSpace) { Matrix myModelSpace = scalingMatrix * rotationMatrix * translationMatrix * worldSpace; // TODO: Ryan wants to add real curve intersection here // for now, we do a fake init on z-distance: int zDistance = 0; if (_children != null) { foreach (Object3DCommon childObj in _children) { int newZDistance = childObj.Intersect(rayPosition, rayDirection, ref obj, myModelSpace); if (newZDistance > zDistance) { zDistance = newZDistance; } } } return(zDistance); }
public abstract int Intersect( Vector3 rayPosition, Vector3 rayDirection, ref Object3DCommon obj, Matrix worldSpace );
public abstract int Intersect(Vector3 rayPosition, Vector3 rayDirection, ref Object3DCommon obj, Matrix worldSpace);
public override int Intersect( Vector3 rayPosition, Vector3 rayDirection, ref Object3DCommon obj, Matrix worldSpace ) { Matrix myModelSpace = scalingMatrix * rotationMatrix * translationMatrix * worldSpace; // transform world space to object space Vector3 pickRayOriginTemp = new Vector3(rayPosition.X, rayPosition.Y, rayPosition.Z); Vector3 pickRayDirectionTemp = new Vector3(rayDirection.X,rayDirection.Y,rayDirection.Z); // convert ray from 3d space to model space pickRayOriginTemp.TransformCoordinate(Matrix.Invert(myModelSpace)); pickRayDirectionTemp.TransformNormal (Matrix.Invert(myModelSpace)); // check to see if I intersect int zDistance = CheckIntersect(pickRayOriginTemp,pickRayDirectionTemp); if (zDistance > 0) { obj = this; } if (_children != null) { foreach (Object3DCommon childObj in _children) { int newZDistance = childObj.Intersect(rayPosition, rayDirection, ref obj, myModelSpace); if (newZDistance > zDistance) { zDistance = newZDistance; } } } return zDistance; }
public override int Intersect( Vector3 rayPosition, Vector3 rayDirection, ref Object3DCommon obj, Matrix worldSpace ) { Matrix myModelSpace = scalingMatrix * rotationMatrix * translationMatrix * worldSpace; // TODO: Ryan wants to add real curve intersection here // for now, we do a fake init on z-distance: int zDistance = 0; if (_children != null) { foreach (Object3DCommon childObj in _children) { int newZDistance = childObj.Intersect(rayPosition, rayDirection, ref obj, myModelSpace); if (newZDistance > zDistance) { zDistance = newZDistance; } } } return zDistance; }