Finish Displacement and animation of it.
This commit is contained in:
parent
61e289036e
commit
09fe84abbf
|
@ -213,6 +213,7 @@ ViewProviderFemMesh::ViewProviderFemMesh()
|
|||
pcPointMaterial->ref();
|
||||
//PointMaterial.touch();
|
||||
|
||||
DisplacementFactor = 0;
|
||||
}
|
||||
|
||||
ViewProviderFemMesh::~ViewProviderFemMesh()
|
||||
|
@ -548,8 +549,28 @@ void ViewProviderFemMesh::resetDisplacementByNodeId(void)
|
|||
/// reaply the node displacement with a certain factor and do a redraw
|
||||
void ViewProviderFemMesh::animateNodes(double factor)
|
||||
{
|
||||
float x,y,z;
|
||||
// set the point coordinates
|
||||
long sz = pcCoords->point.getNum();
|
||||
SbVec3f* verts = pcCoords->point.startEditing();
|
||||
for (long i=0;i < sz ;i++) {
|
||||
verts[i].getValue(x,y,z);
|
||||
// undo old factor#
|
||||
Base::Vector3d oldDisp = DisplacementVector[i] * DisplacementFactor;
|
||||
x -= oldDisp.x;
|
||||
y -= oldDisp.y;
|
||||
z -= oldDisp.z;
|
||||
// apply new factor
|
||||
Base::Vector3d newDisp = DisplacementVector[i] * factor;
|
||||
x += newDisp.x;
|
||||
y += newDisp.y;
|
||||
z += newDisp.z;
|
||||
// set the new value
|
||||
verts[i].setValue(x,y,z);
|
||||
}
|
||||
pcCoords->point.finishEditing();
|
||||
|
||||
|
||||
DisplacementFactor = factor;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,10 +20,15 @@ std::string ViewProviderFemMeshPy::representation(void) const
|
|||
|
||||
|
||||
|
||||
PyObject* ViewProviderFemMeshPy::animate(PyObject * /*args*/)
|
||||
PyObject* ViewProviderFemMeshPy::animate(PyObject * args)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
|
||||
return 0;
|
||||
double factor;
|
||||
if (!PyArg_ParseTuple(args, "d", &factor))
|
||||
return 0;
|
||||
|
||||
this->getViewProviderFemMeshPtr()->animateNodes(factor);
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user