Search in sources :

Example 6 with Matrix3d

use of maspack.matrix.Matrix3d in project artisynth_core by artisynth.

the class StlRenderer method restoreDefaultState.

@Override
public void restoreDefaultState(boolean strictChecking) {
    if (myMappingsSet) {
        if (myColorMapProps != null) {
            setColorMap(null);
        }
        if (myNormalMapProps != null) {
            setNormalMap(null);
        }
        if (myBumpMapProps != null) {
            setBumpMap(null);
        }
        myMappingsSet = false;
    }
    if (myNonDefaultColorSettings != 0) {
        if (myBackColor != null) {
            setBackColor(null);
        }
        if ((myNonDefaultColorSettings & EMISSION_BIT) != 0) {
            setEmission(DEFAULT_MATERIAL_EMISSION);
        }
        if ((myNonDefaultColorSettings & SPECULAR_BIT) != 0) {
            setSpecular(DEFAULT_MATERIAL_SPECULAR);
        }
        if ((myNonDefaultColorSettings & SHININESS_BIT) != 0) {
            setShininess(DEFAULT_MATERIAL_SHININESS);
        }
        if (getColorInterpolation() != DEFAULT_COLOR_INTERPOLATION) {
            setColorInterpolation(DEFAULT_COLOR_INTERPOLATION);
        }
        if (myActiveColor == ActiveColor.HIGHLIGHT) {
            setHighlighting(false);
        }
        myNonDefaultColorSettings = 0;
    }
    if (myNonDefaultGeneralSettings != 0) {
        if (myViewerState.faceMode != DEFAULT_FACE_STYLE) {
            setFaceStyle(DEFAULT_FACE_STYLE);
        }
        if ((myNonDefaultGeneralSettings & LINE_WIDTH_BIT) != 0) {
            setLineWidth(DEFAULT_LINE_WIDTH);
        }
        if ((myNonDefaultGeneralSettings & POINT_SIZE_BIT) != 0) {
            setPointSize(DEFAULT_POINT_SIZE);
        }
        if (myViewerState.shading != DEFAULT_SHADING) {
            setShading(DEFAULT_SHADING);
        }
        // }
        if (myViewerState.colorMixing != DEFAULT_COLOR_MIXING) {
            setVertexColorMixing(DEFAULT_COLOR_MIXING);
        }
        if (getDepthOffset() != DEFAULT_DEPTH_OFFSET) {
            setDepthOffset(DEFAULT_DEPTH_OFFSET);
        }
        myNonDefaultGeneralSettings = 0;
    }
    if (myModelMatrixSet) {
        int mmsize = modelMatrixStack.size();
        if (mmsize > 0) {
            if (strictChecking) {
                throw new IllegalStateException("render() method exited with model matrix stack size of " + mmsize);
            } else {
                while (mmsize > 0) {
                    modelMatrixStack.pop();
                    mmsize--;
                }
            }
        } else {
            synchronized (modelMatrix) {
                if (!modelMatrix.isIdentity()) {
                    // reset to identity
                    modelMatrix = new RigidTransform3d();
                    modelNormalMatrix = new Matrix3d();
                }
            }
        }
        myModelMatrixSet = false;
    }
    if (myDrawMode != null) {
        if (strictChecking) {
            throw new IllegalStateException("render() method exited while still in draw mode: " + myDrawMode);
        } else {
            resetDraw();
        }
    }
    // set front alpha if not one
    if (myCurrentMaterial.isTransparent()) {
        setFrontAlpha(1.0f);
    }
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) RotationMatrix3d(maspack.matrix.RotationMatrix3d) Matrix3d(maspack.matrix.Matrix3d)

Example 7 with Matrix3d

use of maspack.matrix.Matrix3d in project artisynth_core by artisynth.

the class CGSolverTest method createConstraintProblem.

