#include <TAPsModelDeformableCPU.hpp>


Definition at line 122 of file TAPsModelDeformableCPU.hpp.
| typedef SpringPropertiesForDefModel<T> ModelDeformableCPU< T >::SpringProp |
Since there can be 26 connections where a set of them must have equal spring constant and rest length.
Definition at line 907 of file TAPsModelDeformableCPU.hpp.
| enum ModelDeformableCPU::DrawType |
| AS_2D_TEXTURE | |
| AS_3D_TEXTURE | |
| POSITION_TEXTURE | |
| ALL_ELEMENTS | |
| ALL_ELEMENTS_WITH_CONNECTIVITIES | |
| DUMMY_DrawType |
Definition at line 172 of file TAPsModelDeformableCPU.hpp.
00172 { 00173 AS_2D_TEXTURE, 00174 AS_3D_TEXTURE, 00175 POSITION_TEXTURE, 00176 ALL_ELEMENTS, 00177 ALL_ELEMENTS_WITH_CONNECTIVITIES, 00178 DUMMY_DrawType 00179 };
| BEGIN_NAMESPACE_TAPs__OpenGL ModelDeformableCPU< T >::ModelDeformableCPU | ( | ) | [inline] |
ModelDeformableCPU class is a deformable model implemented typically on CPU.
Definition at line 22 of file TAPsModelDeformableCPU.cpp.
00023 : OpenGLModel<T>() 00024 { 00025 //--------------------------------------------------------------- 00026 // Since Microsoft gl.h is version 1.1, 00027 // So this fn calls glewInit() for latest OpenGL version 00028 // and initialize GLSL. 00029 //GFnInitGLSL(); 00030 Default(); 00031 //--------------------------------------------------------------- 00032 //--------------------------------------------------------------- 00033 #ifdef TAPs_DEBUG_MODE 00034 std::cout << "ModelDeformableCPU<" << typeid(T).name() << "> Constructor\n"; 00035 #endif 00036 }
| ModelDeformableCPU< T >::~ModelDeformableCPU | ( | ) | [inline, virtual] |
Definition at line 40 of file TAPsModelDeformableCPU.cpp.
00041 { 00042 Clear(); 00043 //--------------------------------------------------------------- 00044 #ifdef TAPs_DEBUG_MODE 00045 std::cout << "ModelDeformableCPU<" << typeid(T).name() << "> Destructor\n"; 00046 #endif 00047 }
| void ModelDeformableCPU< T >::ApplyAndResetTransform | ( | ) | [inline, virtual] |
First apply the transformation matrix (from TAPsTransformationSupport.hpp (has a)) to the model, then reset the transformation matrix. (Apply means permanently change the positions of the model's vertices, etc.)
Reimplemented from Model< T >.
Definition at line 578 of file TAPsModelDeformableCPU.cpp.
00579 { 00580 // for ( int i = 0; i < m_iNoVertices; ++i ) { 00581 // m_prXElement[i].SetPosition( 00582 // ( GetTransform().ReturnMatrixTransform() 00583 // * Vector4<T>( m_prXElement[i].GetPosition() ) 00584 // ).GetVector3() 00585 // ); 00586 // } 00587 //--------------------------------------------------------------- 00588 // Set Transformation to Identity Matrix 00589 GetTransform().MakeIdentity(); 00590 //--------------------------------------------------------------- 00591 // Recalculate Bounding Volume(s) 00592 CalBoundingAABB(); 00593 CalBoundingEllipsoid(); 00594 CalBoundingSphere(); 00595 }
| void ModelDeformableCPU< T >::CalAndSetNormals | ( | ) | [inline, virtual] |
Definition at line 564 of file TAPsModelDeformableCPU.cpp.
00565 { 00566 // CalAndSetFaceNormalsNotNormalized(); 00567 // DetermineFaceRings(); 00568 // CalAndSetElementNormals(); 00569 // NormalizeFaceNormals(); 00570 }
| void ModelDeformableCPU< T >::CalBoundingAABB | ( | ) | [inline, protected, virtual] |
Reimplemented from ColDetSupport< T >.
Definition at line 604 of file TAPsModelDeformableCPU.cpp.
00605 { 00606 /* 00607 m_paBoundingAABB[0][0] = m_paBoundingAABB[1][0] = m_prXElement[0][0]; 00608 m_paBoundingAABB[0][1] = m_paBoundingAABB[1][1] = m_prXElement[0][1]; 00609 m_paBoundingAABB[0][2] = m_paBoundingAABB[1][2] = m_prXElement[0][2]; 00610 for ( int i = 1; i < m_iNoVertices; ++i ) 00611 { 00612 // Find lowest x, y, and z 00613 if ( m_paBoundingAABB[0][0] > m_prXElement[i][0] ) 00614 m_paBoundingAABB[0][0] = m_prXElement[i][0]; 00615 if ( m_paBoundingAABB[0][1] > m_prXElement[i][1] ) 00616 m_paBoundingAABB[0][1] = m_prXElement[i][1]; 00617 if ( m_paBoundingAABB[0][2] > m_prXElement[i][2] ) 00618 m_paBoundingAABB[0][2] = m_prXElement[i][2]; 00619 // Find highest x, y, and z 00620 if ( m_paBoundingAABB[1][0] < m_prXElement[i][0] ) 00621 m_paBoundingAABB[1][0] = m_prXElement[i][0]; 00622 if ( m_paBoundingAABB[1][1] < m_prXElement[i][1] ) 00623 m_paBoundingAABB[1][1] = m_prXElement[i][1]; 00624 if ( m_paBoundingAABB[1][2] < m_prXElement[i][2] ) 00625 m_paBoundingAABB[1][2] = m_prXElement[i][2]; 00626 } 00627 // Find the bounding volume center 00628 m_pBoundingCenter[0] = ( m_paBoundingAABB[0][0] + m_paBoundingAABB[1][0] ) / 2.0; 00629 m_pBoundingCenter[1] = ( m_paBoundingAABB[0][1] + m_paBoundingAABB[1][1] ) / 2.0; 00630 m_pBoundingCenter[2] = ( m_paBoundingAABB[0][2] + m_paBoundingAABB[1][2] ) / 2.0; 00631 //*/ 00632 }
| void ModelDeformableCPU< T >::CalBoundingEllipsoid | ( | ) | [inline, protected, virtual] |
Reimplemented from ColDetSupport< T >.
Definition at line 635 of file TAPsModelDeformableCPU.cpp.
00636 { 00637 /* 00638 m_pBoundingCenter[0] = ( m_paBoundingAABB[0][0] + m_paBoundingAABB[1][0] ) / 2.0; 00639 m_pBoundingCenter[1] = ( m_paBoundingAABB[0][1] + m_paBoundingAABB[1][1] ) / 2.0; 00640 m_pBoundingCenter[2] = ( m_paBoundingAABB[0][2] + m_paBoundingAABB[1][2] ) / 2.0; 00641 m_pBoundingEllipsoid[0] = fabs( (m_paBoundingAABB[0][0] - m_paBoundingAABB[1][0])/2.0 ); 00642 m_pBoundingEllipsoid[1] = fabs( (m_paBoundingAABB[0][1] - m_paBoundingAABB[1][1])/2.0 ); 00643 m_pBoundingEllipsoid[2] = fabs( (m_paBoundingAABB[0][2] - m_paBoundingAABB[1][2])/2.0 ); 00644 //*/ 00645 00646 /* 00647 T xLength = m_paBoundingAABB[0][0] - m_paBoundingAABB[1][0]; 00648 T yLength = m_paBoundingAABB[0][1] - m_paBoundingAABB[1][1]; 00649 T zLength = m_paBoundingAABB[0][2] - m_paBoundingAABB[1][2]; 00650 xLength *= xLength; 00651 yLength *= yLength; 00652 zLength *= zLength; 00653 m_pBoundingEllipsoid[0] = sqrt( yLength + zLength ) / 2.0; 00654 m_pBoundingEllipsoid[1] = sqrt( zLength + xLength ) / 2.0; 00655 m_pBoundingEllipsoid[2] = sqrt( xLength + yLength ) / 2.0; 00656 //*/ 00657 00658 T x = m_paBoundingAABB[1][0] - m_pBoundingCenter[0]; 00659 x *= x; 00660 T y = m_paBoundingAABB[1][1] - m_pBoundingCenter[1]; 00661 y *= y; 00662 T z = m_paBoundingAABB[1][2] - m_pBoundingCenter[2]; 00663 z *= z; 00664 m_pBoundingEllipsoid[1] = sqrt( y + z ); 00665 m_pBoundingEllipsoid[2] = sqrt( z + x ); 00666 m_pBoundingEllipsoid[0] = sqrt( x + y ); 00667 }
| void ModelDeformableCPU< T >::CalBoundingSphere | ( | ) | [inline, protected, virtual] |
Reimplemented from ColDetSupport< T >.
Definition at line 670 of file TAPsModelDeformableCPU.cpp.
00671 { 00672 /* 00673 T xLength = m_paBoundingAABB[0][0] - m_paBoundingAABB[1][0]; 00674 T yLength = m_paBoundingAABB[0][1] - m_paBoundingAABB[1][1]; 00675 T zLength = m_paBoundingAABB[0][2] - m_paBoundingAABB[1][2]; 00676 xLength *= xLength; 00677 yLength *= yLength; 00678 zLength *= zLength; 00679 m_pBoundingSphere = sqrt( xLength + yLength + zLength ) / 2.0; 00680 //*/ 00681 // T squaredLength; 00682 m_pBoundingSphere = 0; 00683 // for ( int i = 0; i < m_iNoVertices; ++i ) { 00684 // squaredLength = (m_prXElement[i].GetPosition() - m_pBoundingCenter).SquaredLength(); 00685 // if ( squaredLength > m_pBoundingSphere ) 00686 // m_pBoundingSphere = squaredLength; 00687 // } 00688 m_pBoundingSphere = sqrt( m_pBoundingSphere ); 00689 }
| void ModelDeformableCPU< T >::CalElementForceExternal | ( | int | iElementID, | |
| T | Vforce[3] | |||
| ) | [inline, protected] |
Calculate the total external force vector of an element
Definition at line 1966 of file TAPsModelDeformableCPU.cpp.
| void ModelDeformableCPU< T >::CalElementForceInternal | ( | int | iElementID, | |
| T | Vforce[3] | |||
| ) | [inline, protected] |
Calculate the total internal (spring) force vector of an element
Definition at line 1701 of file TAPsModelDeformableCPU.cpp.
01703 { 01704 int iFromElementIdx = iElementID * 4; 01705 int iToElementIdx = 0; 01706 T Kstiffness = 0; 01707 T Kdamper = 0; 01708 T tRestLength = 1; 01709 //--------------------------------------------------------------- 01710 int start = iElementID * m_iElementMaxValence; 01711 for ( int i = start; i < start + m_iElementMaxValence; ++i ) { 01712 //------------------------------------------------- 01713 // Get the damped spring parameters 01714 //--------------------------------------- 01715 // Center to East and to West 01716 if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::EAST] ) { 01717 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::EAST]; 01718 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01719 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::EAST]; 01720 #endif 01721 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::EAST]; 01722 } 01723 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::WEST] ) { 01724 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::WEST]; 01725 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01726 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::WEST]; 01727 #endif 01728 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::WEST]; 01729 } 01730 //--------------------------------------- 01731 // Center to North and to South 01732 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::NORTH] ) { 01733 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::NORTH]; 01734 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01735 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::NORTH]; 01736 #endif 01737 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::NORTH]; 01738 } 01739 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::SOUTH] ) { 01740 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::SOUTH]; 01741 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01742 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::SOUTH]; 01743 #endif 01744 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::SOUTH]; 01745 } 01746 //--------------------------------------- 01747 // Center to Front and to Back 01748 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::FRONT] ) { 01749 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::FRONT]; 01750 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01751 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::FRONT]; 01752 #endif 01753 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::FRONT]; 01754 } 01755 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::BACK] ) { 01756 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::BACK]; 01757 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01758 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::BACK]; 01759 #endif 01760 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::BACK]; 01761 } 01762 //--------------------------------------- 01763 // Center to North East and to South West 01764 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::NORTH_EAST] ) { 01765 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::NORTH_EAST]; 01766 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01767 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::NORTH_EAST]; 01768 #endif 01769 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::NORTH_EAST]; 01770 } 01771 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::SOUTH_WEST] ) { 01772 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::SOUTH_WEST]; 01773 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01774 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::SOUTH_WEST]; 01775 #endif 01776 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::SOUTH_WEST]; 01777 } 01778 //--------------------------------------- 01779 // Center to North West and to South East 01780 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::NORTH_WEST] ) { 01781 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::NORTH_WEST]; 01782 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01783 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::NORTH_WEST]; 01784 #endif 01785 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::NORTH_WEST]; 01786 } 01787 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::SOUTH_EAST] ) { 01788 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::SOUTH_EAST]; 01789 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01790 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::SOUTH_EAST]; 01791 #endif 01792 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::SOUTH_EAST]; 01793 } 01794 //--------------------------------------- 01795 // Center to Front East and to South West 01796 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::FRONT_EAST] ) { 01797 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::FRONT_EAST]; 01798 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01799 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::FRONT_EAST]; 01800 #endif 01801 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::FRONT_EAST]; 01802 } 01803 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::BACK_WEST] ) { 01804 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::BACK_WEST]; 01805 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01806 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::BACK_WEST]; 01807 #endif 01808 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::BACK_WEST]; 01809 } 01810 //--------------------------------------- 01811 // Center to Front North and to Back South 01812 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::FRONT_NORTH] ) { 01813 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::FRONT_NORTH]; 01814 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01815 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::FRONT_NORTH]; 01816 #endif 01817 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::FRONT_NORTH]; 01818 } 01819 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::BACK_SOUTH] ) { 01820 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::BACK_SOUTH]; 01821 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01822 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::BACK_SOUTH]; 01823 #endif 01824 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::BACK_SOUTH]; 01825 } 01826 //--------------------------------------- 01827 // Center to Front West and to Back East 01828 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::FRONT_WEST] ) { 01829 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::FRONT_WEST]; 01830 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01831 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::FRONT_WEST]; 01832 #endif 01833 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::FRONT_WEST]; 01834 } 01835 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::BACK_EAST] ) { 01836 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::BACK_EAST]; 01837 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01838 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::BACK_EAST]; 01839 #endif 01840 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::BACK_EAST]; 01841 } 01842 //--------------------------------------- 01843 // Center to Front South and to Back North 01844 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::FRONT_SOUTH] ) { 01845 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::FRONT_SOUTH]; 01846 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01847 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::FRONT_SOUTH]; 01848 #endif 01849 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::FRONT_SOUTH]; 01850 } 01851 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::BACK_NORTH] ) { 01852 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::BACK_NORTH]; 01853 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01854 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::BACK_NORTH]; 01855 #endif 01856 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::BACK_NORTH]; 01857 } 01858 //--------------------------------------- 01859 // Center to Front North East and to Back South West 01860 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::FRONT_NORTH_EAST] ) { 01861 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::FRONT_NORTH_EAST]; 01862 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01863 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::FRONT_NORTH_EAST]; 01864 #endif 01865 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::FRONT_NORTH_EAST]; 01866 } 01867 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::BACK_SOUTH_WEST] ) { 01868 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::BACK_SOUTH_WEST]; 01869 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01870 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::BACK_SOUTH_WEST]; 01871 #endif 01872 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::BACK_SOUTH_WEST]; 01873 } 01874 //--------------------------------------- 01875 // Center to Front North West and to Back South East 01876 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::FRONT_NORTH_WEST] ) { 01877 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::FRONT_NORTH_WEST]; 01878 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01879 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::FRONT_NORTH_WEST]; 01880 #endif 01881 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::FRONT_NORTH_WEST]; 01882 } 01883 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::BACK_SOUTH_EAST] ) { 01884 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::BACK_SOUTH_EAST]; 01885 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01886 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::BACK_SOUTH_EAST]; 01887 #endif 01888 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::BACK_SOUTH_EAST]; 01889 } 01890 //--------------------------------------- 01891 // Center to Front South West and to Back North East 01892 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::FRONT_SOUTH_WEST] ) { 01893 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::FRONT_SOUTH_WEST]; 01894 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01895 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::FRONT_SOUTH_WEST]; 01896 #endif 01897 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::FRONT_SOUTH_WEST]; 01898 } 01899 else if( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::BACK_NORTH_EAST] ) { 01900 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::BACK_NORTH_EAST]; 01901 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01902 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::BACK_NORTH_EAST]; 01903 #endif 01904 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::BACK_NORTH_EAST]; 01905 } 01906 //--------------------------------------- 01907 // Center to Front South East and to Back North West 01908 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::FRONT_SOUTH_EAST] ) { 01909 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::FRONT_SOUTH_EAST]; 01910 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01911 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::FRONT_SOUTH_EAST]; 01912 #endif 01913 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::FRONT_SOUTH_EAST]; 01914 } 01915 else if ( m_ipElementConnect[i] == CONNECTION_INDEX[SpringProp::CONNECT::BACK_NORTH_WEST] ) { 01916 Kstiffness = SPRING_PROP.STIFFNESS[SpringProp::CONNECT::BACK_NORTH_WEST]; 01917 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01918 Kdamper = SPRING_PROP.DAMPER[SpringProp::CONNECT::BACK_NORTH_WEST]; 01919 #endif 01920 tRestLength = SPRING_PROP.REST_LENGTH[SpringProp::CONNECT::BACK_NORTH_WEST]; 01921 } 01922 //------------------------------------------------- 01923 //------------------------------------------------- 01924 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 01925 // Calculate and add the damped spring force for 01926 // the explicit Euler integration 01927 iToElementIdx = iFromElementIdx + m_ipElementConnect[i]; 01928 AddDampedSpringForceForExplicitEulerIntegration( 01929 &m_tpElementPos[iFromElementIdx], 01930 &m_tpElementPos[iToElementIdx], 01931 &m_tpElementVel[iFromElementIdx], 01932 &m_tpElementVel[iToElementIdx], 01933 tRestLength, 01934 Kstiffness, 01935 Kdamping, 01936 Vforce 01937 ); 01938 #endif 01939 //------------------------------------------------- 01940 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VERLET_INTEGRATION 01941 // Calculate and add the undamped spring force for 01942 // the Verlet integration 01943 if ( m_ipElementConnect[i] != 0 ) { 01944 iToElementIdx = iFromElementIdx + m_ipElementConnect[i]; 01945 01946 /* 01947 // DEBUG] 01948 std::cout << "\nm_ipElementConnect[" << i%26 << "]: " << m_ipElementConnect[i] << "\n"; 01949 std::cout << "iFromElementIdx: " << iFromElementIdx << "\n"; 01950 std::cout << "iToElementIdx: " << iToElementIdx << "\n"; 01951 //*/ 01952 01953 AddUndampedSpringForceForVerletIntegration( 01954 &m_tpElementPos[iFromElementIdx], 01955 &m_tpElementPos[iToElementIdx], 01956 tRestLength, 01957 Kstiffness, 01958 Vforce 01959 ); 01960 } 01961 #endif 01962 } 01963 }
| void ModelDeformableCPU< T >::CalElementForceTotal | ( | int | iElementID, | |
| T | Vforce[3] | |||
| ) | [inline, protected] |
Calculate the total force of an element Ftotal = Finternal + Fexternal
Definition at line 1684 of file TAPsModelDeformableCPU.cpp.
01686 { 01687 //--------------------------------------------------------------- 01688 // Reset the (output) force vector 01689 // Commented out if assume the force does not need to be reset! 01690 //Vforce[0] = Vforce[1] = Vforce[2] = 0; 01691 //--------------------------------------------------------------- 01692 // Calculate the Total Internal Force 01693 CalElementForceInternal ( iElementID, Vforce ); 01694 //--------------------------------------------------------------- 01695 // Calculate the Total External Force 01696 CalElementForceExternal ( iElementID, Vforce ); 01697 //--------------------------------------------------------------- 01698 }
| void ModelDeformableCPU< T >::Clear | ( | ) | [inline, virtual] |
Definition at line 109 of file TAPsModelDeformableCPU.cpp.
00110 { 00111 //--------------------------------------------------------------- 00112 // Element Connections 00113 if ( m_ipElementConnect ) { 00114 delete [] m_ipElementConnect; 00115 //m_ipElementConnect = NULL; 00116 } 00117 //--------------------------------------------------------------- 00118 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VERLET_INTEGRATION 00119 // Element Position Previous 00120 if ( m_tpElementPosPrev ) { 00121 delete [] m_tpElementPosPrev; 00122 //m_tpElementPosPrev = NULL; 00123 } 00124 #endif 00125 //--------------------------------------------------------------- 00126 // Element Position 00127 if ( m_tpElementPos ) { 00128 delete [] m_tpElementPos; 00129 //m_tpElementPos = NULL; 00130 } 00131 //--------------------------------------------------------------- 00132 // Element Position Next 00133 if ( m_tpElementPosNext ) { 00134 delete [] m_tpElementPosNext; 00135 //m_tpElementPosNext = NULL; 00136 } 00137 //--------------------------------------------------------------- 00138 // Element Velocity 00139 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 00140 if ( m_tpElementVel ) { 00141 delete [] m_tpElementVel; 00142 //m_tpElementVel = NULL; 00143 } 00144 //--------------------------------------------------------------- 00145 // Element Velocity Next 00146 if ( m_tpElementVelNext ) { 00147 delete [] m_tpElementVelNext; 00148 //m_tpElementVelNext = NULL; 00149 } 00150 #endif 00151 //--------------------------------------------------------------- 00152 // For GLSL 00153 // if ( m_glslProgramObject ) { 00154 // m_glslShaderManager.Delete( m_glslProgramObject ); 00155 // delete m_glslProgramObject; // WHY ERROR!!! DEBUG ??? 00156 // //m_glslProgramObject = NULL; 00157 // } 00158 //--------------------------------------------------------------- 00159 /* 00160 #ifdef TAPs_DEBUG_MODE 00161 #ifdef TAPs_USE_WXWIDGETS 00162 wxLogError( wxT( "Finish clearing the deformable model data." ) ); 00163 #else 00164 std::cout << "Finish clearing the deformable model data." << std::endline; 00165 #endif 00166 #endif 00167 //*/ 00168 //--------------------------------------------------------------- 00169 // Clear Visualization 00170 ClearVisualization(); 00171 //--------------------------------------------------------------- 00172 Default(); 00173 }
| void ModelDeformableCPU< T >::ClearVisualization | ( | ) | [inline, protected] |
Definition at line 195 of file TAPsModelDeformableCPU.cpp.
00196 { 00197 #ifdef TAPs_MODEL_DEFORMABLE_GLSL_VISUALIZATION_RT_GEN_MESH 00198 if ( m_Visualization_RTGenMesh ) { 00199 delete m_Visualization_RTGenMesh; 00200 } 00201 #endif 00202 #ifdef TAPs_MODEL_DEFORMABLE_GLSL_VISUALIZATION_3D_TEXTURE 00203 if ( m_Visualization_3DTexture ) { 00204 delete m_Visualization_3DTexture; 00205 } 00206 #endif 00207 #ifdef TAPs_MODEL_DEFORMABLE_GLSL_VISUALIZATION_RAY_CASTING 00208 if ( m_Visualization_RayCasting ) { 00209 delete m_Visualization_RayCasting; 00210 } 00211 #endif 00212 #ifdef TAPs_MODEL_DEFORMABLE_GLSL_VISUALIZATION_MESH 00213 if ( m_Visualization_Mesh ) { 00214 delete m_Visualization_Mesh; 00215 } 00216 #endif 00217 //--------------------------------- 00218 DefaultVisualization(); 00219 }
| void ModelDeformableCPU< T >::CreateConnections | ( | ) | [protected] |
| void ModelDeformableCPU< T >::CreateConnectionsFullOneRing | ( | ) | [inline, protected] |
Definition at line 1339 of file TAPsModelDeformableCPU.cpp.
01340 { 01341 /* 01342 m_iElementMaxValence = 1; 01343 int listOfConnections[1]; 01344 listOfConnections[0] = CONNECTION_INDEX[BACK]; 01345 //*/ 01346 01347 01348 /* 01349 m_gliElementMaxValence = 6; 01350 int listOfConnections[6]; 01351 listOfConnections[0] = CONNECTION_INDEX::CENTER_EAST; 01352 listOfConnections[1] = CONNECTION_INDEX::CENTER_NORTH; 01353 listOfConnections[2] = CONNECTION_INDEX::CENTER_WEST; 01354 listOfConnections[3] = CONNECTION_INDEX::CENTER_SOUTH; 01355 listOfConnections[4] = CONNECTION_INDEX::FRONT_CENTER; 01356 listOfConnections[5] = CONNECTION_INDEX::BACK_CENTER; 01357 //*/ 01358 01359 //* 01360 //--------------------------------------------------------------- 01361 m_iElementMaxValence = 26; 01362 int listOfConnections[26]; 01363 //----------------------- 01364 listOfConnections[0] = CONNECTION_INDEX[SpringProp::CONNECT::EAST]; 01365 listOfConnections[1] = CONNECTION_INDEX[SpringProp::CONNECT::NORTH]; 01366 listOfConnections[2] = CONNECTION_INDEX[SpringProp::CONNECT::WEST]; 01367 listOfConnections[3] = CONNECTION_INDEX[SpringProp::CONNECT::SOUTH]; 01368 //----------------------- 01369 listOfConnections[4] = CONNECTION_INDEX[SpringProp::CONNECT::FRONT]; 01370 //----------------------- 01371 listOfConnections[5] = CONNECTION_INDEX[SpringProp::CONNECT::BACK]; 01372 //----------------------- 01373 listOfConnections[6] = CONNECTION_INDEX[SpringProp::CONNECT::NORTH_EAST]; 01374 listOfConnections[7] = CONNECTION_INDEX[SpringProp::CONNECT::NORTH_WEST]; 01375 listOfConnections[8] = CONNECTION_INDEX[SpringProp::CONNECT::SOUTH_WEST]; 01376 listOfConnections[9] = CONNECTION_INDEX[SpringProp::CONNECT::SOUTH_EAST]; 01377 //----------------------- 01378 listOfConnections[10] = CONNECTION_INDEX[SpringProp::CONNECT::FRONT_EAST]; 01379 listOfConnections[11] = CONNECTION_INDEX[SpringProp::CONNECT::FRONT_NORTH]; 01380 listOfConnections[12] = CONNECTION_INDEX[SpringProp::CONNECT::FRONT_WEST]; 01381 listOfConnections[13] = CONNECTION_INDEX[SpringProp::CONNECT::FRONT_SOUTH]; 01382 //----------------------- 01383 listOfConnections[14] = CONNECTION_INDEX[SpringProp::CONNECT::BACK_EAST]; 01384 listOfConnections[15] = CONNECTION_INDEX[SpringProp::CONNECT::BACK_NORTH]; 01385 listOfConnections[16] = CONNECTION_INDEX[SpringProp::CONNECT::BACK_WEST]; 01386 listOfConnections[17] = CONNECTION_INDEX[SpringProp::CONNECT::BACK_SOUTH]; 01387 //----------------------- 01388 listOfConnections[18] = CONNECTION_INDEX[SpringProp::CONNECT::FRONT_NORTH_EAST]; 01389 listOfConnections[19] = CONNECTION_INDEX[SpringProp::CONNECT::FRONT_NORTH_WEST]; 01390 listOfConnections[20] = CONNECTION_INDEX[SpringProp::CONNECT::FRONT_SOUTH_WEST]; 01391 listOfConnections[21] = CONNECTION_INDEX[SpringProp::CONNECT::FRONT_SOUTH_EAST]; 01392 //----------------------- 01393 listOfConnections[22] = CONNECTION_INDEX[SpringProp::CONNECT::BACK_NORTH_EAST]; 01394 listOfConnections[23] = CONNECTION_INDEX[SpringProp::CONNECT::BACK_NORTH_WEST]; 01395 listOfConnections[24] = CONNECTION_INDEX[SpringProp::CONNECT::BACK_SOUTH_WEST]; 01396 listOfConnections[25] = CONNECTION_INDEX[SpringProp::CONNECT::BACK_SOUTH_EAST]; 01397 //----------------------- 01398 //*/ 01399 01400 //* 01401 //--------------------------------------------------------------- 01402 m_ipElementConnect = new int[m_iTotalElements * m_iElementMaxValence]; 01403 //--------------------------------------------------------------- 01404 int index = 0; 01405 int iOffsetSlice = m_vGridResolution[0] * m_vGridResolution[1]; 01406 //--------------------------------------------------------------- 01407 // All elements not on the boundary 01408 for ( int Z = 1; Z < m_vGridResolution[2] - 1; ++Z ) { 01409 index = Z * iOffsetSlice; 01410 for ( int Y = 1; Y < m_vGridResolution[1] - 1; ++Y ) { 01411 for ( int X = 1; X < m_vGridResolution[0] - 1; ++X ) { 01412 CreateConnectionsOfOneElementNotOnBoundary( 01413 Z, Y, X, listOfConnections, m_iElementMaxValence ); 01414 } 01415 } 01416 } 01417 //--------------------------------------------------------------- 01418 // The first (back) slice and the last (front) slice 01419 for ( int Z = 0; Z < m_vGridResolution[2]; Z += m_vGridResolution[2]-1 ) { 01420 for ( int Y = 0; Y < m_vGridResolution[1]; ++Y ) { 01421 for ( int X = 0; X < m_vGridResolution[0]; ++X ) { 01422 CreateConnectionsOfOneElementOnBoundary( 01423 Z, Y, X, listOfConnections, m_iElementMaxValence ); 01424 } 01425 } 01426 } 01427 //--------------------------------------------------------------- 01428 // The bottom slice and the top slice 01429 for ( int Z = 0; Z < m_vGridResolution[2]; ++Z ) { 01430 for ( int Y = 0; Y < m_vGridResolution[1]; Y += m_vGridResolution[1]-1 ) { 01431 for ( int X = 0; X < m_vGridResolution[0]; ++X ) { 01432 CreateConnectionsOfOneElementOnBoundary( 01433 Z, Y, X, listOfConnections, m_iElementMaxValence ); 01434 } 01435 } 01436 } 01437 //--------------------------------------------------------------- 01438 // The left slice and the right slice 01439 for ( int Z = 1; Z < m_vGridResolution[2] - 1; ++Z ) { 01440 for ( int Y = 1; Y < m_vGridResolution[1] - 1; ++Y ) { 01441 for ( int X = 0; X < m_vGridResolution[0]; X += m_vGridResolution[0]-1 ) { 01442 CreateConnectionsOfOneElementOnBoundary( 01443 Z, Y, X, listOfConnections, m_iElementMaxValence ); 01444 } 01445 } 01446 } 01447 //*/ 01448 }
| void ModelDeformableCPU< T >::CreateConnectionsOfOneElementNotOnBoundary | ( | int | z, | |
| int | y, | |||
| int | x, | |||
| int * | connectionPattern, | |||
| int | connectionSize | |||
| ) | [inline, protected] |
Definition at line 1451 of file TAPsModelDeformableCPU.cpp.
01453 { 01454 //--------------------------------------------------------------- 01455 int iOffsetSlice = m_vGridResolution[1] * m_vGridResolution[0]; 01456 int indexThis = (z * iOffsetSlice + y * m_vGridResolution[0] + x); 01457 int idxConnection = indexThis * m_iElementMaxValence; // index for start of connections 01458 indexThis *= 4; // index for start of positions (+ flag) 01459 //--------------------------------------------------------------- 01460 static T threshold = 250; 01461 if ( m_tpElementPos[indexThis + 3] < threshold ) return; 01462 //--------------------------------------------------------------- 01463 int indexConnectedTo; 01464 //--------------------------------------------------------------- 01465 for ( int i = 0; i < connectionSize; ++i ) { 01466 //------------------------------------------------- 01467 int idx = idxConnection + i; 01468 m_ipElementConnect[idx] = CONNECTION_INDEX[SpringProp::CONNECT::NOT_CONNECTED]; 01469 //------------------------------------------------- 01470 indexConnectedTo = indexThis + connectionPattern[i]; 01471 if ( m_tpElementPos[indexConnectedTo + 3] >= threshold ) { 01472 m_ipElementConnect[idx] = connectionPattern[i]; 01473 } 01474 } 01475 }
| void ModelDeformableCPU< T >::CreateConnectionsOfOneElementOnBoundary | ( | int | z, | |
| int | y, | |||
| int | x, | |||
| int * | connectionPattern, | |||
| int | connectionSize | |||
| ) | [inline, protected] |
Definition at line 1478 of file TAPsModelDeformableCPU.cpp.
01480 { 01481 //--------------------------------------------------------------- 01482 int iOffsetSlice = m_vGridResolution[1] * m_vGridResolution[0]; 01483 int indexThis = (z * iOffsetSlice + y * m_vGridResolution[0] + x); 01484 int idxConnection = indexThis * m_iElementMaxValence; // index for start of connections 01485 indexThis *= 4; // index for start of positions (+ flag) 01486 //--------------------------------- 01487 int iBoundEast = m_vGridResolution[0] - 1; 01488 int iBoundWest = 0; 01489 int iBoundNorth = m_vGridResolution[1] - 1; 01490 int iBoundSouth = 0; 01491 int iBoundFront = m_vGridResolution[2] - 1; 01492 int iBoundBack = 0; 01493 //--------------------------------------------------------------- 01494 static T threshold = 250; 01495 if ( m_tpElementPos[indexThis + 3] < threshold ) return; 01496 //--------------------------------------------------------------- 01497 int indexConnectedTo; 01498 //--------------------------------------------------------------- 01499 for ( int i = 0; i < connectionSize; ++i ) { 01500 //------------------------------------------------- 01501 int idx = idxConnection + i; 01502 m_ipElementConnect[idx] = CONNECTION_INDEX[SpringProp::CONNECT::NOT_CONNECTED]; 01503 indexConnectedTo = 0; 01504 //================================================= 01505 //------------------------------------------------- 01506 if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::EAST] ) { 01507 if ( x < iBoundEast ) { 01508 indexConnectedTo = indexThis + connectionPattern[i]; 01509 } 01510 } 01511 //------------------------------------------------- 01512 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::NORTH] ) { 01513 if ( y < iBoundNorth ) { 01514 indexConnectedTo = indexThis + connectionPattern[i]; 01515 } 01516 } 01517 //------------------------------------------------- 01518 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::WEST] ) { 01519 if ( x > iBoundWest ) { 01520 indexConnectedTo = indexThis + connectionPattern[i]; 01521 } 01522 } 01523 //------------------------------------------------- 01524 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::SOUTH] ) { 01525 if ( y > iBoundSouth ) { 01526 indexConnectedTo = indexThis + connectionPattern[i]; 01527 } 01528 } 01529 //================================================= 01530 //------------------------------------------------- 01531 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::FRONT] ) { 01532 if ( z < iBoundFront ) { 01533 indexConnectedTo = indexThis + connectionPattern[i]; 01534 } 01535 } 01536 //------------------------------------------------- 01537 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::BACK] ) { 01538 if ( z > iBoundBack ) { 01539 indexConnectedTo = indexThis + connectionPattern[i]; 01540 } 01541 } 01542 //================================================= 01543 //------------------------------------------------- 01544 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::NORTH_EAST] ) { 01545 if ( y < iBoundNorth && x < iBoundEast ) { 01546 indexConnectedTo = indexThis + connectionPattern[i]; 01547 } 01548 } 01549 //------------------------------------------------- 01550 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::NORTH_WEST] ) { 01551 if ( y < iBoundNorth && x > iBoundWest ) { 01552 indexConnectedTo = indexThis + connectionPattern[i]; 01553 } 01554 } 01555 //------------------------------------------------- 01556 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::SOUTH_WEST] ) { 01557 if ( y > iBoundSouth && x > iBoundWest ) { 01558 indexConnectedTo = indexThis + connectionPattern[i]; 01559 } 01560 } 01561 //------------------------------------------------- 01562 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::SOUTH_EAST] ) { 01563 if ( y > iBoundSouth && x < iBoundEast ) { 01564 indexConnectedTo = indexThis + connectionPattern[i]; 01565 } 01566 } 01567 //================================================= 01568 //------------------------------------------------- 01569 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::FRONT_EAST] ) { 01570 if ( z < iBoundFront && x < iBoundEast ) { 01571 indexConnectedTo = indexThis + connectionPattern[i]; 01572 } 01573 } 01574 //------------------------------------------------- 01575 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::FRONT_NORTH] ) { 01576 if ( z < iBoundFront && y < iBoundNorth ) { 01577 indexConnectedTo = indexThis + connectionPattern[i]; 01578 } 01579 } 01580 //------------------------------------------------- 01581 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::FRONT_WEST] ) { 01582 if ( z < iBoundFront && x > iBoundWest ) { 01583 indexConnectedTo = indexThis + connectionPattern[i]; 01584 } 01585 } 01586 //------------------------------------------------- 01587 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::FRONT_SOUTH] ) { 01588 if ( z < iBoundFront && y > iBoundSouth ) { 01589 indexConnectedTo = indexThis + connectionPattern[i]; 01590 } 01591 } 01592 //================================================= 01593 //------------------------------------------------- 01594 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::BACK_EAST] ) { 01595 if ( z > iBoundBack && x < iBoundEast ) { 01596 indexConnectedTo = indexThis + connectionPattern[i]; 01597 } 01598 } 01599 //------------------------------------------------- 01600 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::BACK_NORTH] ) { 01601 if ( z > iBoundBack && y < iBoundNorth ) { 01602 indexConnectedTo = indexThis + connectionPattern[i]; 01603 } 01604 } 01605 //------------------------------------------------- 01606 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::BACK_WEST] ) { 01607 if ( z > iBoundBack && x > iBoundWest ) { 01608 indexConnectedTo = indexThis + connectionPattern[i]; 01609 } 01610 } 01611 //------------------------------------------------- 01612 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::BACK_SOUTH] ) { 01613 if ( z > iBoundBack && y > iBoundSouth ) { 01614 indexConnectedTo = indexThis + connectionPattern[i]; 01615 } 01616 } 01617 //================================================= 01618 //------------------------------------------------- 01619 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::FRONT_NORTH_EAST] ) { 01620 if ( z < iBoundFront && y < iBoundNorth && x < iBoundEast ) { 01621 indexConnectedTo = indexThis + connectionPattern[i]; 01622 } 01623 } 01624 //------------------------------------------------- 01625 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::FRONT_NORTH_WEST] ) { 01626 if ( z < iBoundFront && y < iBoundNorth && x > iBoundWest ) { 01627 indexConnectedTo = indexThis + connectionPattern[i]; 01628 } 01629 } 01630 //------------------------------------------------- 01631 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::FRONT_SOUTH_WEST] ) { 01632 if ( z < iBoundFront && y > iBoundSouth && x > iBoundWest ) { 01633 indexConnectedTo = indexThis + connectionPattern[i]; 01634 } 01635 } 01636 //------------------------------------------------- 01637 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::FRONT_SOUTH_EAST] ) { 01638 if ( z < iBoundFront && y > iBoundSouth && x < iBoundEast ) { 01639 indexConnectedTo = indexThis + connectionPattern[i]; 01640 } 01641 } 01642 //================================================= 01643 //------------------------------------------------- 01644 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::BACK_NORTH_EAST] ) { 01645 if ( z > iBoundBack && y < iBoundNorth && x < iBoundEast ) { 01646 indexConnectedTo = indexThis + connectionPattern[i]; 01647 } 01648 } 01649 //------------------------------------------------- 01650 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::BACK_NORTH_WEST] ) { 01651 if ( z > iBoundBack && y < iBoundNorth && x > iBoundWest ) { 01652 indexConnectedTo = indexThis + connectionPattern[i]; 01653 } 01654 } 01655 //------------------------------------------------- 01656 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::BACK_SOUTH_WEST] ) { 01657 if ( z > iBoundBack && y > iBoundSouth && x > iBoundWest ) { 01658 indexConnectedTo = indexThis + connectionPattern[i]; 01659 } 01660 } 01661 //------------------------------------------------- 01662 else if ( connectionPattern[i] == CONNECTION_INDEX[SpringProp::CONNECT::BACK_SOUTH_EAST] ) { 01663 if ( z > iBoundBack && y > iBoundSouth && x < iBoundEast ) { 01664 indexConnectedTo = indexThis + connectionPattern[i]; 01665 } 01666 } 01667 //------------------------------------------------- 01668 //================================================= 01669 //------------------------------------------------- 01670 if ( indexConnectedTo > 0 ) { 01671 if ( m_tpElementPos[indexConnectedTo + 3] >= threshold ) { 01672 m_ipElementConnect[idx] = connectionPattern[i]; 01673 } 01674 } 01675 } 01676 }
| void ModelDeformableCPU< T >::CreateSurfaceBoundary | ( | ) | [inline, protected] |
Definition at line 528 of file TAPsModelDeformableCPU.cpp.
00529 { 00530 for ( int Z = 0; Z < m_vGridResolution[2]; ++Z ) { 00531 for ( int Y = 0; Y < m_vGridResolution[1]; ++Y ) { 00532 for ( int X = 0; X < m_vGridResolution[0]; ++X ) { 00533 /* 00534 if ( 400 == m_glfpElementPos[count+3] ) { 00535 glPushMatrix(); 00536 glTranslatef( 00537 m_glfpElementPos[count ], 00538 m_glfpElementPos[count+1], 00539 m_glfpElementPos[count+2] 00540 ); 00541 m_OGLUsefulObj.DrawSphere( vScale ); 00542 glPopMatrix(); 00543 } 00544 //*/ 00545 count += 4; 00546 } 00547 } 00548 } 00549 }
| void ModelDeformableCPU< T >::Default | ( | ) | [inline, virtual] |
Definition at line 51 of file TAPsModelDeformableCPU.cpp.
00052 { 00053 //------------------------------------------- 00054 m_vGridResolution.SetXYZ( 0, 0, 0 ); 00055 m_vGridDimension.SetXYZ( 0, 0, 0 ); 00056 m_iTotalElements = 0; 00057 m_fElementVolume = 0; 00058 //------------------------------------------- 00059 // Element Properties 00060 m_tMass = 1; 00061 //------------------------------------------- 00062 // Default Visualization 00063 DefaultVisualization(); 00064 //------------------------------------------- 00065 // Default Spring Properties 00066 //----------------------- 00067 T stiffness = 100; 00068 SPRING_PROP.SetValueForAllStiffnesses( stiffness ); 00069 //SPRING_PROP.SetValueForAllDampers( stiffness / 45000 ); // if SimStepByVerletIntegration damper is multiplied by dt 00070 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 00071 SPRING_PROP.SetValueForAllDampers( stiffness / 100 ); 00072 #endif 00073 //----------------------- 00074 // Spring Rest Lengths have to be set when the grids are created! 00075 //------------------------------------------- 00076 // Previous Step 00077 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VERLET_INTEGRATION 00078 m_tpElementPosPrev = NULL; 00079 #endif 00080 //------------------------------------------- 00081 // Current Step 00082 m_tpElementPos = NULL; 00083 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 00084 m_tpElementVel = NULL; 00085 #endif 00086 //--------------------------------- 00087 // Next Step 00088 m_tpElementPosNext = NULL; 00089 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 00090 m_tpElementVelNext = NULL; 00091 #endif 00092 //--------------------------------- 00093 // Surface 00094 m_ipSurfaceBoundary = NULL; 00095 //--------------------------------- 00096 // Connectivity 00097 m_ipElementConnect = NULL; 00098 m_iElementMaxValence = 0; 00099 //------------------------------------------- 00100 // For GLSL 00101 //m_glslProgramObject = NULL; 00102 //------------------------------------------- 00103 // For drawing useful objects 00104 //m_vOGLUsefulObj = NULL; 00105 }
| void ModelDeformableCPU< T >::DefaultVisualization | ( | ) | [inline, protected] |
Definition at line 177 of file TAPsModelDeformableCPU.cpp.
00178 { 00179 #ifdef TAPs_MODEL_DEFORMABLE_GLSL_VISUALIZATION_RT_GEN_MESH 00180 m_Visualization_RTGenMesh = NULL; 00181 #endif 00182 #ifdef TAPs_MODEL_DEFORMABLE_GLSL_VISUALIZATION_3D_TEXTURE 00183 m_Visualization_3DTexture = NULL; 00184 #endif 00185 #ifdef TAPs_MODEL_DEFORMABLE_GLSL_VISUALIZATION_RAY_CASTING 00186 m_Visualization_RayCasting = NULL; 00187 #endif 00188 #ifdef TAPs_MODEL_DEFORMABLE_GLSL_VISUALIZATION_MESH 00189 m_Visualization_Mesh = NULL; 00190 #endif 00191 }
| void ModelDeformableCPU< T >::DrawByGL | ( | DrawType | drawType = POSITION_TEXTURE |
) | [inline, virtual] |
Definition at line 873 of file TAPsModelDeformableCPU.cpp.
00874 { 00875 /* 00876 // DEBUG 00877 static int iCount = 0; 00878 if ( !m_tpElementPos ) { 00879 iCount = 0; 00880 } 00881 else { 00882 if ( iCount < 20 ) { 00883 int idx = 3; 00884 for ( int i = 0; i < m_iTotalElements; ++i ) { 00885 if ( m_tpElementPos[idx] >= 250 ) { 00886 m_tpElementPos[idx-3] -= m_vGridDimension[0] / 5; 00887 m_tpElementPos[idx-2] -= m_vGridDimension[1] / 5; 00888 m_tpElementPos[idx-1] -= m_vGridDimension[2] / 5; 00889 break; 00890 } 00891 idx += 4; 00892 } 00893 //++iCount; 00894 } 00895 else if ( iCount > 500 ) { 00896 iCount = 0; 00897 } 00898 ++iCount; 00899 SimStepByVerletIntegration( 0.001 ); 00900 } 00901 //*/ 00902 00903 //--------------------------------------------------------------- 00904 switch ( drawType ) { 00905 case AS_2D_TEXTURE: 00906 DrawByGL_As2DTexture(); 00907 break; 00908 case AS_3D_TEXTURE: 00909 DrawByGL_As3DTexture(); 00910 break; 00911 case POSITION_TEXTURE: 00912 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_RT_GEN_MESH 00913 //std::cout << "POSITION_TEXTURE -- w Gen Mesh\n"; 00914 00915 /* 00916 glPushAttrib( GL_ALL_ATTRIB_BITS ); 00917 glDisable( GL_LIGHTING ); 00918 glPointSize( 7 ); 00919 glBegin( GL_POINTS ); 00920 glColor3f( 1, 1, 1 ); 00921 glVertex3f( 0, 0, 0 ); 00922 glEnd(); 00923 glPopAttrib(); 00924 //*/ 00925 00926 //DrawByGL_AllElementsWithConnectivities_GPU(); 00927 VisualizeByRTGenMesh( drawType ); 00928 #else // #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_RT_GEN_MESH 00929 //std::cout << "POSITION_TEXTURE -- wo Gen Mesh\n"; 00930 Visualize( drawType ); 00931 #endif // #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_RT_GEN_MESH 00932 break; 00933 case ALL_ELEMENTS: 00934 DrawByGL_AllElements(); 00935 break; 00936 case ALL_ELEMENTS_WITH_CONNECTIVITIES: 00937 DrawByGL_AllElementsWithConnectivities(); 00938 break; 00939 default: 00940 //DrawByGL_AllElements(); 00941 DrawByGL_AllElementsWithConnectivities(); 00942 break; 00943 } 00944 }
| void ModelDeformableCPU< T >::DrawByGL_AllElements | ( | ) | [inline, protected, virtual] |
Definition at line 1072 of file TAPsModelDeformableCPU.cpp.
01073 { 01074 if ( !m_tpElementPos ) return; 01075 //--------------------------------------------------------------- 01076 // GLsizei numPoints = m_vGridResolution[0] * m_vGridResolution[1]; 01077 //--------------------------------------------------------------- 01078 /* 01079 glPushAttrib( GL_LIGHTING_BIT | GL_CURRENT_BIT | GL_POINT_BIT ); 01080 //glDisable( GL_LIGHTING ); 01081 glEnable( GL_COLOR_MATERIAL ); 01082 glPointSize( 3 ); 01083 glColor3f( 0.2f, 0.7f, 0.4f ); 01084 //*/ 01085 //------------------------------------------------- 01086 // Immediate Draw Mode 01087 //------------------------------------------- 01088 // Draw as OpenGL Primitive Points 01089 /* 01090 glBegin( GL_POINTS ); 01091 int count = 0; 01092 for ( int Z = 0; Z < m_vGridResolution[2]; ++Z ) { 01093 for ( int Y = 0; Y < m_vGridResolution[1]; ++Y ) { 01094 for ( int X = 0; X < m_vGridResolution[0]; ++X ) { 01095 if ( m_glfpElementPos[count+3] > 250 ) { 01096 glElement3f( 01097 m_glfpElementPos[count ], 01098 m_glfpElementPos[count+1], 01099 m_glfpElementPos[count+2] 01100 ); 01101 } 01102 count += 4; 01103 } 01104 } 01105 } 01106 glEnd(); 01107 glPopAttrib(); 01108 //*/ 01109 //------------------------------------------- 01110 // Draw as Spheres 01111 int count = 0; 01112 m_OGLUsefulObj.SetColor( 0.1, 0.3, 0.25, 0.25 ); 01113 Vector3<T> vScale( 01114 m_vGridDimension[0], 01115 m_vGridDimension[1], 01116 m_vGridDimension[2] 01117 //m_vGridDimension[0] / 2.0f, 01118 //m_vGridDimension[1] / 2.0f, 01119 //m_vGridDimension[2] / 2.0f 01120 //m_vGridDimension[0] / 4.0f, 01121 //m_vGridDimension[1] / 4.0f, 01122 //m_vGridDimension[2] / 4.0f 01123 ); 01124 // for ( int i = 0; i < m_iTotalElements; ++i ) { 01125 for ( int Z = 0; Z < m_vGridResolution[2]; ++Z ) { 01126 for ( int Y = 0; Y < m_vGridResolution[1]; ++Y ) { 01127 for ( int X = 0; X < m_vGridResolution[0]; ++X ) { 01128 /* 01129 if ( m_glfpElementPos[count+3] > 250 ) { 01130 glPushMatrix(); 01131 glTranslatef( 01132 m_glfpElementPos[count ], 01133 m_glfpElementPos[count+1], 01134 m_glfpElementPos[count+2] 01135 ); 01136 m_OGLUsefulObj.DrawSphere( vScale ); 01137 glPopMatrix(); 01138 } 01139 //*/ 01140 //------------------------------- 01141 if ( 500 == m_tpElementPos[count+3] ) { 01142 m_OGLUsefulObj.SetColor( 0.10, 0.30, 0.50, 0.25 ); // some what blue 01143 glPushMatrix(); 01144 glTranslatef( 01145 m_tpElementPos[count ], 01146 m_tpElementPos[count+1], 01147 m_tpElementPos[count+2] 01148 ); 01149 //m_OGLUsefulObj.DrawSphere( vScale ); 01150 m_OGLUsefulObj.DrawCube( vScale ); 01151 glPopMatrix(); 01152 } 01153 //------------------------------- 01154 else if ( 400 == m_tpElementPos[count+3] ) { 01155 m_OGLUsefulObj.SetColor( 0.10, 0.30, 0.25, 0.25 ); // some what green 01156 glPushMatrix(); 01157 glTranslatef( 01158 m_tpElementPos[count ], 01159 m_tpElementPos[count+1], 01160 m_tpElementPos[count+2] 01161 ); 01162 //m_OGLUsefulObj.DrawSphere( vScale ); 01163 m_OGLUsefulObj.DrawCube( vScale ); 01164 glPopMatrix(); 01165 } 01166 //------------------------------- 01167 else if ( 300 == m_tpElementPos[count+3] ) { 01168 m_OGLUsefulObj.SetColor( 0.50, 0.30, 0.10, 0.25 ); // some what yellow 01169 glPushMatrix(); 01170 glTranslatef( 01171 m_tpElementPos[count ], 01172 m_tpElementPos[count+1], 01173 m_tpElementPos[count+2] 01174 ); 01175 //m_OGLUsefulObj.DrawSphere( vScale ); 01176 m_OGLUsefulObj.DrawCube( vScale ); 01177 glPopMatrix(); 01178 } 01179 //------------------------------- 01180 count += 4; 01181 } 01182 } 01183 } 01184 }
| void ModelDeformableCPU< T >::DrawByGL_AllElementsWithConnectivities | ( | ) | [inline, protected, virtual] |
Definition at line 716 of file TAPsModelDeformableCPU.cpp.
00717 { 00718 if ( !m_tpElementPos ) return; 00719 //--------------------------------------------------------------- 00720 // GLsizei numPoints = m_vGridResolution[0] * m_vGridResolution[1]; 00721 //--------------------------------------------------------------- 00722 // Draw as Spheres 00723 int count = 0; 00724 m_OGLUsefulObj.SetColor( 0.1, 0.3, 0.25, 0.25 ); 00725 Vector3<T> vScale( 00726 // m_vGridDimension[0] / 4.0f, 00727 // m_vGridDimension[1] / 4.0f, 00728 // m_vGridDimension[2] / 4.0f 00729 00730 // m_vGridDimension[0] / 3.0f, 00731 // m_vGridDimension[1] / 3.0f, 00732 // m_vGridDimension[2] / 3.0f 00733 00734 // Good value for seeing connections 00735 // m_vGridDimension[0] / 1.25, 00736 // m_vGridDimension[1] / 1.25, 00737 // m_vGridDimension[2] / 1.25 00738 00739 // Ellipsoid touching each other 00740 // m_vGridDimension[0], 00741 // m_vGridDimension[1], 00742 // m_vGridDimension[2] 00743 00744 // Ellipsoid overlapping each other 00745 m_vGridDimension[0] * 1.25, 00746 m_vGridDimension[1] * 1.25, 00747 m_vGridDimension[2] * 1.25 00748 ); 00749 //----------------------------------------------------- 00750 // for ( int i = 0; i < m_iTotalElements; ++i ) { 00751 for ( int Z = 0; Z < m_vGridResolution[2]; ++Z ) { 00752 for ( int Y = 0; Y < m_vGridResolution[1]; ++Y ) { 00753 for ( int X = 0; X < m_vGridResolution[0]; ++X ) { 00754 /* 00755 if ( m_glfpElementPos[count+3] > 250 ) { 00756 glPushMatrix(); 00757 glTranslatef( 00758 m_glfpElementPos[count ], 00759 m_glfpElementPos[count+1], 00760 m_glfpElementPos[count+2] 00761 ); 00762 m_OGLUsefulObj.DrawSphere( vScale ); 00763 glPopMatrix(); 00764 } 00765 //*/ 00766 00767 00768 /* 00769 // DEBUG 00770 if ( X == 1 && Y == 1 && Z == 1 ) { 00771 m_OGLUsefulObj.SetColor( 1.0, 0.0, 0.5, 0.25 ); // some what red 00772 glPushMatrix(); 00773 glTranslatef( 00774 m_tpElementPos[count ], 00775 m_tpElementPos[count+1], 00776 m_tpElementPos[count+2] 00777 ); 00778 m_OGLUsefulObj.DrawSphere( vScale ); 00779 glPopMatrix(); 00780 } 00781 //*/ 00782 00783 //------------------------------- 00784 if ( 500 == m_tpElementPos[count+3] ) { 00785 m_OGLUsefulObj.SetColor( 0.10, 0.30, 0.50, 0.25 ); // some what blue 00786 glPushMatrix(); 00787 glTranslatef( 00788 m_tpElementPos[count ], 00789 m_tpElementPos[count+1], 00790 m_tpElementPos[count+2] 00791 ); 00792 m_OGLUsefulObj.DrawSphere( vScale ); 00793 glPopMatrix(); 00794 } 00795 //------------------------------- 00796 else if ( 400 == m_tpElementPos[count+3] ) { 00797 m_OGLUsefulObj.SetColor( 0.10, 0.30, 0.25, 0.25 ); // some what green 00798 glPushMatrix(); 00799 glTranslatef( 00800 m_tpElementPos[count ], 00801 m_tpElementPos[count+1], 00802 m_tpElementPos[count+2] 00803 ); 00804 m_OGLUsefulObj.DrawSphere( vScale ); 00805 glPopMatrix(); 00806 } 00807 //------------------------------- 00808 else if ( 300 == m_tpElementPos[count+3] ) { 00809 m_OGLUsefulObj.SetColor( 0.50, 0.30, 0.10, 0.25 ); // some what yellow 00810 glPushMatrix(); 00811 glTranslatef( 00812 m_tpElementPos[count ], 00813 m_tpElementPos[count+1], 00814 m_tpElementPos[count+2] 00815 ); 00816 m_OGLUsefulObj.DrawSphere( vScale ); 00817 glPopMatrix(); 00818 } 00819 //------------------------------- 00820 count += 4; 00821 } 00822 } 00823 } 00824 //------------------------------------------- 00825 // Draw Connections 00826 glPushAttrib( GL_ALL_ATTRIB_BITS ); 00827 glLineWidth( 1 ); 00828 //glLineWidth( 3 ); 00829 glColor3f( 0.9, 1.0, 0.0 ); 00830 glDisable( GL_LIGHTING ); 00831 int idxElementPos = 0; 00832 int idxElementPos2 = 0; 00833 int idxElementConnection = 0; 00834 int iOffsetSlice = m_vGridResolution[1] * m_vGridResolution[0] * 4; 00835 int iOffsetRow = m_vGridResolution[0] * 4; 00836 int iOffsetCol = 4; 00837 //------------------------------------------------------------------ 00838 glBegin( GL_LINES ); 00839 for ( int Z = 0; Z < m_vGridResolution[2]; ++Z ) { 00840 for ( int Y = 0; Y < m_vGridResolution[1]; ++Y ) { 00841 for ( int X = 0; X < m_vGridResolution[0]; ++X ) { 00842 //if ( m_glfpElementPos[idxElementPos + 3] < 450 ) { // Skip all except an inside element 00843 if ( m_tpElementPos[idxElementPos + 3] < 250 ) { // Skip a void element 00844 idxElementConnection += m_iElementMaxValence; // Next element index 00845 } 00846 else { 00847 for ( int i = 0; i < m_iElementMaxValence; ++i ) { 00848 if ( m_ipElementConnect[idxElementConnection] != 0 ) { 00849 idxElementPos2 = idxElementPos + m_ipElementConnect[idxElementConnection]; 00850 glVertex3f( 00851 m_tpElementPos[idxElementPos ], 00852 m_tpElementPos[idxElementPos + 1], 00853 m_tpElementPos[idxElementPos + 2] 00854 ); 00855 glVertex3f( 00856 m_tpElementPos[idxElementPos2 ], 00857 m_tpElementPos[idxElementPos2 + 1], 00858 m_tpElementPos[idxElementPos2 + 2] 00859 ); 00860 } 00861 ++idxElementConnection; 00862 } 00863 } 00864 idxElementPos += 4; 00865 } 00866 } 00867 } 00868 glEnd(); 00869 glPopAttrib(); 00870 }
| void ModelDeformableCPU< T >::DrawByGL_As2DTexture | ( | ) | [inline, protected, virtual] |
Definition at line 1013 of file TAPsModelDeformableCPU.cpp.
01014 { 01015 Vector3<T> vAABBMinPt = GetBoundingAABBLowPoint(); 01016 Vector3<T> vAABBMaxPt = GetBoundingAABBHighPoint(); 01017 //--------------------------------------------------------------- 01018 if ( m_tpElementPos ) { 01019 glPushAttrib( GL_POINT_BIT | GL_LIGHTING_BIT | GL_CURRENT_BIT ); 01020 glPointSize( 7 ); 01021 float r = (float)rand()/(float)(RAND_MAX+1); 01022 float g = (float)rand()/(float)(RAND_MAX+1); 01023 float b = (float)rand()/(float)(RAND_MAX+1); 01024 glColor3f( r, g, b ); 01025 glDisable( GL_LIGHTING ); 01026 glBegin( GL_POINTS ); 01027 glVertex3f( 0, 0, 0 ); 01028 glEnd(); 01029 glPopAttrib(); 01030 } 01031 }
| void ModelDeformableCPU< T >::DrawByGL_As3DTexture | ( | ) | [inline, protected, virtual] |
Definition at line 1034 of file TAPsModelDeformableCPU.cpp.
01035 { 01036 //--------------------------------------------------------------- 01037 if ( m_tpElementPos ) { 01038 glPushAttrib( GL_POINT_BIT | GL_LIGHTING_BIT | GL_CURRENT_BIT ); 01039 glPointSize( 7 ); 01040 float r = (float)rand()/(float)(RAND_MAX+1); 01041 float g = (float)rand()/(float)(RAND_MAX+1); 01042 float b = (float)rand()/(float)(RAND_MAX+1); 01043 glColor3f( r, g, b ); 01044 glDisable( GL_LIGHTING ); 01045 glBegin( GL_POINTS ); 01046 glVertex3f( 0, 0, 0 ); 01047 glEnd(); 01048 glPopAttrib(); 01049 } 01050 }
| void ModelDeformableCPU< T >::DrawByGL_PositionTexture | ( | ) | [inline, protected, virtual] |
Definition at line 1053 of file TAPsModelDeformableCPU.cpp.
01054 { 01055 //--------------------------------------------------------------- 01056 if ( m_tpElementPos ) { 01057 glPushAttrib( GL_POINT_BIT | GL_LIGHTING_BIT | GL_CURRENT_BIT ); 01058 glPointSize( 7 ); 01059 float r = (float)rand()/(float)(RAND_MAX+1); 01060 float g = (float)rand()/(float)(RAND_MAX+1); 01061 float b = (float)rand()/(float)(RAND_MAX+1); 01062 glColor3f( r, g, b ); 01063 glDisable( GL_LIGHTING ); 01064 glBegin( GL_POINTS ); 01065 glVertex3f( 0, 0, 0 ); 01066 glEnd(); 01067 glPopAttrib(); 01068 } 01069 }
| void ModelDeformableCPU< T >::DrawGL | ( | GLenum | eDrawMode | ) | [inline, virtual] |
Implements OpenGLSupport.
Definition at line 697 of file TAPsModelDeformableCPU.cpp.
00698 { 00699 //--------------------------------------------------------------- 00700 if ( m_tpElementPos ) { 00701 glPushAttrib( GL_POINT_BIT | GL_LIGHTING_BIT | GL_CURRENT_BIT ); 00702 glPointSize( 7 ); 00703 float r = (float)rand()/(float)(RAND_MAX+1); 00704 float g = (float)rand()/(float)(RAND_MAX+1); 00705 float b = (float)rand()/(float)(RAND_MAX+1); 00706 glColor3f( r, g, b ); 00707 glDisable( GL_LIGHTING ); 00708 glBegin( GL_POINTS ); 00709 glVertex3f( 0, 0, 0 ); 00710 glEnd(); 00711 glPopAttrib(); 00712 } 00713 }
| Vector3<T> ModelDeformableCPU< T >::GetGridDimension | ( | ) | const [inline] |
| T ModelDeformableCPU< T >::GetGridElementVolume | ( | ) | const [inline] |
| Vector3<int> ModelDeformableCPU< T >::GetGridResolution | ( | ) | const [inline] |
| T ModelDeformableCPU< T >::GetMaxHalfLength | ( | ) | const [inline, virtual] |
Implements Model< T >.
Definition at line 553 of file TAPsModelDeformableCPU.cpp.
00554 { 00555 T maxHalfSize = 0.0; 00556 // for ( int i = 0; i < m_iNoVertices; ++i ) 00557 // { 00558 // } 00559 return maxHalfSize; 00560 }
| GLuint ModelDeformableCPU< T >::GetRTGenMesh_3DTexture | ( | ) | [inline] |
Get 3D Texture
Definition at line 362 of file TAPsModelDeformableCPU.hpp.
00362 { 00363 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_RT_GEN_MESH 00364 if ( m_Visualization_RTGenMesh ) { 00365 return m_Visualization_RTGenMesh->Get3DTexture(); 00366 } 00367 #else 00368 return 0; 00369 #endif 00370 }
| T ModelDeformableCPU< T >::GetRTGenMesh_MCGlobalInterpolationValue | ( | ) | const [inline] |
Get Marching cube interpolation value of the visualization by real-time generated mesh. The return value is in range [0-1] if the visualization by real-time generated mesh is enabled, else the return value is -1.
Definition at line 287 of file TAPsModelDeformableCPU.hpp.
00287 { 00288 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_RT_GEN_MESH 00289 if ( m_Visualization_RTGenMesh ) { 00290 return m_Visualization_RTGenMesh->GetGlobalInterpolationValue(); 00291 } 00292 #endif 00293 return -1; 00294 }
| bool ModelDeformableCPU< T >::GetRTGenMesh_MCUseGlobalInterpolationValue | ( | ) | const [inline] |
Definition at line 266 of file TAPsModelDeformableCPU.hpp.
00266 { 00267 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_RT_GEN_MESH 00268 if ( m_Visualization_RTGenMesh ) { 00269 return m_Visualization_RTGenMesh->GetUseGlobalInterpolationValue(); 00270 } 00271 #endif 00272 return false; 00273 }
| int ModelDeformableCPU< T >::GetRTGenMesh_PNTriangleSmoothness | ( | ) | const [inline] |
Get PN-Triangle Smoothness.
Definition at line 331 of file TAPsModelDeformableCPU.hpp.
00331 { 00332 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_RT_GEN_MESH 00333 if ( m_Visualization_RTGenMesh ) { 00334 return m_Visualization_RTGenMesh->GetPNTriangleSmoothness(); 00335 } 00336 #endif 00337 return -1; 00338 }
| bool ModelDeformableCPU< T >::GetRTGenMesh_StatusDrawnWithPNTriangle | ( | ) | const [inline] |
Get status drawn with PN-Triangles.
Definition at line 310 of file TAPsModelDeformableCPU.hpp.
00310 { 00311 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_RT_GEN_MESH 00312 if ( m_Visualization_RTGenMesh ) { 00313 return m_Visualization_RTGenMesh->GetStatusDrawnWithPNTriangle(); 00314 } 00315 #endif 00316 return false; 00317 }
| T ModelDeformableCPU< T >::GetSpringRestLength | ( | enum SpringProp::CONNECT | springSelection | ) | [inline] |
Definition at line 909 of file TAPsModelDeformableCPU.hpp.
00910 { return SPRING_PROP.REST_LENGTH[ springSelection ]; }
| T ModelDeformableCPU< T >::GetSpringStiffness | ( | enum SpringProp::CONNECT | springSelection | ) | [inline] |
Definition at line 911 of file TAPsModelDeformableCPU.hpp.
00912 { return SPRING_PROP.STIFFNESS[ springSelection ]; }
| void ModelDeformableCPU< T >::GetTheClosestElementToThePosition | ( | Vector3< T > const & | position, | |
| int & | x, | |||
| int & | y, | |||
| int & | z, | |||
| T | closestDistance | |||
| ) | [inline] |
Definition at line 455 of file TAPsModelDeformableCPU.hpp.
00456 { 00457 int iElementNo = 0; 00458 T tDistance; 00459 closestDistance = (m_tpElementPos[0] - position).Length(); 00460 Vector3<int> closetPt( 0, 0, 0 ); 00461 for ( int k = 0; k < m_vGridResolution[2]; ++k ) { 00462 for ( int j = 0; j < m_vGridResolution[1]; ++j ) { 00463 for ( int i = 0; i < m_vGridResolution[0]; ++i ) { 00464 tDistance = (m_tpElementPos[ iElementNo ] - position).Length(); 00465 if ( closestDistance > tDistance ) { 00466 closestDistance = tDistance; 00467 x = i; 00468 y = j; 00469 z = k; 00470 } 00471 ++iElementNo; 00472 } 00473 } 00474 } 00475 }
| int ModelDeformableCPU< T >::GetTotalGridElements | ( | ) | const [inline] |
| std::string ModelDeformableCPU< T >::Info | ( | ) | const [inline, virtual] |
Definition at line 1192 of file TAPsModelDeformableCPU.cpp.
01193 { 01194 const int maxNumConnections = 26; 01195 std::string strInfo; 01196 //--------------------------------- 01197 strInfo += "Rest Length Stiffness Damper Distance Limit\n"; 01198 //================================= 01199 strInfo += "-----------\n"; 01200 strInfo += "FRONT GROUP:\n"; 01201 strInfo += "-----------"; 01202 //------------- 01203 strInfo += "\n FrontNorthWest: "; 01204 InfoConnectionProperties( strInfo, SpringProp::CONNECT::FRONT_NORTH_WEST, maxNumConnections ); 01205 strInfo += "\n FrontNorth: "; 01206 InfoConnectionProperties( strInfo, SpringProp::CONNECT::FRONT_NORTH, maxNumConnections ); 01207 strInfo += "\n FrontNorthEast: "; 01208 InfoConnectionProperties( strInfo, SpringProp::CONNECT::FRONT_NORTH_EAST, maxNumConnections ); 01209 //------------- 01210 strInfo += "\n FrontWest: "; 01211 InfoConnectionProperties( strInfo, SpringProp::CONNECT::FRONT_WEST, maxNumConnections ); 01212 strInfo += "\n Front: "; 01213 InfoConnectionProperties( strInfo, SpringProp::CONNECT::FRONT, maxNumConnections ); 01214 strInfo += "\n FrontEast: "; 01215 InfoConnectionProperties( strInfo, SpringProp::CONNECT::FRONT_EAST, maxNumConnections ); 01216 //------------- 01217 strInfo += "\n FrontSouthWest: "; 01218 InfoConnectionProperties( strInfo, SpringProp::CONNECT::FRONT_SOUTH_WEST, maxNumConnections ); 01219 strInfo += "\n FrontSouth: "; 01220 InfoConnectionProperties( strInfo, SpringProp::CONNECT::FRONT_SOUTH, maxNumConnections ); 01221 strInfo += "\n FrontSouthEast: "; 01222 InfoConnectionProperties( strInfo, SpringProp::CONNECT::FRONT_SOUTH_EAST, maxNumConnections ); 01223 //------------- 01224 strInfo += "\n"; 01225 //================================= 01226 strInfo += "------------\n"; 01227 strInfo += "CENTER GROUP:\n"; 01228 strInfo += "------------"; 01229 //------------- 01230 strInfo += "\n NorthWest: "; 01231 InfoConnectionProperties( strInfo, SpringProp::CONNECT::NORTH_WEST, maxNumConnections ); 01232 strInfo += "\n North: "; 01233 InfoConnectionProperties( strInfo, SpringProp::CONNECT::NORTH, maxNumConnections ); 01234 strInfo += "\n NorthEast: "; 01235 InfoConnectionProperties( strInfo, SpringProp::CONNECT::NORTH_EAST, maxNumConnections ); 01236 //------------- 01237 strInfo += "\n West: "; 01238 InfoConnectionProperties( strInfo, SpringProp::CONNECT::WEST, maxNumConnections ); 01239 strInfo += "\n East: "; 01240 InfoConnectionProperties( strInfo, SpringProp::CONNECT::EAST, maxNumConnections ); 01241 //------------- 01242 strInfo += "\n SouthWest: "; 01243 InfoConnectionProperties( strInfo, SpringProp::CONNECT::SOUTH_WEST, maxNumConnections ); 01244 strInfo += "\n South: "; 01245 InfoConnectionProperties( strInfo, SpringProp::CONNECT::SOUTH, maxNumConnections ); 01246 strInfo += "\n SouthEast: "; 01247 InfoConnectionProperties( strInfo, SpringProp::CONNECT::SOUTH_EAST, maxNumConnections ); 01248 //------------- 01249 strInfo += "\n"; 01250 //================================= 01251 strInfo += "----------\n"; 01252 strInfo += "BACK GROUP:\n"; 01253 strInfo += "----------"; 01254 //------------- 01255 strInfo += "\n BackNorthWest: "; 01256 InfoConnectionProperties( strInfo, SpringProp::CONNECT::BACK_NORTH_WEST, maxNumConnections ); 01257 strInfo += "\n BackNorth: "; 01258 InfoConnectionProperties( strInfo, SpringProp::CONNECT::BACK_NORTH, maxNumConnections ); 01259 strInfo += "\n BackNorthEast: "; 01260 InfoConnectionProperties( strInfo, SpringProp::CONNECT::BACK_NORTH_EAST, maxNumConnections ); 01261 //------------- 01262 strInfo += "\n BackWest: "; 01263 InfoConnectionProperties( strInfo, SpringProp::CONNECT::BACK_WEST, maxNumConnections ); 01264 strInfo += "\n Back: "; 01265 InfoConnectionProperties( strInfo, SpringProp::CONNECT::BACK, maxNumConnections ); 01266 strInfo += "\n BackEast: "; 01267 InfoConnectionProperties( strInfo, SpringProp::CONNECT::BACK_EAST, maxNumConnections ); 01268 //------------- 01269 strInfo += "\n BackSouthWest: "; 01270 InfoConnectionProperties( strInfo, SpringProp::CONNECT::BACK_SOUTH_WEST, maxNumConnections ); 01271 strInfo += "\n BackSouth: "; 01272 InfoConnectionProperties( strInfo, SpringProp::CONNECT::BACK_SOUTH, maxNumConnections ); 01273 strInfo += "\n BackSouthEast: "; 01274 InfoConnectionProperties( strInfo, SpringProp::CONNECT::BACK_SOUTH_EAST, maxNumConnections ); 01275 //------------- 01276 //strInfo += "\n"; 01277 //================================= 01278 return strInfo; 01279 }
| virtual void ModelDeformableCPU< T >::InfoConnectionProperties | ( | std::string & | addToStr, | |
| enum SpringProp::CONNECT | connect, | |||
| int | maxNumConnections = 26 | |||
| ) | const [inline, virtual] |
Definition at line 930 of file TAPsModelDeformableCPU.hpp.
00931 { 00932 char cStr[80]; 00933 if ( connect <= maxNumConnections ) { 00934 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 00935 sprintf( cStr, " %g, %g, %g", 00936 SPRING_PROP.REST_LENGTH[ connect ], 00937 SPRING_PROP.STIFFNESS[ connect ], 00938 SPRING_PROP.DAMPER[ connect ] 00939 ); 00940 #else // #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 00941 sprintf( cStr, " %g, %g", 00942 SPRING_PROP.REST_LENGTH[ connect ], 00943 SPRING_PROP.STIFFNESS[ connect ] 00944 ); 00945 #endif // #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 00946 addToStr += cStr; 00947 } 00948 }
| void ModelDeformableCPU< T >::InitConnectionConstants | ( | ) | [inline, protected] |
Helper Fn: Initialize connection index constants (offsets)
Definition at line 1282 of file TAPsModelDeformableCPU.cpp.
01283 { 01284 int iOffsetElement = 4; 01285 int iOffsetX = iOffsetElement; 01286 int iOffsetY = m_vGridResolution[0] * iOffsetElement; 01287 int iOffsetZ = m_vGridResolution[1] * iOffsetY; 01288 //--------- 01289 CONNECTION_INDEX[SpringProp::CONNECT::EAST] = iOffsetX; 01290 CONNECTION_INDEX[SpringProp::CONNECT::NORTH]= iOffsetY; 01291 CONNECTION_INDEX[SpringProp::CONNECT::WEST] = -iOffsetX; 01292 CONNECTION_INDEX[SpringProp::CONNECT::SOUTH]= -iOffsetY; 01293 //--------- 01294 CONNECTION_INDEX[SpringProp::CONNECT::FRONT]= iOffsetZ; 01295 //--------- 01296 CONNECTION_INDEX[SpringProp::CONNECT::BACK] = -iOffsetZ; 01297 //--------- 01298 CONNECTION_INDEX[SpringProp::CONNECT::NORTH_EAST] = iOffsetY + iOffsetX; 01299 CONNECTION_INDEX[SpringProp::CONNECT::NORTH_WEST] = iOffsetY - iOffsetX; 01300 CONNECTION_INDEX[SpringProp::CONNECT::SOUTH_WEST] = -iOffsetY - iOffsetX; 01301 CONNECTION_INDEX[SpringProp::CONNECT::SOUTH_EAST] = -iOffsetY + iOffsetX; 01302 //--------- 01303 CONNECTION_INDEX[SpringProp::CONNECT::FRONT_EAST] = iOffsetZ + iOffsetX; 01304 CONNECTION_INDEX[SpringProp::CONNECT::FRONT_NORTH] = iOffsetZ + iOffsetY; 01305 CONNECTION_INDEX[SpringProp::CONNECT::FRONT_WEST] = iOffsetZ - iOffsetX; 01306 CONNECTION_INDEX[SpringProp::CONNECT::FRONT_SOUTH] = iOffsetZ - iOffsetY; 01307 //--------- 01308 CONNECTION_INDEX[SpringProp::CONNECT::BACK_EAST] = -iOffsetZ + iOffsetX; 01309 CONNECTION_INDEX[SpringProp::CONNECT::BACK_NORTH] = -iOffsetZ + iOffsetY; 01310 CONNECTION_INDEX[SpringProp::CONNECT::BACK_WEST] = -iOffsetZ - iOffsetX; 01311 CONNECTION_INDEX[SpringProp::CONNECT::BACK_SOUTH] = -iOffsetZ - iOffsetY; 01312 //--------- 01313 CONNECTION_INDEX[SpringProp::CONNECT::FRONT_NORTH_EAST] = iOffsetZ + iOffsetY + iOffsetX; 01314 CONNECTION_INDEX[SpringProp::CONNECT::FRONT_NORTH_WEST] = iOffsetZ + iOffsetY - iOffsetX; 01315 CONNECTION_INDEX[SpringProp::CONNECT::FRONT_SOUTH_WEST] = iOffsetZ - iOffsetY - iOffsetX; 01316 CONNECTION_INDEX[SpringProp::CONNECT::FRONT_SOUTH_EAST] = iOffsetZ - iOffsetY + iOffsetX; 01317 //--------- 01318 CONNECTION_INDEX[SpringProp::CONNECT::BACK_NORTH_EAST] = -iOffsetZ + iOffsetY + iOffsetX; 01319 CONNECTION_INDEX[SpringProp::CONNECT::BACK_NORTH_WEST] = -iOffsetZ + iOffsetY - iOffsetX; 01320 CONNECTION_INDEX[SpringProp::CONNECT::BACK_SOUTH_WEST] = -iOffsetZ - iOffsetY - iOffsetX; 01321 CONNECTION_INDEX[SpringProp::CONNECT::BACK_SOUTH_EAST] = -iOffsetZ - iOffsetY + iOffsetX; 01322 //--------- 01323 CONNECTION_INDEX[SpringProp::CONNECT::NOT_CONNECTED] = 0; 01324 //--------------------------------------------------------------- 01325 01326 #ifdef TAPs_DEBUG_MODE 01327 std::cout << "CONNECTION_INDEX[i]" << "\n"; 01328 for ( int i = 0; i < 27; ++i ) { 01329 std::cout << "\t" << CONNECTION_INDEX[i] << "\n"; 01330 } 01331 #endif//TAPs_DEBUG_MODE 01332 01333 }
| virtual void ModelDeformableCPU< T >::Initialize | ( | ) | [inline, virtual] |
| int ModelDeformableCPU< T >::InitializeFromGridGeneratorDataFloat | ( | GridGenerator< T > * | pGridGenerator | ) | [inline, virtual] |
Definition at line 338 of file TAPsModelDeformableCPU.cpp.
00343 { 00344 int iElementSpaceDimension = 4; // XYZ + scalar 00345 //int iElementSpaceDimension = 3; // XYZ 00346 //int iElementSpaceDimension = 2; // XY 00347 //--------------------------------------------------------------- 00348 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VERLET_INTEGRATION 00349 if ( m_tpElementPosPrev != NULL ) return -100;//return false; 00350 #endif 00351 if ( m_tpElementPos != NULL ) return -100;//return false; 00352 if ( m_tpElementPosNext != NULL ) return -200;//return false; 00353 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 00354 if ( m_tpElementVel != NULL ) return -600;//return false; 00355 if ( m_tpElementVelNext != NULL ) return -700;//return false; 00356 #endif 00357 //------------------------------------------- 00358 if ( !pGridGenerator ) return -800;//return false; 00359 //------------------------------------------- 00360 if ( !pGridGenerator->IsGridGenerated() ) return -900;//return false; 00361 //------------------------------------------- 00362 m_vGridResolution.SetXYZ( pGridGenerator->GetGridSizeX(), 00363 pGridGenerator->GetGridSizeY(), 00364 pGridGenerator->GetGridSizeZ() ); 00365 m_vGridDimension.SetXYZ( pGridGenerator->GetGridDimensionX(), 00366 pGridGenerator->GetGridDimensionY(), 00367 pGridGenerator->GetGridDimensionZ() ); 00368 m_iTotalElements = m_vGridResolution[2] * m_vGridResolution[1] * m_vGridResolution[0]; 00369 m_fElementVolume = m_vGridDimension[2] * m_vGridDimension[1] * m_vGridDimension[0]; 00370 //--------------------------------------------------------------- 00371 // Set Mass Point Properties 00372 //m_tMass = 1 / m_iTotalElements; 00373 //--------------------------------------------------------------- 00374 // Set Spring Lengths 00375 SPRING_PROP.SetValueForAllSpringLengths( m_vGridDimension[0], m_vGridDimension[1], m_vGridDimension[2] ); 00376 00377 //--------------------------------------------------------------- 00378 // DEBUG 00379 //#ifdef TAPs_DEBUG_MODE 00380 //SPRING_PROP.PrintOut(); 00381 //#endif 00382 //--------------------------------------------------------------- 00383 int iMemorySizeForTotalElements = m_iTotalElements * iElementSpaceDimension; 00384 //--------------------------------------------------------------- 00385 // Element Positions 00386 T **** ptElementPosition = pGridGenerator->ReturnPtrToVertexPositionData(); // XYZ in 4D Array 00387 GridGenerator<T>::VertexFlag *** pcElementFlag = 00388 pGridGenerator->ReturnPtrToVertexFlagData(); // Enum in 3D Array 00389 //------------------------------------------------------------------------- 00390 /* 00391 // Position is XYZ only 00392 if ( iElementSpaceDimension == 3 ) { 00393 T * vertexData = new T[ iMemorySizeForTotalElements ]; // XYZ in 1D Array 00394 int m = 0; // XYZ Counter 00395 //--------------------------------------------------------------- 00396 // Data from pGridGenerator is arrenged in x, y, and z order. 00397 // To switch it to z, y, and x order for ordering planes in z-direction. 00398 for ( int k = 0; k < m_vGridResolution[2]; ++k ) { 00399 for ( int j = 0; j < m_vGridResolution[1]; ++j ) { 00400 for ( int i = 0; i < m_vGridResolution[0]; ++i ) { 00401 vertexData[m ] = ptElementPosition[i][j][k][0]; 00402 vertexData[m+1] = ptElementPosition[i][j][k][1]; 00403 vertexData[m+2] = ptElementPosition[i][j][k][2]; 00404 //--------------------------------------------- 00405 m += iElementSpaceDimension; 00406 } 00407 } 00408 } 00409 m_tpElementPos = vertexData; 00410 } 00411 //*/ 00412 //------------------------------------------------------------------------- 00413 // Position XYZ with Flag indicating void or occupied 00414 /*else*/ if ( iElementSpaceDimension == 4 ) { 00415 T * vertexData = new T[ iMemorySizeForTotalElements ]; // XYZ & Flag in 1D Array 00416 int m = 0; // XYZ & Flag Counter 00417 //--------------------------------------------------------------- 00418 // Data from pGridGenerator is arrenged in x, y, and z order. 00419 // To switch it to z, y, and x order for ordering planes in z-direction. 00420 for ( int k = 0; k < m_vGridResolution[2]; ++k ) { 00421 for ( int j = 0; j < m_vGridResolution[1]; ++j ) { 00422 for ( int i = 0; i < m_vGridResolution[0]; ++i ) { 00423 vertexData[m ] = ptElementPosition[i][j][k][0]; 00424 vertexData[m+1] = ptElementPosition[i][j][k][1]; 00425 vertexData[m+2] = ptElementPosition[i][j][k][2]; 00426 //--------------------------------------------- 00427 if ( pcElementFlag[i][j][k] >= GridGenerator<T>::INSIDE_MODEL ) { 00428 vertexData[m+3] = 500.0; 00429 } 00430 else if ( pcElementFlag[i][j][k] >= GridGenerator<T>::RIGHT_INSIDE_BOUNDARY ) { 00431 vertexData[m+3] = 400.0; 00432 } 00433 else if ( pcElementFlag[i][j][k] >= GridGenerator<T>::ON_BOUNDARY ) { 00434 vertexData[m+3] = 300.0; 00435 } 00436 else if ( pcElementFlag[i][j][k] >= GridGenerator<T>::RIGHT_OUTSIDE_BOUNDARY ) { 00437 vertexData[m+3] = 200.0; 00438 } 00439 else if ( pcElementFlag[i][j][k] >= GridGenerator<T>::OUTSIDE_MODEL ) { 00440 vertexData[m+3] = 100.0; 00441 } 00442 else { 00443 vertexData[m+3] = 0.0; 00444 } 00445 m += iElementSpaceDimension; 00446 } 00447 } 00448 } 00449 m_tpElementPos = vertexData; 00450 } 00451 //--------------------------------------------------------------- 00452 // Allocate (positions and velocities) data 00453 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VERLET_INTEGRATION 00454 m_tpElementPosPrev = new T[ iMemorySizeForTotalElements ]; 00455 // Initialize previous positions with current positions 00456 for ( int i = 0; i < iMemorySizeForTotalElements; ++i ) { 00457 m_tpElementPosPrev[i] = m_tpElementPos[i]; 00458 } 00459 #endif 00460 m_tpElementPosNext = new T[ iMemorySizeForTotalElements ]; 00461 //* 00462 // DEBUG 00463 // Initialize previous positions with current positions 00464 for ( int i = 0; i < iMemorySizeForTotalElements; ++i ) { 00465 if ( i % 4 == 3 ) 00466 m_tpElementPosNext[i] = m_tpElementPos[i]; 00467 } 00468 //*/ 00469 #ifdef TAPs_MODEL_DEFORMABLE_CPU_EXPLICIT_EULER_INTEGRATION 00470 m_tpElementVel = new T[ iMemorySizeForTotalElements ]; 00471 m_tpElementVelNext = new T[ iMemorySizeForTotalElements ]; 00472 #endif 00473 //--------------------------------------------------------------- 00474 #ifdef TAPs_DEBUG_MODE 00475 #ifdef TAPs_USE_WXWIDGETS 00476 wxLogError( wxT( " w/ (CPU) Grid Size: %i, %i, %i" ), 00477 m_vGridResolution[0], m_vGridResolution[1], m_vGridResolution[2] ); 00478 #endif 00479 #endif 00480 //--------------------------------------------------------------- 00481 // Model Initialization 00482 CalAndSetNormals(); 00483 ApplyMaterial(); 00484 SetBoundingAABBLowPoint( pGridGenerator->GetAABBMinPt() ); 00485 SetBoundingAABBHighPoint( pGridGenerator->GetAABBMaxPt() ); 00486 //CalBoundingAABB(); 00487 //CalBoundingEllipsoid(); 00488 //CalBoundingSphere(); 00489 00490 //--------------------------------------------------------------- 00491 // For GLSL 00492 //* 00493 // m_glslProgramObject = m_glslShaderManager.LoadFromFile( 00494 // "Resource/Shader/brick.vert", 00495 // "Resource/Shader/brick.frag" 00496 // ); 00497 //*/ 00498 00499 /* 00500 m_glslProgramObject = m_glslShaderManager.LoadFromFile( 00501 "Resource/Shader/minimal.vert", 00502 "Resource/Shader/minimal.frag" 00503 ); 00504 //*/ 00505 00506 // if ( m_glslProgramObject == NULL ) return -1000;//return false; 00507 //--------------------------------------------------------------- 00508 00509 InitConnectionConstants(); 00510 CreateConnectionsFullOneRing(); 00511 00512 //=============================================================== 00513 // Setup Visualization 00514 //--------------------------------------------------------------- 00515 int errCode = SetupVisualization( pcElementFlag ); 00516 if ( errCode < 0 ) { 00517 Clear(); 00518 return -1000 + errCode;//return false; 00519 } 00520 //--------------------------------------------------------------- 00521 //=============================================================== 00522 00523 return 0;//return true; 00524 }
| bool ModelDeformableCPU< T >::IsVisualizedByRTGenMesh | ( | ) | [inline] |
Definition at line 180 of file TAPsModelDeformableCPU.hpp.
00180 { 00181 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_RT_GEN_MESH 00182 return true; 00183 #else 00184 return false; 00185 #endif 00186 }
| bool ModelDeformableCPU< T >::IsVisualizedByRTGenMeshAvailable | ( | ) | const [inline] |
Definition at line 232 of file TAPsModelDeformableCPU.hpp.
00232 { 00233 #ifdef TAPs_MODEL_DEFORMABLE_GLSL_VISUALIZATION_RT_GEN_MESH 00234 if ( m_Visualization_RTGenMesh ) return true; 00235 #endif 00236 return false; 00237 }
| void ModelDeformableCPU< T >::RemoveElementConnection | ( | int | iElementID, | |
| int | iConnection | |||
| ) | [protected] |
Simulation Fn: Void (remove) an element (make element empty)
| Vector3<T> const& ModelDeformableCPU< T >::RetGridDimension | ( | ) | const [inline] |
| Vector3<int> const& ModelDeformableCPU< T >::RetGridResolution | ( | ) | const [inline] |
| T* const ModelDeformableCPU< T >::ReturnPositionPointer | ( | ) | [inline] |
Definition at line 443 of file TAPsModelDeformableCPU.hpp.
00443 { 00444 return m_tpElementPos; 00445 }
| ModelDeformableCPU_Visualization_RTGenMesh<T>* const ModelDeformableCPU< T >::RetVisualRTGenMesh | ( | ) | [inline] |
Definition at line 391 of file TAPsModelDeformableCPU.hpp.
00392 { return m_Visualization_RTGenMesh; }
| void ModelDeformableCPU< T >::SetRTGenMesh_3DTexture | ( | GLuint | i | ) | [inline] |
Set 3D Texture
Definition at line 352 of file TAPsModelDeformableCPU.hpp.
00352 { 00353 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_RT_GEN_MESH 00354 if ( m_Visualization_RTGenMesh ) { 00355 m_Visualization_RTGenMesh->Set3DTexture( i ); 00356 } 00357 #endif 00358 }
| void ModelDeformableCPU< T >::SetRTGenMesh_MCGlobalInterpolationValue | ( | T | val | ) | [inline] |
Set Marching cube interpolation value of the visualization by real-time generated mesh. The setting value is clamped to be in range [0-1].
Definition at line 300 of file TAPsModelDeformableCPU.hpp.
00300 { 00301 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_RT_GEN_MESH 00302 if ( m_Visualization_RTGenMesh ) { 00303 m_Visualization_RTGenMesh->SetGlobalInterpolationValue( val ); 00304 } 00305 #endif 00306 }
| void ModelDeformableCPU< T >::SetRTGenMesh_MCUseGlobalInterpolationValue | ( | bool | b | ) | [inline] |
Definition at line 274 of file TAPsModelDeformableCPU.hpp.
00274 { 00275 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_RT_GEN_MESH 00276 if ( m_Visualization_RTGenMesh ) { 00277 m_Visualization_RTGenMesh->SetUseGlobalInterpolationValue( b ); 00278 } 00279 #endif 00280 }
| void ModelDeformableCPU< T >::SetRTGenMesh_PNTriangleSmoothness | ( | int | i | ) | [inline] |
Set PN-triangle Smoothness.
Definition at line 342 of file TAPsModelDeformableCPU.hpp.
00342 { 00343 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_RT_GEN_MESH 00344 if ( m_Visualization_RTGenMesh ) { 00345 m_Visualization_RTGenMesh->SetPNTriangleSmoothness( i ); 00346 } 00347 #endif 00348 }
| void ModelDeformableCPU< T >::SetRTGenMesh_StatusDrawnWithPNTriangle | ( | bool | b | ) | [inline] |
Get status drawn with PN-Triangles.
Definition at line 321 of file TAPsModelDeformableCPU.hpp.
00321 { 00322 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_RT_GEN_MESH 00323 if ( m_Visualization_RTGenMesh ) { 00324 m_Visualization_RTGenMesh->SetStatusDrawnWithPNTriangle( b ); 00325 } 00326 #endif 00327 }
| void ModelDeformableCPU< T >::SetSpringRestLength | ( | enum SpringProp::CONNECT | springSelection, | |
| T | val | |||
| ) | [inline] |
Definition at line 913 of file TAPsModelDeformableCPU.hpp.
00914 { SPRING_PROP.REST_LENGTH[ springSelection ] = val; }
| void ModelDeformableCPU< T >::SetSpringStiffness | ( | enum SpringProp::CONNECT | springSelection, | |
| T | val | |||
| ) | [inline] |
Definition at line 915 of file TAPsModelDeformableCPU.hpp.
00916 { SPRING_PROP.STIFFNESS[ springSelection ] = val; }
| int ModelDeformableCPU< T >::SetupVisualization | ( | enum GridGenerator< T >::VertexFlag *** | pFlagDataForXYZVoxels | ) | [inline, protected] |
Definition at line 223 of file TAPsModelDeformableCPU.cpp.
00226 { 00228 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_RT_GEN_MESH 00229 //=============================================================== 00230 // Setup visualization by real-time generated mesh 00231 //--------------------------------------------------------------- 00232 m_Visualization_RTGenMesh = new ModelDeformableCPU_Visualization_RTGenMesh<T>( this ); 00233 if ( !m_Visualization_RTGenMesh ) { 00234 #ifdef TAPs_USE_WXWIDGETS 00235 wxLogError( wxT( "ERROR: ModelDeformableGLSL --> Cannot create a real-time generated mesh for visualization of size (%i, %i, %i)!" ), 00236 m_vGridResolution[0], m_vGridResolution[1], m_vGridResolution[2] ); 00237 #else 00238 std::cerr << "ERROR: ModelDeformableGLSL --> Cannot create a real-time generated mesh for visualization of size (" 00239 << m_vGridResolution[0] << ", " << m_vGridResolution[1] << ", " << m_vGridResolution[2] 00240 << ")!" << std::endl; 00241 #endif 00242 return -1;//return false; 00243 } 00244 00245 //std::cout << "AFTER new m_Visualization_RTGenMesh" << std::endl; 00246 00247 if ( !m_Visualization_RTGenMesh->SetupVisualization( 00248 m_vGridResolution[0], m_vGridResolution[1], m_vGridResolution[2], 00249 pFlagDataForXYZVoxels ) ) 00250 { 00251 #ifdef TAPs_USE_WXWIDGETS 00252 wxLogError( wxT( "ERROR: ModelDeformableGLSL::SetupVisualization Fn --> Cannot a real-time generated mesh for visualization of size (%i, %i, %i)!" ), 00253 m_vGridResolution[0], m_vGridResolution[1], m_vGridResolution[2] ); 00254 #else 00255 std::cerr << "ERROR: ModelDeformableGLSL::SetupVisualization Fn --> Cannot create a real-time generated mesh for visualization of size (" 00256 << m_vGridResolution[0] << ", " << m_vGridResolution[1] << ", " << m_vGridResolution[2] 00257 << ")!" << std::endl; 00258 #endif 00259 return -2;//return false; 00260 } 00261 00262 //std::cout << "AFTER m_Visualization_RTGenMesh->SetupVisualization()" << std::endl; 00263 00264 //--------------------------------------------------------------- 00265 //=============================================================== 00266 #endif 00268 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_3D_TEXTURE 00269 //=============================================================== 00270 // Setup a 3D Texture (for Visualization) 00271 //--------------------------------------------------------------- 00272 //m_Visualization_3DTexture = new ModelDeformableGLSL_Visualization_3DTexture<T>( this ); 00273 //if ( !m_Visualization_3DTexture ) { 00274 // #ifdef TAPs_USE_WXWIDGETS 00275 // wxLogError( wxT( "ERROR: ModelDeformableGLSL --> Cannot create 3D texture visualization of size (%i, %i, %i)!" ), 00276 // m_vGridResolution[0], m_vGridResolution[1], m_vGridResolution[2] ); 00277 // #else 00278 // std::cerr << "ERROR: ModelDeformableGLSL --> Cannot create 3D texture visualization of size (" 00279 // << m_vGridResolution[0] << ", " << m_vGridResolution[1] << ", " << m_vGridResolution[2] 00280 // << ")!" << std::endl; 00281 // #endif 00282 // return -3;//return false; 00283 //} 00284 00285 //std::cout << "AFTER new m_Visualization_3DTexture" << std::endl; 00286 00287 //if ( !m_Visualization_3DTexture->SetupVisualization( 00288 // m_vGridResolution[0], m_vGridResolution[1], m_vGridResolution[2], 00289 // pFlagDataForXYZVoxels ) ) 00290 //{ 00291 // #ifdef TAPs_USE_WXWIDGETS 00292 // wxLogError( wxT( "ERROR: ModelDeformableGLSL::SetupVisualization Fn --> Cannot create 3D texture of size (%i, %i, %i)!" ), 00293 // m_vGridResolution[0], m_vGridResolution[1], m_vGridResolution[2] ); 00294 // #else 00295 // std::cerr << "ERROR: ModelDeformableGLSL::SetupVisualization Fn --> Cannot create 3D texture of size (" 00296 // << m_vGridResolution[0] << ", " << m_vGridResolution[1] << ", " << m_vGridResolution[2] 00297 // << ")!" << std::endl; 00298 // #endif 00299 // return -4;//return false; 00300 //} 00301 00302 //std::cout << "AFTER m_Visualization_3DTexture->SetupVisualization()" << std::endl; 00303 00304 //--------------------------------------------------------------- 00305 //=============================================================== 00306 #endif 00307 00308 00309 //*/ 00310 // DEBUG 00311 //m_Visualization_RTGenMesh->Set3DTexture( m_Visualization_3DTexture->Get3DTextureVisualization() ); 00312 //*/ 00313 00314 00316 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_RAY_CASTING 00317 //=============================================================== 00318 //--------------------------------------------------------------- 00319 //--------------------------------------------------------------- 00320 //=============================================================== 00321 #endif 00323 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_MESH 00324 //=============================================================== 00325 //--------------------------------------------------------------- 00326 //--------------------------------------------------------------- 00327 //=============================================================== 00328 #endif 00330 //--------------------------------------------------------------- 00331 //=============================================================== 00332 //--------------------------------------------------------------- 00333 return true; 00334 }
| int ModelDeformableCPU< T >::TranslateElementNumber | ( | int | x, | |
| int | y, | |||
| int | z | |||
| ) | [inline, protected] |
Definition at line 484 of file TAPsModelDeformableCPU.hpp.
00484 { 00485 assert( 0 <= x && x < m_vGridResolution[0] ); 00486 assert( 0 <= y && y < m_vGridResolution[1] ); 00487 assert( 0 <= z && z < m_vGridResolution[2] ); 00488 return (z * m_vGridResolution[1] + y) * m_vGridResolution[0] + x; 00489 }
| void ModelDeformableCPU< T >::Visualize | ( | DrawType | drawType = ALL_ELEMENTS |
) | [inline, virtual] |
Definition at line 947 of file TAPsModelDeformableCPU.cpp.
00948 { 00949 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_RT_GEN_MESH 00950 VisualizeByRTGenMesh( drawType ); 00951 #endif 00952 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_3D_TEXTURE 00953 VisualizeBy3DTexture( drawType ); 00954 #endif 00955 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_RAY_CASTING 00956 VisualizeByRayCasting( drawType ); 00957 #endif 00958 #ifdef TAPs_MODEL_DEFORMABLE_CPU_VISUALIZATION_MESH 00959 VisualizeByMesh( drawType ); 00960 #endif 00961 }
| void ModelDeformableCPU< T >::VisualizeByRTGenMesh | ( | DrawType | drawType | ) | [inline, virtual] |
Definition at line 965 of file TAPsModelDeformableCPU.cpp.
00966 { 00967 //std::cout << "Start: VisualizeByRTGenMesh( drawType )" << std::endl; 00968 00969 if ( m_Visualization_RTGenMesh ) { 00970 00971 // std::cout << "Inside: VisualizeByRTGenMesh( drawType )" << std::endl; 00972 00973 m_Visualization_RTGenMesh->DrawByGL( 64 /* depth supersampling */ ); 00974 } 00975 00976 //std::cout << "End: VisualizeByRTGenMesh( drawType )" << std::endl; 00977 }
| void ModelDeformableCPU< T >::VoidAnElement | ( | int | iElementID | ) | [protected] |
Simulation Fn: Void (remove) an element (make element empty)
| std::ostream& operator<< | ( | std::ostream & | output, | |
| ModelDeformableCPU< T > const & | o | |||
| ) | [friend] |
Definition at line 125 of file TAPsModelDeformableCPU.hpp.
00126 { 00127 output << "\n=========================================================\n" 00128 << "TAPs::OpenGL::ModelDeformableCPU<" << typeid(T).name() << "> Class:\n" 00129 << "=========================================================\n"; 00130 //------------------------------------------------- 00131 output << o.Info(); 00132 output << "\n=========================================================\n"; 00133 //------------------------------------------------- 00134 return output; 00135 }
int ModelDeformableCPU< T >::CONNECTION_INDEX[27] [protected] |
Represented as Vertices (XYZF) x,y,z and flag:
F is 0.0 represents UNSET
F is 100.0 represents OUTSIDE_MODEL
F is 200.0 represents RIGHT_OUTSIDE_MODEL
F is 300.0 represents ON_BOUNDARY
F is 400.0 represents RIGHT_INSIDE_MODEL
F is 500.0 represents INSIDE_MODEL Element Status: i.e. fixed/unfixed Element Connectivities: up to 26 connections
*---*---* BACK | NW N NE / / /| *---*---* * CENTER | W C E / / /|/| *---*---* * * FRONT | SW S SE | | |/|/ *---*---* * e.g. BACK_C -> Back Center | | |/ *---*---* Total: 9 (front) + 8 (center) + 9 (back) = 26 Remark: Front is +Z and Back is -Z. Use Enum to Identify Connections. The Enum are from SpringPropertiesForDefModel<T> class. Treat as Constant Values for Connection Indexes 26 connections + 1 connection (for no connection, i.e. not connected)
Definition at line 865 of file TAPsModelDeformableCPU.hpp.
T ModelDeformableCPU< T >::m_fElementVolume [protected] |
Definition at line 809 of file TAPsModelDeformableCPU.hpp.
int ModelDeformableCPU< T >::m_iElementMaxValence [protected] |
Definition at line 875 of file TAPsModelDeformableCPU.hpp.
int* ModelDeformableCPU< T >::m_ipElementConnect [protected] |
Definition at line 872 of file TAPsModelDeformableCPU.hpp.
int* ModelDeformableCPU< T >::m_ipSurfaceBoundary [protected] |
Definition at line 895 of file TAPsModelDeformableCPU.hpp.
int ModelDeformableCPU< T >::m_iTotalElements [protected] |
Definition at line 808 of file TAPsModelDeformableCPU.hpp.
OpenGLUsefulObj< T > ModelDeformableCPU< T >::m_OGLUsefulObj [protected] |
Definition at line 814 of file TAPsModelDeformableCPU.hpp.
T ModelDeformableCPU< T >::m_tMass [protected] |
T* ModelDeformableCPU< T >::m_tpElementPos [protected] |
Definition at line 883 of file TAPsModelDeformableCPU.hpp.
T* ModelDeformableCPU< T >::m_tpElementPosNext [protected] |
Definition at line 889 of file TAPsModelDeformableCPU.hpp.
Vector3< T > ModelDeformableCPU< T >::m_vGridDimension [protected] |
Definition at line 806 of file TAPsModelDeformableCPU.hpp.
Vector3< int > ModelDeformableCPU< T >::m_vGridResolution [protected] |
Definition at line 804 of file TAPsModelDeformableCPU.hpp.
ModelDeformableCPU_Visualization_RTGenMesh<T>* ModelDeformableCPU< T >::m_Visualization_RTGenMesh [protected] |
Definition at line 389 of file TAPsModelDeformableCPU.hpp.
| SpringProp ModelDeformableCPU< T >::SPRING_PROP |
Definition at line 908 of file TAPsModelDeformableCPU.hpp.
1.5.6