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

Method UpdateTransform

trinity/Tr2PrimitiveSet.cpp:109–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109void Tr2PrimitiveSet::UpdateTransform( void )
110{
111 Matrix finalTransform;
112 Matrix scale_mat = IdentityMatrix();
113 Matrix view = Tr2Renderer::GetViewTransform();
114
115 if( m_scaleByDistanceToView )
116 {
117 // How much to scale the lineset based on the distance to the eye position
118 Vector3 viewPos = Tr2Renderer::GetViewPosition();
119 Vector3 lineSetPos = Vector3( m_localTransform._41, m_localTransform._42, m_localTransform._43 );
120 Vector3 normal = Vector3( view._13, view._23, view._33 );
121 Vector3 dir( viewPos - lineSetPos );
122 m_scale = fabs( Dot( dir, normal ) * g_primitiveDistanceScaleMultiplier * Tr2Renderer::GetFieldOfView() );
123 scale_mat = ScalingMatrix( m_scale, m_scale, m_scale );
124 finalTransform = scale_mat * m_localTransform;
125 }
126 else
127 {
128 m_scale = 1.0f;
129 }
130
131 if( m_viewOriented )
132 {
133 // The primitives need to be oriented in such a way
134 // as you were drawing on a x,y plane
135 Matrix rotation = IdentityMatrix();
136 rotation._11 = view._11;
137 rotation._12 = view._21;
138 rotation._13 = view._31;
139 rotation._21 = view._12;
140 rotation._22 = view._22;
141 rotation._23 = view._32;
142 rotation._31 = view._13;
143 rotation._32 = view._23;
144 rotation._33 = view._33;
145
146 // Need to scale the matrix before we translate it...
147 finalTransform = scale_mat * rotation;
148
149 finalTransform._41 = m_localTransform._41;
150 finalTransform._42 = m_localTransform._42;
151 finalTransform._43 = m_localTransform._43;
152 }
153 else
154 {
155 if( m_scaleByDistanceToView )
156 {
157 finalTransform = scale_mat * m_localTransform;
158 }
159 else
160 {
161 finalTransform = m_localTransform;
162 }
163 }
164
165 m_worldTransform = finalTransform;
166}

Callers 7

UpdateMethod · 0.45
PostPhysicsUpdateMethod · 0.45
UpdateMethod · 0.45
UpdateMethod · 0.45
ResetPrimitivesMethod · 0.45
RenderMethod · 0.45

Calls 5

GetViewTransformFunction · 0.85
GetViewPositionFunction · 0.85
GetFieldOfViewFunction · 0.85
Vector3Class · 0.70
DotFunction · 0.50

Tested by

no test coverage detected