123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- #include "la_5.h"
- /*
- NUL4.0 - Nick's Best - www.nicksbest.com
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- @@ TNS OpenGL 2D/3D Rendering System @@
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- @@ __ @@
- @@ ___--- | @@
- @@ __---- @@ || @@
- @@ _--- _ @@@ || @@
- @@ | @@@__ @@ || @@
- @@ | @@ #@@@#_ @@@ || @@
- @@ | @@ `#@@@@ @@ |_ @@
- @@ | @@ `#@@@@@_-- @@
- @@ | @@ _--' @@
- @@ | @@ _--- @@
- @@ | @@_--- @@
- @@ |_-- _ __ __ __ __@@
- @@ | Not Fancy @@
- @@ | But Easy @@
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- Author(s):WuYiming - xp8110@outlook.com
- Want to join the development?
- Append your name in the author list above.
- Send feedback to la_support@nicksbest.com
- */
- #include "la_tns.h"
- #include "la_util.h"
- #include <math.h>
- extern tnsMain *T;
- //z3 = 1/( linearintp(1/z1),(1/z2),t )
- //L,R is GLocation
- void tnsInterpolatePerspective4dv(tnsVector4d LG, tnsVector4d RG, tnsVector4d L, tnsVector4d R, real T, tnsVector3d Result){
- ////real t = (w - L[3]) / (R[3] - L[3]);
- real z = 1 / tnsLinearItp(1 / L[2], 1 / R[2], T);
- ////Result[2] = tnsLinearItp(L[2] / L[3], R[2] / R[3], t)*w;
- ////Result[0] = tnsLinearItp(L[0] / L[3], R[0] / R[3], t)*w;
- ////Result[1] = tnsLinearItp(L[1] / L[3], R[1] / R[3], t)*w;
- Result[0] = tnsLinearItp(L[0] / L[2], R[0] / R[2], T) * z;
- Result[1] = tnsLinearItp(L[1] / L[2], R[1] / R[2], T) * z;
- Result[2] = z;
- //real x1z1 = LG[0] / LG[2], x2z2 = RG[0] / RG[2];
- //real x3 = tnsLinearItp(LG[0], RG[0], T);
- //real z3 = tnsLinearItp(LG[2], RG[2], T);
- //real t = (x3 / z3 - x1z1) / (x2z2 - x1z1);
- //Result[0] = tnsLinearItp(L[0], R[0], t);
- //Result[1] = tnsLinearItp(L[1], R[1], t);
- //Result[2] = tnsLinearItp(L[2], R[2], t);
- }
- tnsLineStrip *tnsCreateLineStrip(){
- tnsLineStrip *ls = CreateNew(tnsLineStrip);
- return ls;
- }
- tnsLineStripPoint *tnsAppendPoint(tnsLineStrip *ls, real X, real Y, real Z){
- tnsLineStripPoint *lsp = CreateNew(tnsLineStripPoint);
- lsp->P[0] = X;
- lsp->P[1] = Y;
- lsp->P[2] = Z;
- lstAppendItem(&ls->Points, lsp);
- ls->PointCount++;
- return lsp;
- }
- tnsLineStripPoint *tnsPushPoint(tnsLineStrip *ls, real X, real Y, real Z){
- tnsLineStripPoint *lsp = CreateNew(tnsLineStripPoint);
- lsp->P[0] = X;
- lsp->P[1] = Y;
- lsp->P[2] = Z;
- lstPushItem(&ls->Points, lsp);
- ls->PointCount++;
- return lsp;
- }
- void tnsRemovePoint(tnsLineStrip *ls, tnsLineStripPoint *lsp){
- lstRemoveItem(&ls->Points, lsp);
- FreeMem(lsp);
- }
- void tnsDestroyLineStrip(tnsLineStrip *ls){
- tnsLineStripPoint *lsp;
- while (lsp = lstPopItem(&ls->Points)){
- FreeMem(lsp);
- }
- FreeMem(ls);
- }
|