Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 public abstract int Intersect( Vector3 rayPosition, Vector3 rayDirection, ref Object3DCommon obj, Matrix worldSpace );
Ejemplo n.º 7
0
 public abstract int Intersect(Vector3 rayPosition, Vector3 rayDirection, ref Object3DCommon obj, Matrix worldSpace);
Ejemplo n.º 8
0
        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;
        }
Ejemplo n.º 9
0
        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;
        }