diff options
author | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
---|---|---|
committer | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
commit | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Plugins/Visualization/vis_avs/matrix.cpp | |
parent | 537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff) | |
download | winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz |
Initial community commit
Diffstat (limited to 'Src/Plugins/Visualization/vis_avs/matrix.cpp')
-rw-r--r-- | Src/Plugins/Visualization/vis_avs/matrix.cpp | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/Src/Plugins/Visualization/vis_avs/matrix.cpp b/Src/Plugins/Visualization/vis_avs/matrix.cpp new file mode 100644 index 00000000..8b567f2a --- /dev/null +++ b/Src/Plugins/Visualization/vis_avs/matrix.cpp @@ -0,0 +1,74 @@ +/* + LICENSE + ------- +Copyright 2005 Nullsoft, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name of Nullsoft nor the names of its contributors may be used to + endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ +#include <windows.h> +#include <math.h> +#include "r_defs.h" + +void matrixRotate(float matrix[], char m, float Deg) { + char m1, m2; + float c,s; + Deg *= 3.141592653589f / 180.0f; + memset(matrix,0,sizeof(float)*16); + matrix[((m-1)<<2)+m-1] = matrix[15] = 1.0f; + m1 = (m % 3); + m2 = ((m1+1) % 3); + c = (float)cos(Deg); s = (float)sin(Deg); + matrix[(m1<<2)+m1]=c; matrix[(m1<<2)+m2]=s; + matrix[(m2<<2)+m2]=c; matrix[(m2<<2)+m1]=-s; +} + +void matrixTranslate(float m[], float x, float y, float z) { + memset(m,0,sizeof(float)*16); + m[0] = m[4+1] = m[8+2] = m[12+3] = 1.0f; + m[0+3] = x; m[4+3] = y; m[8+3] = z; +} + +void matrixMultiply(float *dest, float src[]) { + float temp[16]; + int i; + memcpy(temp,dest,sizeof(float)*16); + for (i = 0; i < 16; i += 4) { + *dest++ = src[i+0]*temp[(0<<2)+0]+src[i+1]*temp[(1<<2)+0]+ + src[i+2]*temp[(2<<2)+0]+src[i+3]*temp[(3<<2)+0]; + *dest++ = src[i+0]*temp[(0<<2)+1]+src[i+1]*temp[(1<<2)+1]+ + src[i+2]*temp[(2<<2)+1]+src[i+3]*temp[(3<<2)+1]; + *dest++ = src[i+0]*temp[(0<<2)+2]+src[i+1]*temp[(1<<2)+2]+ + src[i+2]*temp[(2<<2)+2]+src[i+3]*temp[(3<<2)+2]; + *dest++ = src[i+0]*temp[(0<<2)+3]+src[i+1]*temp[(1<<2)+3]+ + src[i+2]*temp[(2<<2)+3]+src[i+3]*temp[(3<<2)+3]; + } +} + +void matrixApply(float *m, float x, float y, float z, + float *outx, float *outy, float *outz) { + *outx = x*m[0] + y*m[1] + z*m[2] + m[3]; + *outy = x*m[4] + y*m[5] + z*m[6] + m[7]; + *outz = x*m[8] + y*m[9] + z*m[10] + m[11]; +} |