Ejemplo n.º 1
0
        void update_source()
        {
            TransformableSO from   = Source as TransformableSO;
            Frame3f         FrameS = from.GetLocalFrame(CoordSpace.SceneCoords);
            TransformableSO to     = Target as TransformableSO;

            relativeF = SceneTransforms.SceneToObject(to, FrameS);
        }
Ejemplo n.º 2
0
        public void UpdateBrushPreview(Frame3f vFrameW, int nHitTID)
        {
            Frame3f vFrameS = scene.ToSceneFrame(vFrameW);
            Frame3f vFrameL = SceneTransforms.SceneToObject(Target, vFrameS);

            update_preview(vFrameL, nHitTID);

            lastBrushPosW = vFrameW;
        }
Ejemplo n.º 3
0
 public override OpStatus Revert()
 {
     if (space == CoordSpace.SceneCoords)
     {
         Frame3f localF = SceneTransforms.SceneToObject(Target, initialFrame);
         Frame3f setF   = Target.GetLocalFrame(CoordSpace.ObjectCoords).FromFrame(localF);
         Target.RepositionPivot(setF);
     }
     else
     {
         Target.RepositionPivot(initialFrame);
     }
     return(OpStatus.Success);
 }
Ejemplo n.º 4
0
        public void UpdateBrushStroke(Frame3f vFrameW, int nHitTID)
        {
            if (in_stroke == false)
            {
                throw new Exception("SurfaceBrushTool.UpdateBrushStroke: not in brush stroke!");
            }

            Frame3f vFrameS = scene.ToSceneFrame(vFrameW);
            Frame3f vFrameL = SceneTransforms.SceneToObject(Target, vFrameS);

            update_stroke(vFrameL, nHitTID);

            lastBrushPosW = vFrameW;
        }
Ejemplo n.º 5
0
        public override void AppendVertex(Vector3d v)
        {
            base.AppendVertex(v);

            // map v to local coords
            LocalVertexRef r = new LocalVertexRef();

            r.localPos = SceneTransforms.SceneToObject(Target, v);
            SurfacePoints.Add(r);
            if (Curve.VertexCount != SurfacePoints.Count)
            {
                throw new Exception("SurfaceCurvePreview: counts are out of sync!!");
            }
        }
Ejemplo n.º 6
0
        public void BeginBrushStroke(Frame3f vFrameW, int nHitTID)
        {
            if (in_stroke)
            {
                throw new Exception("SurfaceBrushTool.BeginBrushStroke: already in brush stroke!");
            }

            Frame3f vFrameS = scene.ToSceneFrame(vFrameW);
            Frame3f vFrameL = SceneTransforms.SceneToObject(Target, vFrameS);

            begin_stroke(vFrameL, nHitTID);

            in_stroke     = true;
            lastBrushPosW = vFrameW;
        }
Ejemplo n.º 7
0
        virtual public AxisAlignedBox3f GetLocalBoundingBox()
        {
            if (vChildren.Count == 0)
            {
                return(new AxisAlignedBox3f(Vector3f.Zero, 0.5f));
            }
            Box3d combine = vChildren[0].GetBoundingBox(CoordSpace.SceneCoords);

            for (int k = 1; k < vChildren.Count; ++k)
            {
                Box3d childbox = vChildren[k].GetBoundingBox(CoordSpace.SceneCoords);
                combine = Box3d.Merge(ref combine, ref childbox);
            }
            Box3f boxLocal = SceneTransforms.SceneToObject(this, (Box3f)combine);

            return(boxLocal.ToAABB());
        }
Ejemplo n.º 8
0
        override public bool FindRayIntersection(Ray3f worldRay, out SORayHit hit)
        {
            hit = null;

            // project world ray into local coords
            FScene scene    = GetScene();
            Ray3f  sceneRay = scene.ToSceneRay(worldRay);
            Ray3f  localRay = SceneTransforms.SceneToObject(this, sceneRay);

            // also need width in local coords
            float sceneWidth = scene.ToSceneDimension(visibleWidth);
            float localWidth = SceneTransforms.SceneToObject(this, sceneWidth) * HitWidthMultiplier;

            // bounding-box hit test (would be nice to do w/o object allocation...)
            AxisAlignedBox3d hitBox = localBounds;

            hitBox.Expand(localWidth);
            IntrRay3AxisAlignedBox3 box_test = new IntrRay3AxisAlignedBox3(localRay, hitBox);

            if (box_test.Find() == false)
            {
                return(false);
            }

            // raycast against curve (todo: spatial data structure for this? like 2D polycurve bbox tree?)
            double rayHitT;

            if (CurveUtils.FindClosestRayIntersection(curve, localWidth, localRay, out rayHitT))
            {
                hit = new SORayHit();
                // transform local hit point back into world coords
                Vector3f rayPos   = localRay.PointAt((float)rayHitT);
                Vector3f scenePos = SceneTransforms.ObjectToSceneP(this, rayPos);
                hit.hitPos    = SceneTransforms.SceneToWorldP(scene, scenePos);
                hit.fHitDist  = worldRay.Project(hit.hitPos);
                hit.hitNormal = Vector3f.Zero;
                hit.hitGO     = root;
                hit.hitSO     = this;
                return(true);
            }
            return(false);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Find intersection of *WORLD* ray with Mesh
        /// </summary>
        override public bool FindRayIntersection(Ray3f rayW, out SORayHit hit)
        {
            hit = null;
            if (enable_spatial == false)
            {
                return(false);
            }

            validate_spatial();

            // convert ray to local
            FScene scene     = this.GetScene();
            Ray3f  rayS      = scene.ToSceneRay(rayW);
            Ray3d  local_ray = SceneTransforms.SceneToObject(this, rayS);

            int hit_tid = spatial.FindNearestHitTriangle(local_ray);

            if (hit_tid != DMesh3.InvalidID)
            {
                IntrRay3Triangle3 intr = MeshQueries.TriangleIntersection(mesh, hit_tid, local_ray);

                Vector3f hitPos = (Vector3f)local_ray.PointAt(intr.RayParameter);
                hitPos = SceneTransforms.ObjectToSceneP(this, hitPos);
                hitPos = scene.ToWorldP(hitPos);

                Vector3f hitNormal = (Vector3f)mesh.GetTriNormal(hit_tid);
                hitNormal = SceneTransforms.ObjectToSceneN(this, hitNormal);
                hitNormal = scene.ToWorldN(hitNormal);

                hit           = new SORayHit();
                hit.hitPos    = hitPos;
                hit.hitNormal = hitNormal;
                hit.hitIndex  = hit_tid;
                hit.fHitDist  = hit.hitPos.Distance(rayW.Origin);   // simpler than transforming!
                hit.hitGO     = RootGameObject;
                hit.hitSO     = this;
                return(true);
            }
            return(false);
        }
Ejemplo n.º 10
0
        void update_source()
        {
            Frame3f FrameS = Source.GetLocalFrame(CoordSpace.SceneCoords);

            relativeF = SceneTransforms.SceneToObject(Target, FrameS);
        }