public SparseMatrixNd createConstraintProblem(int nbodies) {
    SparseMatrixNd M = new SparseMatrixNd(5 * nbodies, 5 * nbodies);
    Matrix3d mass = new Matrix3d();
    for (int k = 0; k < nbodies; k++) {
        mass.setRandom(-0.5, 0.5, randGen);
        mass.mulTranspose(mass);
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                M.set(3 * k + i, 3 * k + j, mass.get(i, j));
            }
        }
    }
    int[] connectionCount = new int[nbodies * nbodies];
    Vector3d n = new Vector3d();
    for (int k = 0; k < 2 * nbodies; k++) {
        // find a random connection between two bodies
        int bod1, bod2;
        do {
            bod1 = randGen.nextInt(nbodies);
            bod2 = randGen.nextInt(nbodies);
            if (bod1 < bod2) {
                int l = bod1;
                bod1 = bod2;
                bod2 = l;
            }
        } while (bod1 == bod2 || connectionCount[bod1 * nbodies + bod2] >= 2);
        connectionCount[bod1 * nbodies + bod2]++;
        n.setRandom(-0.5, 0.5, randGen);
        for (int i = 0; i < 3; i++) {
            M.set(bod1 * 3 + i, 3 * nbodies + k, n.get(i));
            M.set(bod2 * 3 + i, 3 * nbodies + k, -n.get(i));
            M.set(3 * nbodies + k, bod1 * 3 + i, n.get(i));
            M.set(3 * nbodies + k, bod2 * 3 + i, -n.get(i));
        }
    }
    return M;
}
Also used : Matrix3d(maspack.matrix.Matrix3d) Vector3d(maspack.matrix.Vector3d) SparseMatrixNd(maspack.matrix.SparseMatrixNd)

Example 8 with Matrix3d

use of maspack.matrix.Matrix3d in project artisynth_core by artisynth.

the class CRSolverTest method createConstraintProblem.

public SparseMatrixNd createConstraintProblem(int nbodies) {
    SparseMatrixNd M = new SparseMatrixNd(5 * nbodies, 5 * nbodies);
    Matrix3d mass = new Matrix3d();
    for (int k = 0; k < nbodies; k++) {
        mass.setRandom(-0.5, 0.5, randGen);
        mass.mulTranspose(mass);
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                M.set(3 * k + i, 3 * k + j, mass.get(i, j));
            }
        }
    }
    int[] connectionCount = new int[nbodies * nbodies];
    Vector3d n = new Vector3d();
    for (int k = 0; k < 2 * nbodies; k++) {
        // find a random connection between two bodies
        int bod1, bod2;
        do {
            bod1 = randGen.nextInt(nbodies);
            bod2 = randGen.nextInt(nbodies);
            if (bod1 < bod2) {
                int l = bod1;
                bod1 = bod2;
                bod2 = l;
            }
        } while (bod1 == bod2 || connectionCount[bod1 * nbodies + bod2] >= 2);
        connectionCount[bod1 * nbodies + bod2]++;
        n.setRandom(-0.5, 0.5, randGen);
        for (int i = 0; i < 3; i++) {
            M.set(bod1 * 3 + i, 3 * nbodies + k, n.get(i));
            M.set(bod2 * 3 + i, 3 * nbodies + k, -n.get(i));
            M.set(3 * nbodies + k, bod1 * 3 + i, n.get(i));
            M.set(3 * nbodies + k, bod2 * 3 + i, -n.get(i));
        }
    }
    return M;
}
Also used : Matrix3d(maspack.matrix.Matrix3d) Vector3d(maspack.matrix.Vector3d) SparseMatrixNd(maspack.matrix.SparseMatrixNd)

Example 9 with Matrix3d

use of maspack.matrix.Matrix3d in project artisynth_core by artisynth.

the class FemMuscleModel method render.

