Search in sources :

Example 11 with Renderer

use of maspack.render.Renderer in project artisynth_core by artisynth.

the class ConstrainedTranslator3d method updateLocation.

private void updateLocation(MouseRayEvent e) {
    if (mesh == null) {
        return;
    }
    Line ray = e.getRay();
    Point3d origin = ray.getOrigin();
    Vector3d direction = ray.getDirection();
    // face = obbt.intersect (origin, direction, duv, intersector);
    face = query.nearestFaceAlongRay(null, duv, mesh, origin, direction);
    if (face != null) {
        myXDraggerToWorld.p.scaledAdd(duv.x, direction, origin);
    } else {
        Renderer renderer = e.getViewer();
        Point3d location = new Point3d(myXDraggerToWorld.p);
        RigidTransform3d EyeToWorld = renderer.getViewMatrix();
        EyeToWorld.invert();
        EyeToWorld.R.getColumn(2, planeNormal);
        plane.set(planeNormal, location);
        plane.intersectRay(planeLocation, direction, origin);
        face = query.nearestFaceToPoint(location, coords, mesh, planeLocation);
        duv.x = myXDraggerToWorld.p.distance(EyeToWorld.p);
        duv.y = coords.x;
        duv.z = coords.y;
        myXDraggerToWorld.p.set(location);
    }
    myIncrementalTransform.p.set(transform.p);
    transform.p.sub(myXDraggerToWorld.p, firstLocation);
    myIncrementalTransform.p.sub(transform.p, myIncrementalTransform.p);
}
Also used : Line(maspack.matrix.Line) RigidTransform3d(maspack.matrix.RigidTransform3d) Vector3d(maspack.matrix.Vector3d) Point3d(maspack.matrix.Point3d) Renderer(maspack.render.Renderer)

Aggregations

Renderer (maspack.render.Renderer)11 Vector3d (maspack.matrix.Vector3d)8 RenderList (maspack.render.RenderList)7 SimpleSelectable (maspack.test.GL.MultiViewer.SimpleSelectable)6 LinkedList (java.util.LinkedList)4 RenderProps (maspack.render.RenderProps)4 Point3d (maspack.matrix.Point3d)3 RigidTransform3d (maspack.matrix.RigidTransform3d)3 Rectangle2D (java.awt.geom.Rectangle2D)2 JFrame (javax.swing.JFrame)2 PolygonalMesh (maspack.geometry.PolygonalMesh)2 BumpMapProps (maspack.render.BumpMapProps)2 ColorMapProps (maspack.render.ColorMapProps)2 IsRenderable (maspack.render.IsRenderable)2 NormalMapProps (maspack.render.NormalMapProps)2 RenderObject (maspack.render.RenderObject)2 Shading (maspack.render.Renderer.Shading)2 GL3 (com.jogamp.opengl.GL3)1 Color (java.awt.Color)1 Font (java.awt.Font)1