CAE Tutorial: Animating Contour Data

This step provides an example of how contour information can be animated.

 

 

Overview

Animation in a CAE or FEA application may involve depicting mesh deformation over time, and/or color contour data changing over time. For example, the image depicted above shows some screen-stills of a sample HSF that contains a live animiation of a CAE model. (Read the file <hoops>/datasets/hsf/anim/piston.hsf into the HoopsPartViewer and select the 'Animate->Play' button on the toolbar.)

This tutorial step focuses on animating the contour data applied to vertices of HOOPS/3dGS geometry's vertices, though the actual geometry vertices can be similar changed (using Edit_Shell_Points, or precalculating and stored the various shells that represent the deformed meshes.). The tutorial may be enhanced in the future to provide example of animating the actual geometry's points, or a new 'animation' tutorial may be added to show how to animate both color data and the geometry (mesh) itself.

 

Animating Color Contours

Animating the color contour data is quite straightforward. At its core, it simply involves modifying the colormap index values set on the vertices of the HOOPS geometry, instructing HOOPS to redraw, and then continuing the process in a loop (using the new set of colormap index values for each time step in the animation). In a real world scenario, you would most likely have precalculated each new set of colormap index values in your solving step, and then you'd interate through them to provide N frames of an animation.

Recall that sample colormap index values were already calculated in a previous tutorial step, via a call to HAnalysisView::MapData. Thus we'll just write a new function called HAnalysisView::AnimateVertexColors . Let's first setup local members for HAnalysisModel::m_DataCycles and HAnalysisModel::m_pShellVertexData:

void HAnalysisView::AnimateVertexColors()
{
int cycles = ((HAnalysisModel *)GetModel())->m_DataCycles;
HShellVertexData *pVertexData = ((HAnalysisModel *)GetModel())->m_pShellVertexData;
if ( !pVertexData )
{
AfxMessageBox( _T("Must map data to create artificial color index array first.") );
return;
}

Then we'll proceed with animating through the number of data cycles 3x, incrementing the pointer into HShellVertexData::m_pFIndexArray each time:

for ( int i=0; i<3; i++ )
for ( int t=0; t<cycles; t++ )
{
HC_MSet_Vertex_Colors_By_FIndex(pVertexData->m_ShellKey, "faces, edges, markers", 0,
pVertexData->m_VertexCount, (pVertexData->m_pFIndexArray)+t);
Update();
Sleep(100);
}
}

Animating in this sort of 'static' fashion using the Sleep function is unorthodocs since it's blocking approach, but it gets the point across for purpose of this tutorial. Instead, you'd probably setup a timer to provide asynchronous animation/user-interacting. The HOOPS/MVO Programming Guide covers how to setup timers and perform more complex animations.

 

Performance Issues

If you are going to ultimately animate the color vertex data in a dynamic fashion as demonstrated above, there is an important performance consideration. If you are using HOOPS' OpenGL driver, you should turn display lists OFF, since DLs only give a boost when per vertex vertex attributes (like colormap values) are not changing on every update). Display lists are on by default in HOOPS/MVO, can can be turned off by calling HBaseView::SetDisplayListMode. Additional performance information is covered in the HOOPS/3dAF Performance Guidelines document.