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);
}
}
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;
}
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;
}
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);
}
}
}
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);
}
}
}
Aggregations