MCPcopy Create free account
hub / github.com/carbonengine/trinity / SetLocalTransform

Method SetLocalTransform

trinity/Eve/Turret/EveTurretSet.cpp:1805–1896  ·  view source on GitHub ↗

-------------------------------------------------------------------------------- Description: This sets up a turret on a ship to a give position. The total number of turrets in this set is dynamically changed here. Also allocate some animation related granny stuff, if we have the model already loaded. If we need to allocate new animation stuff, automatically play the idle anim, which puts new turr

Source from the content-addressed store, hash-verified

1803// localMatrix - position/orientation of single turret in object-space
1804// --------------------------------------------------------------------------------
1805void EveTurretSet::SetLocalTransform( unsigned int turretIndex, const Matrix* localMatrix )
1806{
1807 // should never be more than MAX_TURRETS_PER_SET
1808 if( turretIndex >= EVE_MAX_TURRETS_PER_SET )
1809 {
1810 return;
1811 }
1812
1813 if( IsUsingCMF( m_geometryResource ) )
1814 {
1815 // keep list up to size
1816 if( m_singleTurrets.size() <= turretIndex )
1817 {
1818 // fill up list with new entries for turrets to meet requirement
1819 for( unsigned int i = (unsigned int)m_singleTurrets.size(); i <= turretIndex; ++i )
1820 {
1821 SingleTurretData data;
1822 if( m_skeleton )
1823 {
1824 data.sequencer = std::make_unique<cmf::AnimationSequencer>( *m_skeleton );
1825 cmf::RestPose( data.pose, *m_skeleton );
1826 }
1827 else
1828 {
1829 data.sequencer.reset();
1830 data.pose.skeleton = NULL;
1831 data.pose.boneTransforms.clear();
1832 }
1833 data.worldMatrix = IdentityMatrix();
1834 data.valid = false;
1835 data.visible = false;
1836
1837 m_singleTurrets.push_back( std::move( data ) );
1838
1839 PlayAnimation( i, "", "Active" );
1840 }
1841 }
1842 }
1843#if WITH_GRANNY
1844 else
1845 {
1846 // keep list up to size
1847 if( m_singleTurrets.size() <= turretIndex )
1848 {
1849 // fill up list with new entries for turrets to meet requirement
1850 for( unsigned int i = (unsigned int)m_singleTurrets.size(); i <= turretIndex; ++i )
1851 {
1852 SingleTurretData data;
1853 if( m_grnModel )
1854 {
1855 data.grnModelInstance = GrannyInstantiateModel( m_grnModel );
1856 data.grnSkeleton = GrannyGetSourceSkeleton( data.grnModelInstance );
1857 data.grnLocalPose = GrannyNewLocalPose( data.grnSkeleton->BoneCount );
1858 data.grnWorldPose = GrannyNewWorldPose( data.grnSkeleton->BoneCount );
1859 }
1860 else
1861 {
1862 data.grnModelInstance = NULL;

Callers 2

UpdateSyncronousMethod · 0.80

Calls 8

IsUsingCMFFunction · 0.85
TriMatrixRemoveScalingFunction · 0.85
sizeMethod · 0.80
resetMethod · 0.80
UpdateInstanceMethod · 0.80
ifFunction · 0.50
Vector4Class · 0.50
Vector3Class · 0.50

Tested by

no test coverage detected