Message board for the users of flat assembler.
> Windows > Normal vectors generation from an arbitrary geometry
I am trying to write a code to calculate normal vectors from an arbitrary 3d model. Actually, I am a newbie in assembler and SIMD programming , so, I can't find the errors in the following piece of code:
v1 dd 1.0,1.0,0.0,0.0 v2 dd 1.0,0.0,0.0,0.0 v3 dd 0.0,1.0,0.0,0.0 movups xmm0,dqword [v1] movups xmm1,dqword [v2] movups xmm2,dqword [v3] subps xmm1,xmm0 ;xmm1: v1-v2 = A = Ax Ay Az Aw subps xmm2,xmm0 ;xmm2: v1-v3 = B = Bx By Bz Bw movups xmm0,xmm2 ;xmm0: B = Bx By Bz Bw shufps xmm0,xmm2,10011101b ;xmm0: By Bz Bx Bz shufps xmm1,xmm1,01100111b ;xmm1: Az Ay Az Ax mulps xmm0,xmm1 ;xmm0: [By*Az] [Bz*Ay] [Bx*Az] [Bz*Ax] shufps xmm1,xmm1,00000010b ;xmm1: Ax Ax Ax Ay shufps xmm2,xmm2,00011011b ;xmm2: Bw Bz By Bx mulps xmm1,xmm2 ;xmm1: [?] [?] [Ax*By] [Ay*Bx] movups xmm2,xmm0 ;xmm2: [By*Az] [Bz*Ay] [Bx*Az] [Bz*Ax] shufps xmm0,xmm1,00011101b ;xmm0: [Ay*Bx] [Ax*By] [By*Az] [Bx*Az] shufps xmm2,xmm1,00001000b ;xmm2: [Ay*Bx] [Ay*Bx] [Bz*Ay] [Bz*Ax] subps xmm2,xmm0 ;xmm2:  [Ax*By - Ay*Bx] [By*Az - Bz*Ay] [Bx*Az - Bz*Ax] shufps xmm2,xmm2,11100001b ;xmm2:  [Ax*By - Ay*Bx] [Bx*Az - Bz*Ax] [By*Az - Bz*Ay] (w,z,y,x)
v1,v2,v3 are three vertices of a triangle. I want to obtain the normal vector of the triangle.
Thanks in advance!
|30 Apr 2005, 00:31||
< Last Thread | Next Thread >
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.