// public void setDrawFibers(boolean enable) {
// myDrawFibers = enable;
// }
public void render(Renderer renderer, int flags) {
    super.render(renderer, flags);
    // if (myFiberMesh != null) {
    // myFiberMesh.render(renderer, myRenderProps, /* flags= */0);
    // }
    // if (myDrawFibers) {
    RenderProps fiberRenderProps = myFiberRenderProps;
    if (fiberRenderProps == null) {
        fiberRenderProps = DEFAULT_FIBER_RENDER_PROPS;
    }
    double dirLen = getDirectionRenderLen();
    if (dirLen > 0) {
        Matrix3d F = new Matrix3d();
        Vector3d dir = new Vector3d();
        float[] coords0 = new float[3];
        float[] coords1 = new float[3];
        for (FemElement3d e : getElements()) {
            renderDirection(renderer, fiberRenderProps, e, coords0, coords1, F, dir, dirLen);
        }
    }
}
Also used : Matrix3d(maspack.matrix.Matrix3d) SymmetricMatrix3d(maspack.matrix.SymmetricMatrix3d) Vector3d(maspack.matrix.Vector3d) RenderProps(maspack.render.RenderProps)

Example 10 with Matrix3d

use of maspack.matrix.Matrix3d in project artisynth_core by artisynth.

the class FemMuscleModel method renderIPointDirection.

protected void renderIPointDirection(Renderer renderer, RenderProps props, FemElement3d elem, float[] coords0, float[] coords1, Matrix3d F, Vector3d dir, double len) {
    IntegrationPoint3d[] ipnt = elem.getIntegrationPoints();
    IntegrationData3d[] idata = elem.getIntegrationData();
    for (int i = 0; i < ipnt.length; i++) {
        Matrix3d Frame = idata[i].myFrame;
        if (Frame != null) {
            dir.x = Frame.m00;
            dir.y = Frame.m10;
            dir.z = Frame.m20;
            ipnt[i].computeGradientForRender(F, elem.getNodes(), idata[i].myInvJ0);
            ipnt[i].computeCoordsForRender(coords0, elem.getNodes());
            F.mul(dir, dir);
            double size = elem.computeDirectedRenderSize(dir);
            dir.scale(0.5 * size);
            dir.scale(len);
            coords0[0] -= (float) dir.x / 2;
            coords0[1] -= (float) dir.y / 2;
            coords0[2] -= (float) dir.z / 2;
            coords1[0] = coords0[0] + (float) dir.x;
            coords1[1] = coords0[1] + (float) dir.y;
            coords1[2] = coords0[2] + (float) dir.z;
            props.getLineColor(myDirectionColor);
            renderer.drawLine(props, coords0, coords1, myDirectionColor, /*capped=*/
            false, /*highlight=*/
            false);
        }
    }
}
Also used : Matrix3d(maspack.matrix.Matrix3d) SymmetricMatrix3d(maspack.matrix.SymmetricMatrix3d)

Aggregations

Matrix3d (maspack.matrix.Matrix3d)64 SymmetricMatrix3d (maspack.matrix.SymmetricMatrix3d)42 Vector3d (maspack.matrix.Vector3d)32 RotationMatrix3d (maspack.matrix.RotationMatrix3d)22 Matrix6d (maspack.matrix.Matrix6d)15 Point3d (maspack.matrix.Point3d)9 RigidTransform3d (maspack.matrix.RigidTransform3d)7 SVDecomposition3d (maspack.matrix.SVDecomposition3d)7 IntegrationData3d (artisynth.core.femmodels.IntegrationData3d)6 AffineTransform3d (maspack.matrix.AffineTransform3d)4 VectorNd (maspack.matrix.VectorNd)4 IntegrationPoint3d (artisynth.core.femmodels.IntegrationPoint3d)3 SolidDeformation (artisynth.core.materials.SolidDeformation)3 FemMaterial (artisynth.core.materials.FemMaterial)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 BVNode (maspack.geometry.BVNode)2 BVTree (maspack.geometry.BVTree)2 Boundable (maspack.geometry.Boundable)2 LineSegment (maspack.geometry.LineSegment)2