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

Method DrawAudioSpeaker

trinity/Tr2DebugRenderer.cpp:974–1036  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

972}
973
974void Tr2DebugRenderer::DrawAudioSpeaker( Tr2DebugObjectReference owner, const Matrix& transform, float size, uint32_t segments, Effect effect, Tr2DebugColor color )
975{
976 if( segments < 3 )
977 {
978 segments = 3;
979 }
980
981 const float coneWidth = size * 0.3f;
982 const float coneHeight = size * 0.5f;
983 const float waveOffset = size * 0.6f;
984 const float waveSpacing = size * 0.2f;
985 const float halfConeHeight = coneHeight * 0.5f;
986 const float coneWidthNarrow = coneWidth * 0.3f;
987
988 const Vector2 coneVertices[] = {
989 Vector2( -halfConeHeight, coneWidthNarrow ), // Back narrow end
990 Vector2( -halfConeHeight, coneWidthNarrow ),
991 Vector2( halfConeHeight, coneWidth ), // Front wide end
992 Vector2( halfConeHeight, coneWidth )
993 };
994 const Vector2 coneNormals[] = {
995 Vector2( -1, 0 ), Vector2( -1, 0 ), Vector2( 0, 1 ), Vector2( 0, 1 )
996 };
997
998 DrawExtrusionShape( owner, transform, coneVertices, coneNormals, sizeof( coneVertices ) / sizeof( coneVertices[0] ), segments, effect, color );
999
1000 static const uint32_t MAX_WAVE_SEGMENTS = 32;
1001 uint32_t waveSegments = std::min( std::max( segments / 2, 8u ), MAX_WAVE_SEGMENTS );
1002
1003 static const float arcAngle = XM_PI * 0.6f; // 108 degrees total arc
1004 static const float halfArcAngle = arcAngle * 0.5f;
1005 const float arcStep = arcAngle / float( waveSegments );
1006
1007 const Vector3 waveBasePoint( halfConeHeight, 0, 0 );
1008 const Vector3 transformedWaveBase = Vector3( XMVector3TransformCoord( waveBasePoint, transform ) );
1009
1010 for( int wave = 0; wave < 3; ++wave )
1011 {
1012 float waveRadius = waveOffset + (float)wave * waveSpacing;
1013 Vector3 arcPoints[MAX_WAVE_SEGMENTS + 1];
1014 uint32_t arcCount = waveSegments + 1;
1015
1016 for( uint32_t i = 0; i < arcCount; ++i )
1017 {
1018 float angle = -halfArcAngle + (float)i * arcStep;
1019 float cosAngle = cos( angle );
1020 float sinAngle = sin( angle );
1021
1022 Vector3 localOffset(
1023 0,
1024 cosAngle * waveRadius,
1025 sinAngle * waveRadius );
1026
1027 Vector3 transformedOffset = Vector3( XMVector3TransformNormal( localOffset, transform ) );
1028 arcPoints[i] = transformedWaveBase + transformedOffset;
1029 }
1030
1031 for( uint32_t i = 0; i < waveSegments; ++i )

Callers 1

RenderDebugInfoMethod · 0.80

Calls 1

Vector3Class · 0.70

Tested by

no test coverage detected