*/}}

la_tns.h 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432
  1. /*
  2. * LaGUI: A graphical application framework.
  3. * Copyright (C) 2022-2023 Wu Yiming
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #pragma once
  19. #include "la_5.h"
  20. //#include "tinycthread.h"
  21. #include <float.h>
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. extern const char* TNS_SHADER_COLOR_COMMON;
  26. extern const char* TNS_VERTEX_SIMPLE_MATCAP;
  27. extern const char* TNS_FRAGMENT_SIMPLE_MATCAP;
  28. extern const char* TNS_VERTEX_GRID;
  29. extern const char* TNS_FRAGMENT_TRANSPARNT_GRID;
  30. extern const char* LA_FLOOR_VERTEX_SHADER;
  31. extern const char* LA_FLOOR_FRAGMENT_SHADER;
  32. extern const char* LA_IMM_VERTEX_SHADER;
  33. extern const char* LA_IMM_FRAGMENT_SHADER;
  34. extern const char* LA_RAY_VERTEX_SHADER;
  35. extern const char* LA_SHADER_LIB_FXAA;
  36. extern const char* LA_RAY_FRAGMENT_SHADER;
  37. extern const char* LA_SCENE_VERTEX_SHADER;
  38. extern const char* LA_SCENE_FRAGMENT_SHADER;
  39. extern const char* LA_CASCADE_SHADOW_VERTEX_SHADER;
  40. extern const char* LA_CASCADE_SHADOW_FRAGMENT_SHADER;
  41. extern const char* LA_SELECTION_VERTEX_SHADER;
  42. extern const char* LA_SELECTION_FRAGMENT_SHADER;
  43. #ifdef __cplusplus
  44. }
  45. #endif
  46. #define TNS_PI 3.1415926535897932384626433832795
  47. #define deg(r) r / TNS_PI * 180.0
  48. #define rad(d) d *TNS_PI / 180.0
  49. #define TNS_COLOR_SPACE_SRGB 0
  50. #define TNS_COLOR_SPACE_CLAY 1
  51. //typedef real tnsMatrix33d[9];
  52. typedef float tnsMatrix44f[16];
  53. typedef real tnsMatrix44d[16];
  54. typedef real tnsVector2d[2];
  55. typedef real tnsVector3d[3];
  56. typedef real tnsVector4d[4];
  57. typedef float tnsVector3f[3];
  58. typedef int tnsVector2i[2];
  59. typedef struct _tnsMatrixStackItem tnsMatrixStackItem;
  60. struct _tnsMatrixStackItem
  61. {
  62. tnsMatrix44d view;
  63. tnsMatrix44d model;
  64. tnsMatrix44d projection;
  65. };
  66. typedef struct _tnsMatrixStack tnsMatrixStack;
  67. struct _tnsMatrixStack
  68. {
  69. tnsMatrixStackItem *level;
  70. int current_level;
  71. int max_level;
  72. };
  73. typedef struct _tnsShader tnsShader;
  74. struct _tnsShader{
  75. laListItem Item;
  76. int vtShaderID;
  77. int fgShaderID;
  78. int gsShaderID;
  79. int glProgramID;
  80. int CustomID;
  81. int iModel, iProjection, iView, iProjectionInverse;
  82. int iShadow;
  83. int iVertex, iNormal, iColor, iUV;
  84. int iUseNormal;
  85. int iTexColor,iTexNormal,iTexGPos;
  86. int iTexColorMS;
  87. int iMultiplyColor, StateMultiplyColor;
  88. int iTextureMode, StateTextureMode, iColorMode,iHCYGamma;
  89. int iSampleAmount, StateSampleAmount;
  90. int iInputColorSpace, iOutputColorSpace, iShowStripes;
  91. int iDoOffset;
  92. int uViewDir,uViewPos,uFOV,uNear,uFar;
  93. };
  94. typedef struct _tnsTexture tnsTexture;
  95. typedef struct _tnsCommand tnsCommand;
  96. struct _tnsCommand
  97. {
  98. GLenum Mode;
  99. short Dimensions; // 2 or 3
  100. short UVDimensions; // 2 or 3
  101. char UseVert;
  102. char UseColor;
  103. char UseNormal;
  104. char UseTexCoord;
  105. char UseIndex;
  106. GLenum PolyMode; //0-solid 1-wire
  107. GLenum Shade; //0-falt 1-smooth
  108. GLfloat UniformColor[4];
  109. int NumVert;
  110. int NumIndex;
  111. int VertBegin;
  112. int VertEnd; //'END'is the next one after the last one.
  113. int ColorBegin;
  114. int ColorEnd;
  115. int TexCoordBegin;
  116. int TexCoordEnd;
  117. int NormalBegin;
  118. int NormalEnd;
  119. GLushort IndexBegin;
  120. GLushort IndexEnd;
  121. tnsShader *ReplaceShader;
  122. tnsTexture *ColorTexture;
  123. int TextureMode;
  124. int MultiplyColor;
  125. };
  126. typedef struct _tnsMain tnsMain;
  127. typedef struct _tnsWorld tnsWorld;
  128. typedef struct _tnsObject tnsObject;
  129. struct _tnsWorld
  130. {
  131. laListItem Item;
  132. laListHandle RootObjects;
  133. tnsObject *ActiveRoot;
  134. laListHandle AllObjects;
  135. laListHandle Materials;
  136. u16bit TimeYear;
  137. u8bit TimeMonth;
  138. u8bit TimeDay;
  139. laListHandle BezierCurves;
  140. laListHandle Meshes;
  141. };
  142. NEED_STRUCTURE(tnsLoopItem);
  143. NEED_STRUCTURE(tnsRenderLine);
  144. NEED_STRUCTURE(tnsRenderBuffer);
  145. STRUCTURE(tnsFilterKernel){
  146. int Size;
  147. real *Kernel;
  148. };
  149. STRUCTURE(tnsTriangulateNode){
  150. char Picked;
  151. real Angle; //rad
  152. tnsLoopItem *LoopItem;
  153. tnsRenderLine *FowardRL;
  154. tnsRenderLine *BackwardRL;
  155. };
  156. STRUCTURE(tnsTriangulateEdgeNode){
  157. tnsRenderLine *RL;
  158. };
  159. STRUCTURE(tnsImage){
  160. laListItem Item;
  161. void* MemPNG;
  162. tnsTexture* Texture;
  163. int UserCount;
  164. };
  165. struct _tnsMain {
  166. laListItem Item;
  167. tnsMatrixStack stack;
  168. laListHandle Shaders;
  169. int NextShaderIndex;
  170. tnsShader *CurrentShader;
  171. tnsShader *BindedShader;
  172. //int MatrixMode;
  173. int IsOffscreen;
  174. laListHandle Offscreens;
  175. char *GLVersionStr;
  176. char *GLVendorStr;
  177. char *GLRendererStr;
  178. char *GLSLVersionStr;
  179. tnsShader* immShader;
  180. tnsShader* RayShader;
  181. tnsShader* ShadowShader;
  182. tnsShader* SceneShader;
  183. tnsShader* SelectionShader;
  184. tnsShader* FloorShader;
  185. int GlobalVAO;
  186. tnsShader *uiShader;
  187. tnsShader *stringShader;
  188. tnsShader *TextureShader;
  189. tnsShader *RectangleTextureShader;
  190. tnsShader *TextureMultiplyShader;
  191. tnsShader *MSTextureShader;
  192. tnsShader *MSATextureShader;
  193. tnsShader *TEST_MatcapShader;
  194. tnsShader *TransparentGridShader;
  195. tnsShader *SobelColorShader;
  196. tnsShader *SobelShader;
  197. tnsShader *ExtraBuffersShader;
  198. laListHandle Textures;
  199. tnsTexture *PreviewTexture;
  200. tnsFilterKernel EdgeGaussFilter;
  201. GLenum GlTextureSets;
  202. // Corresponds to current GL_TEXTURE0/1...
  203. tnsTexture *TexColor;
  204. tnsTexture *TexRenderbuffer;
  205. // For commands
  206. GLenum StateShadeMode;
  207. GLenum StatePolyMode;
  208. tnsTexture *StateTexColor;
  209. int StateTextureMode;
  210. int StateMultiplyColor;
  211. int StateUseNormal;
  212. int SetUseNormal;
  213. tnsShader* StateShader;
  214. GLfloat StateColor[4];
  215. GLfloat* Vert;
  216. GLuint VertBufObject;
  217. int NextVert, MaxVert;
  218. GLfloat* Color;
  219. GLuint ColorBufObject;
  220. int NextColor, MaxColor;
  221. GLfloat* Normal;
  222. GLuint NormalBufObject;
  223. int NextNormal, MaxNormal;
  224. GLfloat* TexCoord;
  225. GLuint TexCoordBufObject;
  226. int NextTexCoord, MaxTexCoord;
  227. GLuint* Index;
  228. GLuint IndexBufObject;
  229. int NextIndex, MaxIndex;
  230. tnsCommand* DrawingCommand;
  231. int NextCommand, MaxCommand;
  232. tnsWorld World;
  233. laListHandle RenderBuffers;
  234. tnsRenderBuffer *ActiveRenderBuffer;
  235. laListHandle Images;
  236. };
  237. typedef struct _tnsLineStripPoint tnsLineStripPoint;
  238. struct _tnsLineStripPoint
  239. {
  240. laListItem Item;
  241. tnsVector3d P;
  242. };
  243. typedef struct _tnsLineStrip tnsLineStrip;
  244. struct _tnsLineStrip
  245. {
  246. laListItem Item;
  247. laListHandle Points;
  248. int PointCount;
  249. };
  250. #define TNS_SNAKE_STRENGTH_LIMIT 30
  251. #define TNS_SNAKE_STEP_LENGTH 5
  252. #define TNS_SNAKE_STRENGTH_MARCHING_LIMIT 30
  253. #define TNS_SNAKE_EDGE_WIDTH 2
  254. #define TNS_SNAKE_FILTER_SIZE 6
  255. #define TNS_SNAKE_ANGLE_DEVIATE 0.5
  256. #define TNS_SNAKE_ANGLE_PRICISION 1
  257. #define TNS_SNAKE_STEP1 3
  258. #define TNS_SNAKE_STEP2 5
  259. typedef struct _tnsTextureSample tnsTextureSample;
  260. struct _tnsTextureSample
  261. {
  262. laListItem Item;
  263. u8bit Sample;
  264. int X, Y;
  265. real Z;
  266. };
  267. typedef struct _tnsTexture tnsTexture;
  268. struct _tnsTexture
  269. {
  270. laListItem Item;
  271. int IsRenderBuffer;
  272. GLuint GLTexHandle;
  273. GLint GLTexBitsType; //like GL_RGBA
  274. GLuint GLTexType; //like GL_TEXTURE_2D
  275. int Multisample;
  276. int Width;
  277. int Height;
  278. int Slices;
  279. void *DrawData;
  280. int RBWidth, RBHeight;
  281. int ElemSize;
  282. void *TextureReadBack;
  283. void **SamplePtr;
  284. laListHandle PendingSamples;
  285. laListHandle ErasedSamples;
  286. laListHandle LineStrips;
  287. };
  288. typedef struct _tnsOffscreen tnsOffscreen;
  289. struct _tnsOffscreen
  290. {
  291. laListItem Item;
  292. tnsTexture *pColor[16];
  293. tnsTexture *pDepth;
  294. GLuint FboHandle;
  295. int UseSecondary;
  296. };
  297. extern const GLuint TNS_ATTACHMENT_ARRAY_NONE[];
  298. extern const GLuint TNS_ATTACHMENT_ARRAY[];
  299. extern const GLuint TNS_ATTACHMENT_ARRAY_1[];
  300. extern const GLuint TNS_ATTACHMENT_ARRAY_2[];
  301. extern const GLuint TNS_ATTACHMENT_ARRAY_1_2[];
  302. extern const GLuint TNS_ATTACHMENT_ARRAY_0_1_2[];
  303. extern const GLenum TNS_WINDOW_DRAWBUFFER_ARRAY[];
  304. #define TNS_PROJECTION_MATRIX 1
  305. #define TNS_MODEL_MATRIX 2
  306. #define TNS_VIEW_MATRIX 3
  307. #define TNS_TEXTURE_MATRIX 4
  308. //==========================================================================[FT]
  309. #include "freetype/ftglyph.h"
  310. #include "freetype/ftoutln.h"
  311. #include "freetype/fttrigon.h"
  312. #include "ft2build.h"
  313. #include <stdarg.h>
  314. #include <stdlib.h>
  315. #include <string.h>
  316. NEED_STRUCTURE(tnsTexture);
  317. typedef struct _tnsFontSingleCharacter tnsFontSingleCharacter;
  318. struct _tnsFontSingleCharacter
  319. {
  320. tnsTexture *Tex;
  321. int Generated;
  322. short width;
  323. short height;
  324. real advx;
  325. short advy;
  326. short deltax;
  327. short deltay;
  328. short bufferx;
  329. short buffery;
  330. };
  331. #define TNS_UNICODE_COUNT ((unsigned int)(1<<17))
  332. #define TNS_MONO_COUNT (0x045f)
  333. typedef struct _tnsFont tnsFont;
  334. struct _tnsFont
  335. {
  336. laListItem Item;
  337. char *fontName;
  338. char *IconFontName;
  339. tnsFontSingleCharacter** characters; /* [(1<<17)] TNS_UNICODE_COUNT Unicode plane 0-1 */
  340. tnsFontSingleCharacter** monocharacters; /* [0x045f] TNS_MONO_COUNT Up to cryllic. */
  341. FT_Library ftlib;
  342. FT_Face ftface[16];
  343. FT_Face ftfacemono;
  344. int NumFaces;/* excludes mono. */
  345. real MonoScale;
  346. real MonoAdvance;
  347. real size;
  348. unsigned int height;
  349. tnsTexture TexBuffer;
  350. int CurrentX;
  351. int CurrentY;
  352. };
  353. typedef struct _tnsFontManager tnsFontManager;
  354. struct _tnsFontManager
  355. {
  356. laListHandle Fonts;
  357. tnsFont *UsingFont;
  358. tnsFont *VectorsGrapghs;
  359. unsigned LastDlst;
  360. };
  361. typedef struct _tnsFontBoundBox tnsFontBoundBox;
  362. struct _tnsFontBoundBox
  363. {
  364. int x, y, w, h; /* Upper Left and width,height */
  365. };
  366. #define TNS_FONT_BUFFER_W 2048
  367. #define TNS_FONT_BUFFER_H 2048
  368. #define TNS_FONT_ALIGN_LEFT 1
  369. #define TNS_FONT_ALIGN_CENTER 2
  370. #define TNS_FONT_ALIGN_RIGHT 4
  371. #define TNS_FONT_ALIGN_LEFT_PROTECT 8
  372. #define TNS_FONT_ALIGN_CENTER_FIRST (2 | 8)
  373. #define CSS_FLOW_DIRECTION_LR 1
  374. #define CSS_FLOW_DIRECTION_TD 0
  375. //typedef struct _tnsCssBorder tnsCssBorder;
  376. //struct _tnsCssBorder{
  377. // real Px;//thickness
  378. // real Color[4];//rgba
  379. // int Style;//Like________ or ....... or __.__.__. or ======== or ~~~~~~~
  380. // int Padding;
  381. // int Margin;
  382. //};
  383. //
  384. //typedef struct _tnsCssBackground tnsCssBackground;
  385. //struct _tnsCssBackground{
  386. // real Color[4];
  387. // int ImageID;//LA SPECIFIC
  388. // int Repeat;
  389. // int PositionFixed;
  390. // real PositionRatio;
  391. //};
  392. //
  393. //typedef struct _tnsCssText tnsCssText;
  394. //struct _tnsCssText{
  395. // real Color[4];
  396. // int LineSpacing;
  397. // int LetterSpacing;
  398. // int Align;//0-LR 1-C 2-L 3-R all support number-ready display
  399. // int Decoration;
  400. // int Underline;
  401. // int Shadow;
  402. //};
  403. //
  404. //typedef struct _tnsCssMisc tnsCssMisc;
  405. //struct _tnsCssMisc{
  406. // real Color[4];
  407. // int Size;
  408. // const char * Name;
  409. // const char * Description;
  410. //};
  411. //
  412. //typedef struct _tnsCssState tnsCssState;
  413. //struct _tnsCssState{
  414. // char NameReplace[36];
  415. // tnsCssBackground Bkg;
  416. // tnsCssBorder BorderLeft;
  417. // tnsCssBorder BorderRight;
  418. // tnsCssBorder BorderTop;
  419. // tnsCssBorder BorderBottom;
  420. // tnsCssText Text;
  421. // tnsCssMisc Misc1;
  422. // tnsCssMisc Misc2;
  423. // tnsCssMisc Misc3;
  424. // tnsCssMisc Misc4;
  425. //};
  426. #define TNS_STATE_NORMAL 0
  427. #define TNS_STATE_PUSHED 1
  428. #define TNS_STATE_HIGHLIGHT 2
  429. #define TNS_STATE_HIGHLIGHT_SELECT 3
  430. #define TNS_STATE_KEYING 4
  431. #define TNS_STATE_INTERPOLATING 5
  432. #define TNS_STATE_LIMITED 6
  433. //
  434. //typedef struct _tnsCssStyle tnsCssStyle;
  435. //struct _tnsCssStyle{
  436. // tnsCssState Normal;
  437. // tnsCssState Pushed;
  438. // tnsCssState Highlight;
  439. // tnsCssState HighlightSelect;
  440. // tnsCssState Keying;
  441. // tnsCssState Interpolating;
  442. // tnsCssState Limited;
  443. //};
  444. //=====================================================[3d comp]
  445. typedef struct _tnsWorld tnsWorld;
  446. typedef struct _tnsObject tnsObject;
  447. #define TNS_ROTATION_XYZ_EULER 0
  448. #define TNS_ROTATION_XZY_EULER 1
  449. #define TNS_ROTATION_YXZ_EULER 2
  450. #define TNS_ROTATION_YZX_EULER 3
  451. #define TNS_ROTATION_ZXY_EULER 4
  452. #define TNS_ROTATION_ZYX_EULER 5
  453. #define TNS_ROTATION_QUATERNION 6
  454. #define TNS_OBJECT_ROOT 0
  455. #define TNS_OBJECT_EMPTY (1<<0)
  456. #define TNS_OBJECT_CAMERA (1<<1)
  457. #define TNS_OBJECT_LIGHT (1<<2)
  458. #define TNS_OBJECT_MESH (1<<3)
  459. //typedef struct _tnsObjectLinker tnsObjectLinker;
  460. //struct _tnsObjectLinker {
  461. // laListItem Item;
  462. // tnsObject* o;
  463. //};
  464. NEED_STRUCTURE(tnsRenderTriangle);
  465. NEED_STRUCTURE(tnsRenderVert);
  466. #define TNS_OBJECT_FLAGS_SELECTED 1
  467. NEED_STRUCTURE(tnsBatch)
  468. typedef struct _tnsObject tnsObject;
  469. struct _tnsObject
  470. {
  471. laListItem Item;
  472. int Type;
  473. int SelectID;
  474. int Flags;
  475. //u64bit ID;
  476. laSafeString *Name;
  477. int DrawMode;
  478. int Show;
  479. int ShowOnRender;
  480. int HideChildren;
  481. real GLocation[3];
  482. real GRotation[3];
  483. real GScale;
  484. real Location[3];
  485. real Rotation[4];
  486. real Scale;//Only allow uniform scale
  487. u8bit RotationMode;
  488. tnsMatrix44d GlobalTransform;
  489. tnsMatrix44d SelfTransform;
  490. tnsMatrix44d DeltaTransform;
  491. //tnsMatrix44d CameraTransform;
  492. tnsObject *Active; // may be used to store last select info in child objects.
  493. tnsObject *InRoot;
  494. tnsObject *ParentObject; // reused as root active sun.
  495. laListHandle ChildObjects;
  496. laListHandle Drivers; // rack
  497. tnsBatch *ExtraBatch; // for root.
  498. };
  499. NEED_STRUCTURE(laNodeInSocket);
  500. NEED_STRUCTURE(laNodeOutSocket);
  501. STRUCTURE(tnsTransformNode){
  502. laBaseNode Base;
  503. laNodeInSocket* Mat;
  504. tnsObject* Target;
  505. };
  506. STRUCTURE(tnsMakeTransformNode){
  507. laBaseNode Base;
  508. laNodeInSocket* Loc; laNodeInSocket* Rot; laNodeInSocket* Angle; laNodeInSocket* Sca;
  509. laNodeOutSocket* Out;
  510. tnsMatrix44d Mat; tnsVector3d UseLoc; tnsVector3d UseRot; real UseSca; real UseAngle;
  511. };
  512. #define TNS_PRESPECTIVE_CAMERA 0
  513. #define TNS_ORTHOGRAPHICAL_CAMERA 1
  514. #define TNS_FISHEYE_CAMERA 2
  515. #define TNS_ID_TO_COLOR(color, i) \
  516. {color[0]=(real)((i & 0x000000FF)>>0)/255.0; color[1]=(real)((i & 0x0000FF00)>>8)/255.0; color[2]=(real)((i & 0x00FF0000)>>16)/255.0;}
  517. #define TNS_MATERIAL_DRAW_MODE_SOLID 0
  518. #define TNS_MATERIAL_DRAW_MODE_WIRE 1
  519. typedef struct _tnsMaterial tnsMaterial;
  520. struct _tnsMaterial
  521. {
  522. laListItem Item;
  523. laSafeString *Name;
  524. int ID;
  525. int DrawMode;
  526. real Color[4];
  527. real LinearColor[4];
  528. real SpectacularColor[4];
  529. real ReflexThreshold;
  530. real ReflexStrengh;
  531. real ReflexSharpeness;
  532. real LowBrightnessColor[4]; //Windows are lighten up in the evenings
  533. u8bit HaloMode;
  534. };
  535. #define TNS_CAMERA_PERSPECTIVE 0
  536. #define TNS_CAMERA_ORTHO 1
  537. #define TNS_CAMERA_FISHEYE 2
  538. typedef struct _tnsCamera tnsCamera;
  539. struct _tnsCamera
  540. {
  541. tnsObject Base;
  542. int CameraType;
  543. real FOV;
  544. real ZMin, ZMax;
  545. real FocusDistance;
  546. real OrthScale;
  547. tnsVector3d RenderViewDir;
  548. };
  549. typedef struct _tnsLight tnsLight;
  550. struct _tnsLight
  551. {
  552. tnsObject Base;
  553. int LightType;
  554. int UniDirectional;
  555. real Strength;
  556. tnsMaterial *Material;
  557. };
  558. STRUCTURE(tnsGroup){
  559. laListItem Item;
  560. laListHandle ObjectLinks;
  561. laSafeString *Name;
  562. tnsVector4d Color1;
  563. tnsVector4d Color2;
  564. int ExcludeFromCalculation;
  565. };
  566. #define TNS_MESH_FLAG_SELECTED (1<<0)
  567. #define TNS_MESH_FLAG_PICKED (1<<1)
  568. #define TNS_MESH_FLAG_LOOP_REVERSE (1<<2)
  569. STRUCTURE(tnsMVert){
  570. laListItem Item;
  571. tnsVector3d p;
  572. tnsVector3d n;
  573. int flags;
  574. u32bit i;
  575. laListHandle elink;
  576. //laListHandle flink;
  577. };
  578. NEED_STRUCTURE(tnsMFace);
  579. STRUCTURE(tnsMEdge){
  580. laListItem Item;
  581. tnsMVert *vl;
  582. tnsMVert *vr;
  583. tnsMFace *fl;
  584. tnsMFace *fr;
  585. u32bit i;
  586. int flags;
  587. };
  588. STRUCTURE(tnsMFace){
  589. laListItem Item;
  590. laListHandle l; //list item pointer of edges
  591. tnsVector3d n;
  592. tnsVector3d c;
  593. short looplen;
  594. short mat;
  595. u32bit i;
  596. int flags;
  597. };
  598. STRUCTURE(tnsVert){
  599. tnsVector3f p;
  600. tnsVector3f n;
  601. int flags;
  602. };
  603. STRUCTURE(tnsEdge){
  604. int l,r;
  605. int flags;
  606. };
  607. STRUCTURE(tnsFace){
  608. int* loop;
  609. int flags;
  610. tnsVector3f n;
  611. short looplen;
  612. };
  613. STRUCTURE(tnsBatchCommand){
  614. laListItem Item;
  615. char* name;
  616. int DrawElements;
  617. GLuint EBO; //elem
  618. u32bit ElementCount;
  619. GLenum DrawAs;
  620. int UseUniformColor; real UniformColor[4];
  621. GLuint CBO; int ColorDimension; int OverrideColorArray;
  622. int Dimension;
  623. int HiddenByDefault;
  624. };
  625. STRUCTURE(tnsBatch){
  626. laListItem Item;
  627. GLuint VBO; //vert
  628. GLuint NBO; int HasNormal; //normal
  629. GLuint CBO; int HasColor; //color
  630. u32bit NumVert;
  631. int Dimension;
  632. int NormalDimension;
  633. int ColorDimension;
  634. laListHandle Branches;
  635. GLuint BeginElementOffset;
  636. };
  637. #define TNS_MESH_OBJECT_MODE 0
  638. #define TNS_MESH_EDIT_MODE 1
  639. extern laPropContainer* TNS_PC_OBJECT_GENERIC;
  640. extern laPropContainer* TNS_PC_OBJECT_CAMERA;
  641. extern laPropContainer* TNS_PC_OBJECT_LIGHT;
  642. extern laPropContainer* TNS_PC_OBJECT_MESH;
  643. #define TNS_HINT_TRANSFORM (1<<1)
  644. #define TNS_HINT_GEOMETRY (1<<0)
  645. STRUCTURE(tnsMeshFaceStorageSingleHead){
  646. int looplen, flags; //[1] [5] [4] [2] ... [-1 as end]
  647. };
  648. STRUCTURE(tnsMeshFaceStorage){
  649. int len; int arr;
  650. };
  651. STRUCTURE(tnsMeshObject){
  652. tnsObject Base;
  653. tnsVert* v; int totv, maxv;
  654. tnsEdge* e; int tote, maxe; // I intend this to only stores floating edges.
  655. tnsFace* f; int totf, maxf;
  656. laListHandle mv; int totmv;
  657. laListHandle me; int totme;
  658. laListHandle mf; int totmf;
  659. int TriangleCount;
  660. int TriangulatedEdgeCount;
  661. tnsBatch *Batch;
  662. int Mode;
  663. };
  664. STRUCTURE(tnsEdgeHashEdge){
  665. int tv; tnsMEdge* me;
  666. };
  667. STRUCTURE(tnsEdgeHashVert){
  668. tnsEdgeHashEdge* e; int max, next; tnsMVert* mv;
  669. };
  670. STRUCTURE(tnsEdgeHash){
  671. tnsEdgeHashVert* vl; int max,next;
  672. };
  673. #define TNS_TILE(tile, r, c, CCount) \
  674. tile[r * CCount + c]
  675. #define TNS_CLAMP(a, Min, Max) \
  676. a = a < Min ? Min : (a > Max ? Max : a)
  677. #define TNS_MAX2(a, b) \
  678. (a > b ? a : b)
  679. #define TNS_MIN2(a, b) \
  680. (a < b ? a : b)
  681. #define TNS_MAX3(a, b, c) \
  682. (a > TNS_MAX2(b, c) ? a : TNS_MAX2(b, c))
  683. #define TNS_MIN3(a, b, c) \
  684. (a < TNS_MIN2(b, c) ? a : TNS_MIN2(b, c))
  685. #define TNS_MAX2_INDEX(a, b) \
  686. (a > b ? 0 : 1)
  687. #define TNS_MIN2_INDEX(a, b) \
  688. (a < b ? 0 : 1)
  689. #define TNS_MAX3_INDEX(a, b, c) \
  690. (a > b ? (a > c ? 0 : (b > c ? 1 : 2)) : (b > c ? 1 : 2))
  691. #define TNS_MIN3_INDEX(a, b, c) \
  692. (a < b ? (a < c ? 0 : (b < c ? 1 : 2)) : (b < c ? 1 : 2))
  693. #define TNS_MAX3_INDEX_ABC(x, y, z) \
  694. (x > y ? (x > z ? a : (y > z ? b : c)) : (y > z ? b : c))
  695. #define TNS_MIN3_INDEX_ABC(x, y, z) \
  696. (x < y ? (x < z ? a : (y < z ? b : c)) : (y < z ? b : c))
  697. #define TNS_ABC(index) \
  698. (index == 0 ? a : (index == 1 ? b : c))
  699. #define TNS_DOUBLE_CLOSE_ENOUGH(a, b) \
  700. (((a) + DBL_EDGE_LIM) >= (b) && ((a)-DBL_EDGE_LIM) <= (b))
  701. //#define TNS_DOUBLE_CLOSE_ENOUGH(a,b) \
  702. //(((a)+0.00000000001)>=(b) && ((a)-0.0000000001)<=(b))
  703. #define TNS_FLOAT_CLOSE_ENOUGH_WIDER(a, b) \
  704. (((a) + 0.0000001) >= (b) && ((a)-0.0000001) <= (b))
  705. #define TNS_FRAMEBUFFER_PIXEL(FrameBuffer, Row, Column) \
  706. &((FrameBuffer)->Pixels[Row * FrameBuffer->TileSizeW * FrameBuffer->W * FrameBuffer->SubPixelSample + Column * FrameBuffer->H * FrameBuffer->TileSizeH * FrameBuffer->SubPixelSample])
  707. #define TNS_IN_TILE_X(RenderTile, Fx) \
  708. (RenderTile->FX <= Fx && RenderTile->FXLim >= Fx)
  709. #define TNS_IN_TILE_Y(RenderTile, Fy) \
  710. (RenderTile->FY <= Fy && RenderTile->FYLim >= Fy)
  711. #define TNS_IN_TILE(RenderTile, Fx, Fy) \
  712. (TNS_IN_TILE_X(RenderTile, Fx) && TNS_IN_TILE_Y(RenderTile, Fy))
  713. #define TNS_RENDERBUFFER_INCOMPLETE 0
  714. #define TNS_RENDERBUFFER_GEOMETRY_COMPLETE 1
  715. #define TNS_RENDERBUFFER_RASTERIZER_COMPLETE 2
  716. #define TNS_RENDERBUFFER_COMPLETE (TNS_RENDERBUFFER_GEOMETRY_COMPLETE | TNS_RENDERBUFFER_RASTERIZER_COMPLETE)
  717. #define TNS_DISPLAY_MODE_WIRE GL_LINE_LOOP
  718. #define TNS_DISPLAY_MODE_SOLID GL_TRIANGLES
  719. #define TNS_INTERNAL_MODE_WIRE 1
  720. #define TNS_INTERNAL_MODE_SOLID 2
  721. #define TNS_ARROW_L 1
  722. #define TNS_ARROW_R 2
  723. #define TNS_ARROW_U 3
  724. #define TNS_ARROW_D 4
  725. #define TNS_KEYWORD_OBJECT_COUNT 1
  726. #define TNS_KEYWORD_OBJECT_NAME 2
  727. #define TNS_KEYWORD_OBJECT_TYPE 3
  728. #define TNS_KEYWORD_OBJECT_LOCATION 4
  729. #define TNS_KEYWORD_OBJECT_ROTATION 5
  730. #define TNS_KEYWORD_OBJECT_SCALE 6
  731. #define TNS_KEYWORD_OBJECT_CHILDREN_COUNT 7
  732. #define TNS_KEYWORD_OBJECT_CHILDREN_NAMES 8
  733. //#define TNS_KEYWORD_MESH_COUNT 9
  734. //#define TNS_KEYWORD_MESH_NAME 10
  735. #define TNS_KEYWORD_MESH_VERTEX_COUNT 11
  736. #define TNS_KEYWORD_MESH_VERTICES 12
  737. #define TNS_KEYWORD_MESH_LOOP_COUNT 13
  738. #define TNS_KEYWORD_MESH_TOPOLOGY 14
  739. #define TNS_KEYWORD_MESH_UV_COUNT 15
  740. #define TNS_KEYWORD_MESH_UV_NAME 16
  741. #define TNS_KEYWORD_MATERIAL_COUNT 17
  742. #define TNS_KEYWORD_MATERIAL_NAME 18
  743. #define TNS_KEYWORD_MATERIAL_COLOR 19
  744. #define TNS_KEYWORD_MATERIAL_END 20
  745. #define TNS_KEYWORD_CAMERA_FOV 20
  746. #define TNS_KEYWORD_CAMERA_IS_ACTIVE 21
  747. #define TNS_KEYWORD_CAMERA_NEAR 22
  748. #define TNS_KEYWORD_CAMERA_FAR 23
  749. #define TNS_KEYWORD_GROUP_COUNT 24
  750. #define TNS_KEYWORD_GROUP_NAME 25
  751. #define TNS_KEYWORD_OBJECT_GROUP_COUNT 26
  752. void tnsSetuptnsFontManager();
  753. tnsShader *tnsNewShaderProgram(int VertexShaderID, int FragmentShaderID, int GeometryShaderID);
  754. int tnsNewGeometryShader(char *Content);
  755. int tnsNewFragmentShader(char *Content);
  756. int tnsNewVertexShader(char *Content);
  757. void tnsDeleteShaderProgram(tnsShader* s);
  758. int tnsNextPowOf2(int i);
  759. int tnsEnableShader(int index);
  760. int tnsEnableShaderv(tnsShader *shader);
  761. int tnsUseShader(tnsShader *shader);
  762. void tnsUseImmShader();
  763. void tnsUseShadowShader();
  764. void tnsUseSceneShader();
  765. void tnsUseRayShader();
  766. void tnsUseTransparentGridShader();
  767. void tnsUseImagePeelShader();
  768. void tnsInitRenderKernel(int matrixStackLevel);
  769. void tnsInitBuiltinShaders();
  770. void tnsInitWindowDefaultRenderConfig();
  771. void tnsQuit();
  772. void tnsRestoreFromNanoVG();
  773. real *tnsGetModelMatrix();
  774. real *tnsGetViewMatrix();
  775. real *tnsGetProjectionMatrix();
  776. void tnsGetMVMatrix(tnsMatrix44d r);
  777. void tnsGetMVPMatrix(tnsMatrix44d r);
  778. void tnsResetModelMatrix();
  779. void tnsResetViewMatrix();
  780. void tnsResetProjectionMatrix();
  781. void tnsOrtho(real xMin, real xMax, real yMin, real yMax, real zMin, real zMax);
  782. void tnsPerspective(real fFov_rad, real fAspect, real zMin, real zMax);
  783. void tnsPopMatrix();
  784. void tnsPushMatrix();
  785. void tnsTranslate3d(real x, real y, real z);
  786. void tnsPreTranslate3d(real x, real y, real z);
  787. void tnsRotate4d(real degrees, real x, real y, real z);
  788. void tnsPreRotate4d(real degrees, real x, real y, real z);
  789. void tnsScale3d(real x, real y, real z);
  790. void tnsPreScale3d(real x, real y, real z);
  791. void tnsColor4d(real r, real g, real b, real a);
  792. void tnsColor4dv(real *rgba);
  793. void tnsPolygonMode(GLenum PolyMode);
  794. void tnsShadeMode(GLenum ShadeMode);
  795. tnsBatch *tnsCreateBatch(u32bit NumVert, int Dimension, float *Data, int NormalDimension, float *Normal, int ColorDimension, float *Colors);
  796. tnsBatch *tnsCreateBatchi(u32bit NumVert, int Dimension, int *Data);
  797. void tnsCommandUseUniformColor(tnsBatchCommand*c,real* color);
  798. void tnsCommandOverrideColorArray(tnsBatchCommand*c, int VertCount, int ColorDimension, float* colors);
  799. tnsBatchCommand *tnsCreateCommand(tnsBatch *b, const char* name, u32bit ElementCount, int Dimension, GLenum DrawAs, u32bit *Elements, int HiddenByDefault);
  800. void tnsDeleteBatch(tnsBatch *b);
  801. void tnsDrawBatch(tnsBatch* batch, const char* OverrideCommand, real* OverrideUniformColor, int OverrideAsArray);
  802. void tnsVertex3d(real x, real y, real z);
  803. void tnsVertex2d(real x, real y);
  804. void tnsVertexArray2d(real *verts, int amount);
  805. void tnsVertexArray3d(real *verts, int amount);
  806. void tnsColorArray4d(real *colors, int amount);
  807. void tnsNormalArray3d(real *normals, int amount);
  808. void tnsTexCoordArray2d(real *coords, int amount);
  809. void tnsTexCoordArray3d(real *coords, int amount);
  810. void tnsIndexArray(GLuint *index, short amount);
  811. void tnsPackAs(GLenum Mode);
  812. void tnsFlush();
  813. #define tnsLinearItp(L, R, T) \
  814. ((L) * (1.0f - (T)) + (R) * (T))
  815. double tnsGetRatiod(real L, real R, real FromL);
  816. void tnsShaderApplyProjectionInverse(tnsShader *tns, tnsMatrix44d m);
  817. void tnsShaderApplyProjection(tnsShader *tns, tnsMatrix44d m);
  818. void tnsShaderApplyModel(tnsShader *tns, tnsMatrix44d m);
  819. void tnsShaderApplyView(tnsShader *tns, tnsMatrix44d m);
  820. void tnsShaderApplyNormalScaler(tnsShader *tns, tnsMatrix44d m);
  821. int tnsLineIntersectTest2d(tnsVector2d a1, tnsVector2d a2, tnsVector2d b1, tnsVector2d b2, double *aRatio);
  822. double tnsGetLineZ(tnsVector3d L, tnsVector3d R, real Ratio);
  823. double tnsGetLineZPoint(tnsVector3d L, tnsVector3d R, tnsVector3d FromL);
  824. double tnsGetRatio3d(tnsVector3d L, tnsVector3d R, tnsVector3d FromL);
  825. double tnsGetRatiod(real L, real R, real FromL);
  826. real tnsInterpolate(real L, real R, real T);
  827. void tnsInterpolate2dv(real *L, real *R, real T, real *Result);
  828. void tnsInterpolate3dv(real *L, real *R, real T, real *Result);
  829. void tnsInterpolateTripple2d(tnsVector2d v1, tnsVector2d v2, tnsVector2d v3, real ratio, tnsVector2d result);
  830. void tnsVectorMinus2d(tnsVector2d result, tnsVector2d l, tnsVector2d r);
  831. void tnsVectorMinus3d(tnsVector3d result, tnsVector3d l, tnsVector3d r);
  832. void tnsVectorSubtract3d(tnsVector3d l, tnsVector3d r);
  833. void tnsVectorPlus3d(tnsVector3d result, tnsVector3d l, tnsVector3d r);
  834. void tnsVectorAccum3d(tnsVector3d l, tnsVector3d r);
  835. void tnsVectorAccum2d(tnsVector2d l, tnsVector2d r);
  836. void tnsVectorNegate3d(tnsVector3d result, tnsVector3d l);
  837. void tnsVectorNegateSelf3d(tnsVector3d l);
  838. void tnsVectorCopy2d(tnsVector2d from, tnsVector2d to);
  839. void tnsVectorCopy3d(tnsVector3d from, tnsVector3d to);
  840. void tnsVectorCopy4d(tnsVector4d from, tnsVector4d to);
  841. void tnsVectorMultiSelf4d(tnsVector4d from, real num);
  842. void tnsVectorMultiSelf3d(tnsVector3d from, real num);
  843. void tnsVectorMultiSelf2d(tnsVector2d from, real num);
  844. void tnsVectorMulti4d(tnsVector4d to, tnsVector4d from, real num);
  845. void tnsVectorMulti3d(tnsVector3d to, tnsVector3d from, real num);
  846. void tnsVectorMulti2d(tnsVector2d to, tnsVector2d from, real num);
  847. real tnsDirectionToRad(tnsVector2d Dir);
  848. void tnsConvert44df(tnsMatrix44d from, tnsMatrix44f to);
  849. int tnsTrangleLineBoundBoxTest(tnsRenderTriangle *rt, tnsRenderLine *rl);
  850. #define tnsVectorSet2(to, x,y) \
  851. {(to)[0]=x;(to)[1]=y;}
  852. #define tnsVectorSet3(to, x,y,z) \
  853. {(to)[0]=x;(to)[1]=y;(to)[2]=z;}
  854. #define tnsVectorSet4(to, x,y,z,w) \
  855. {(to)[0]=x;(to)[1]=y;(to)[2]=z;(to)[3]=w;}
  856. #define tnsVectorSet2v(to, from) \
  857. tnsVectorSet2(to,(from)[0],(from)[1])
  858. #define tnsVectorSet3v(to, from) \
  859. tnsVectorSet3(to,(from)[0],(from)[1],(from)[2])
  860. #define tnsVectorSet4v(to, from) \
  861. tnsVectorSet4(to,(from)[0],(from)[1],(from)[2],(from)[3])
  862. real tnsDistIdv2(real x1, real y1, real x2, real y2);
  863. real tnsDist3dv(tnsVector3d l, tnsVector3d r);
  864. real tnsDist2dv(tnsVector2d l, tnsVector2d r);
  865. real tnsLength3d(tnsVector3d l);
  866. real tnsLength2d(tnsVector3d l);
  867. void tnsNormalize3d(tnsVector3d result, tnsVector3d l);
  868. void tnsNormalizeSelf2d(tnsVector3d result);
  869. void tnsNormalizeSelf3d(tnsVector3d result);
  870. real tnsDot3d(tnsVector3d l, tnsVector3d r, int normalize);
  871. real tnsDot2d(tnsVector2d l, tnsVector2d r, int normalize);
  872. real tnsVectorCross3d(tnsVector3d result, tnsVector3d l, tnsVector3d r);
  873. real tnsAngleRad3d(tnsVector3d from, tnsVector3d to, tnsVector3d PositiveReference);
  874. void tnsApplyRotation33d(tnsVector3d result, tnsMatrix44d mat, tnsVector3d v);
  875. void tnsApplyRotation43d(tnsVector3d result, tnsMatrix44d mat, tnsVector3d v);
  876. void tnsApplyTransform43d(tnsVector3d result, tnsMatrix44d mat, tnsVector3d v);
  877. void tnsApplyNormalTransform43d(tnsVector3d result, tnsMatrix44d mat, tnsVector3d v);
  878. void tnsApplyTransform44d(tnsVector4d result, tnsMatrix44d mat, tnsVector4d v);
  879. void tnsApplyTransform44dTrue(tnsVector4d result, tnsMatrix44d mat, tnsVector4d v);
  880. void tnsLoadIdentity44d(tnsMatrix44d m);
  881. void tnsMakeOrthoMatrix44d(tnsMatrix44d mProjection, real xMin, real xMax, real yMin, real yMax, real zMin, real zMax);
  882. void tnsMakePerspectiveMatrix44d(tnsMatrix44d mProjection, real fFov_rad, real fAspect, real zMin, real zMax);
  883. void tnsMakeTranslationMatrix44d(tnsMatrix44d mTrans, real x, real y, real z);
  884. void tnsMakeRotationMatrix44d(tnsMatrix44d m, real angle_rad, real x, real y, real z);
  885. void tnsMakeScaleMatrix44d(tnsMatrix44d m, real x, real y, real z);
  886. void tnsMakeViewportMatrix44d(tnsMatrix44d m, real w, real h, real Far, real Near);
  887. void tnsInverse44d(tnsMatrix44d inverse, tnsMatrix44d mat);
  888. void tnsMultiply44d(tnsMatrix44d result, tnsMatrix44d l, tnsMatrix44d r);
  889. void tnsMakeRotationXMatrix44d(tnsMatrix44d m, real angle_rad);
  890. void tnsMakeRotationYMatrix44d(tnsMatrix44d m, real angle_rad);
  891. void tnsMakeRotationZMatrix44d(tnsMatrix44d m, real angle_rad);
  892. void tnsRemoveTranslation44d(tnsMatrix44d result, tnsMatrix44d mat);
  893. void tnsClearTranslation44d(tnsMatrix44d mat);
  894. real tnsAngleRad3d(tnsVector3d from, tnsVector3d to, tnsVector3d PositiveReference);
  895. real tnsLength3d(tnsVector3d l);
  896. void tnsNormalize2d(tnsVector2d result, tnsVector2d l);
  897. void tnsNormalize3d(tnsVector3d result, tnsVector3d l);
  898. void tnsNormalizeSelf3d(tnsVector3d result);
  899. real tnsDot3d(tnsVector3d l, tnsVector3d r, int normalize);
  900. real tnsVectorCross3d(tnsVector3d result, tnsVector3d l, tnsVector3d r);
  901. void tnsVectorCrossOnly3d(tnsVector3d result, tnsVector3d l, tnsVector3d r);
  902. void tnsExtractXYZEuler44d(tnsMatrix44d mat, real *x_result, real *y_result, real *z_result);
  903. void tnsPrintMatrix44d(tnsMatrix44d l);
  904. int tnsPointInsideTriangle3d(tnsVector3d v, tnsVector3d v0, tnsVector3d v1, tnsVector3d v2);
  905. int tnsIntersectPlaneRay(tnsVector3d n, tnsVector3d p0, tnsVector3d l0, tnsVector3d l, real* t);
  906. void tnsExtractXYZEuler44d(tnsMatrix44d mat, real *x_result, real *y_result, real *z_result);
  907. void tnsExtractLocation44d(tnsMatrix44d mat, real *x_result, real *y_result, real *z_result);
  908. void tnsExtractUniformScale44d(tnsMatrix44d mat, real *result);
  909. void tnsSelfMatrixChanged(tnsObject* o, int ApplyToChild);
  910. void tnsGlobalMatrixChanged(tnsObject* o, int ApplyToChild);
  911. void tnsSelfTransformValueChanged(tnsObject* o);
  912. void tnsGlobalTransformValueChanged(tnsObject* o);
  913. void tnsSetCurrentRoot(tnsObject *o);
  914. void tnsInitObjectBase(tnsObject *o, tnsObject *under, char *Name, int Type,
  915. real AtX, real AtY, real AtZ,
  916. real RotX, real RotY, real RotZ, real RotW, u8bit RotationMode,
  917. real Scale);
  918. tnsMeshObject *tnsLoadObjectFromFile(char *FileName);
  919. int tnsLoadExchange(char *FileName);
  920. tnsObject *tnsFindObject(char *Name, tnsObject *From);
  921. void tns_RegisterNodes();
  922. void tnsCopyObjectTransformationsLocal(tnsObject* to, tnsObject* from);
  923. void tnsCopyObjectTransformationsGlobal(tnsObject* to, tnsObject* from);
  924. void tnsRotateObjectGlobal(tnsObject *o, real x, real y, real z, real angle, real cx,real cy,real cz);
  925. void tnsRotateObjectLocal(tnsObject *o, real x, real y, real z, real angle, real gcx,real gcy,real gcz);
  926. void tnsRotateObjectLocalValues(tnsObject *o, real x, real y, real z);
  927. void tnsTranslateObjectGlobal(tnsObject *o, real x, real y, real z);
  928. void tnsTranslateObjectLocal(tnsObject *o, real x, real y, real z);
  929. void tnsMoveObjectLocal(tnsObject *o, real x, real y, real z);
  930. void tnsMoveObjectDelta(tnsObject *o, real x, real y, real z);
  931. void tnsMoveObjectGlobal(tnsObject *o, real x, real y, real z);
  932. void tnsScaleObject(tnsObject *o, real fac, real cx,real cy,real cz);
  933. void tnsScaleObjectDelta(tnsObject *o, real fac, real cx,real cy,real cz);
  934. int tnsCheckParentable(tnsObject* child, tnsObject* parent);
  935. void tnsParentObject(tnsObject *child, tnsObject *parent, int KeepTransform);
  936. void tnsUnparentObject(tnsObject *o, int KeepTransform);
  937. void tnsZoomViewingCamera(tnsCamera *c, real Ratio);
  938. void tnsRotateViewingCamera(tnsCamera *c, real x, real z);
  939. void tnsTranslateViewingCamera(tnsCamera *c, int ViewportW, int ViewportH, real x, real y);
  940. void tnsGetCameraMovingDeltas(tnsCamera *c, int ViewportW, int ViewportH, real x, real y, tnsVector4d p);
  941. laPropContainer* tnsget_ObjectType(tnsObject* o);
  942. void tnsDestroyRootObject(tnsObject *root);
  943. void tnsDestroyObject(tnsObject *o);
  944. tnsObject *tnsCreateRootObject(char *name);
  945. tnsCamera *tnsCreateCamera(tnsObject *under, char *Name, real FOV,
  946. real AtX, real AtY, real AtZ,
  947. real RotX, real RotY, real RotZ,
  948. real FocusDistance);
  949. tnsObject *tnsCreateEmpty(tnsObject *under, char *Name, real AtX, real AtY, real AtZ);
  950. tnsLight *tnsCreateLight(tnsObject *under, char *Name, real AtX, real AtY, real AtZ, real Strength, int UniDirectional);
  951. tnsMeshObject *tnsCreateMeshEmpty(tnsObject *under, char *Name, real AtX, real AtY, real AtZ);
  952. tnsMeshObject *tnsCreateMeshPlane(tnsObject *under, char *Name, real AtX, real AtY, real AtZ, real size);
  953. int tnsMergeMeshObjects(tnsMeshObject* into, tnsMeshObject* mo);
  954. tnsMeshObject* tnsDuplicateMeshObjects(tnsMeshObject* from);
  955. void tnsInitMeshPlane(tnsMeshObject* mo, real size);
  956. void tnsAddMMeshPlane(tnsMeshObject* mo, real size);
  957. int tnsAnyObjectsSelected(tnsObject* parent);
  958. void tnsDeselectAllObjects(tnsObject* parent);
  959. void tnsSelectAllObjects(tnsObject* parent);
  960. void tnsSelectObject(tnsObject* o, int Select, int Toggle);
  961. #define TNS_MMESH_EDGE_BIT 0x800000
  962. #define TNS_MMESH_FACE_BIT 0xC00000
  963. #define TNS_MMESH_TYPE_BIT (TNS_MMESH_FACE_BIT|TNS_MMESH_EDGE_BIT)
  964. tnsMFace* tnsMMeshNewFace(tnsMeshObject* mo);
  965. tnsMEdge* tnsMMeshNewEdge(tnsMeshObject* mo);
  966. tnsMVert* tnsMMeshNewVert(tnsMeshObject* mo);
  967. void tnsMMeshCalculateNormalFrom(tnsMFace* mf);
  968. int tnsMMeshCalculateNormal(tnsMeshObject* mo);
  969. void tnsMMeshEdgeAssignVerts(tnsMEdge* me,tnsMVert* mv1,tnsMVert* mv2);
  970. tnsMEdge* tnsMMeshVertShareEdge(tnsMVert* mv0, tnsMVert* mv1);
  971. int tnsMMeshEdgeHasVert(tnsMEdge* me, tnsMVert* MV);
  972. tnsMVert* tnsMMeshEdgeShareVert(tnsMEdge* me0, tnsMEdge* me1);
  973. tnsMVert* tnsMMeshEdgeAnotherVert(tnsMEdge* me, tnsVert* v);
  974. tnsMVert* tnsMMeshEdgeStartingVert(tnsMEdge* me0, tnsMEdge* me1);
  975. int tnsMMeshSplitFace(tnsMeshObject* mo, tnsMFace* mf, tnsMEdge* me, tnsMFace** r_f1, tnsMFace** r_f2);
  976. tnsMFace* tnsMMeshVertsShareFace(tnsMVert* v1, tnsMVert* v2);
  977. tnsMEdge* tnsMMeshMakeEdge(tnsMeshObject* mo, tnsMVert* v1, tnsMVert* v2);
  978. void tnsMMeshFaceAddEdge(tnsMFace* mf, tnsMEdge* me);
  979. int tnsMMeshFaceMatches(tnsMFace* mf, int ecount, ...);
  980. tnsMFace* tnsMMeshMakeFaceN(tnsMeshObject* mo, int count, laListHandle* vip, tnsMEdge** r_fallback_me);
  981. tnsMFace* tnsMMeshMakeFace4v(tnsMeshObject* mo, tnsVert* v1,tnsVert* v2,tnsVert* v3,tnsVert* v4);
  982. int tnsMMeshLoopIsInverted(laListItemPointer* l);
  983. int tnsMMeshEdgeInsertVert(tnsMeshObject* mo, tnsMEdge* me, tnsMVert* mv, tnsMVert* ref_e1v_optional, tnsMEdge** r_e1, tnsMEdge** r_e2);
  984. tnsMVert* tnsMMeshEdgeInsertVertAt(tnsMeshObject* mo, tnsMEdge* me, real at, tnsMVert* ref_e1v_optional, tnsMEdge** r_e1, tnsMEdge** r_e2);
  985. void tnsMMeshRemoveFaceOnly(tnsMeshObject* mo, tnsMFace* mf);
  986. void tnsMMeshRemoveEdgeFace(tnsMeshObject* mo, tnsMEdge* me);
  987. void tnsMMeshRemoveVertEdgeFace(tnsMeshObject* mo, tnsMVert* mv);
  988. void tnsMMeshRefreshIndex(tnsMeshObject* mo);
  989. void tnsMeshEnterEditMode(tnsMeshObject* mo);
  990. void tnsMeshLeaveEditMode(tnsMeshObject* mo);
  991. int tnsMMeshAnySelected(tnsMeshObject* mo);
  992. void tnsMMeshClearExtraFlags(tnsMeshObject* mo);
  993. void tnsMMeshDeselectAll(tnsMeshObject* mo);
  994. void tnsMMeshSelectAll(tnsMeshObject* mo);
  995. void tnsMMeshSelectVert(tnsMeshObject* mo, tnsMVert* mv, int select, int toggle);
  996. void tnsMMeshSelectEdge(tnsMeshObject* mo, tnsMEdge* me, int select, int toggle);
  997. void tnsMMeshEnsureSelectionFromVerts(tnsMeshObject* mo);
  998. void tnsMMeshEnsureSelectionFromEdges(tnsMeshObject* mo);
  999. void tnsMMeshEnsureSelection(tnsMeshObject* mo, int SelectMode);
  1000. void tnsInvalidateMeshBatch(tnsMeshObject* mo);
  1001. void tnsRegenerateMeshBatch(tnsMeshObject* mo);
  1002. void tnsEnsureMeshBatch(tnsMeshObject* mo);
  1003. void tnsDrawMeshObject(tnsMeshObject* mo, int DrawAsObjectSelection, int MeshSelectionMode, tnsMeshObject* Active);
  1004. void la_RegisterModellingOperators();
  1005. void tnsGetCameraProjection(tnsMatrix44d* mat, int w, int h, tnsCamera* Camera);
  1006. void tnsGetCameraViewProjection(tnsMatrix44d* mat, int w, int h, tnsCamera* Camera);
  1007. void tnsApplyCameraView(int W, int H, tnsCamera *Camera);
  1008. void tnsApplyShadowCameraView(tnsLight *Light);
  1009. void tnsApplyObjectMatrix(tnsObject *Object);
  1010. void tnsLookAt(tnsObject *o, tnsVector3d Target, tnsVector3d Up);
  1011. void tnsDrawThisObject(tnsObject *o, tnsObject *active, int DrawAsObjectSelection, int MeshSelectionMode);
  1012. void tnsDrawObjectTree(tnsObject *from, tnsObject *active, int DrawAsObjectSelection, int MeshSelectionMode);
  1013. void tnsDrawObjectOrigins(tnsObject *from, tnsObject *active, int AllOrigins);
  1014. void tnsDrawCursor(tnsObject* root);
  1015. void tnsDrawScene(int W, int H, tnsObject *root);
  1016. void tnsDrawWorld(int W, int H);
  1017. tnsMaterial *tnsCreateMaterial(char *Name);
  1018. tnsMaterial *tnsFindMaterialByIndex(int index);
  1019. tnsMaterial *tnsFindMaterial(char *name);
  1020. void tnsClearAll();
  1021. void tnsClearColorv(real *rgba);
  1022. void tnsClearColor(real r, real g, real b, real a);
  1023. void tnsSwitchToCurrentWindowContext(void *wnd);
  1024. void tnsRecalculateVertNormal(tnsVert *v);
  1025. void tnsRecalculateFaceAverageNormal(tnsFace *f);
  1026. int tnsLoadVectorGraphPackage(const char *name, unsigned int size);
  1027. real tnsGetMonoFontAdvance();
  1028. int tnsInvalidateFontCache();
  1029. int tnsLoadSystemFontMono(char* from, char* mono);
  1030. int tnsLoadSystemFont(char* from, char* name);
  1031. int tnsGetTextureMemoryComponetCount(tnsTexture *t);
  1032. void tnsUseNormal(int Use);
  1033. void tnsUniformUseOffset(tnsShader* s, int use);
  1034. tnsImage* tnsNewImage(void* MemPNG);
  1035. void tnsUseImage(tnsImage* im);
  1036. void tnsStopUsingImage(tnsImage* im);
  1037. void tnsSetRayShaderUniformTextures(tnsOffscreen* doff);
  1038. int tnsInit2DTexture(tnsTexture *t, GLint glInternalFormat, int w, int h, int Multisample);
  1039. tnsTexture *tnsCreate2DTexture(GLint glInternalFormat, int w, int h, int Multisample);
  1040. tnsTexture *tnsCreate3DTexture(GLint glInternalFormat, int w, int h, int slices);
  1041. void tnsConfigure2DTexture(tnsTexture *t);
  1042. void tnsConfigure3DTexture(tnsTexture *t);
  1043. void tnsReconfigureTextureParameters(int Multisample);
  1044. tnsOffscreen *tnsCreate2DOffscreen(int glInternalFormat, int w, int h, int Multisample, int WithDepth, int WithStencil);
  1045. tnsOffscreen *tnsCreateDeferredOffscreen(int w, int h, int Multisample);
  1046. void tnsCopyScreenTo2DTexture(tnsTexture *target, int x_lower_left, int y_lower_left, int w, int h);
  1047. void tnsActiveTexture(GLenum tex);
  1048. void tnsBindTexture(tnsTexture *t);
  1049. void tnsUnbindTexture();
  1050. void tnsUniformUseNormal(tnsShader* s, int Use);
  1051. void tnsUniformUseTexture(tnsShader* s, int mode, int sample);
  1052. void tnsUniformColorMode(tnsShader *s, int mode);
  1053. void tnsUniformHCYGamma(tnsShader* s, float Gamma);
  1054. void tnsUniformInputColorSpace(tnsShader* s, int ColorSpace);
  1055. void tnsUniformOutputColorSpace(tnsShader* s, int ColorSpace);
  1056. void tnsUniformShowColorOverflowStripes(tnsShader* s, int Show);
  1057. void tnsUniformUseMultiplyColor(tnsShader* s, int enable);
  1058. void tnsUseMaskTexture(tnsTexture *t);
  1059. void tnsUseTexture(tnsTexture *t);
  1060. void tnsUseNoTexture();
  1061. void tnsUseMultiplyColor(int enable);
  1062. void tnsDeleteTexture(tnsTexture *t);
  1063. void tnsDraw2DTextureDirectly(tnsTexture *t, real x, real y, real w, real h);
  1064. void tnsDraw2DTextureArg(tnsTexture *t,
  1065. real x_upper_right, real y_upper_right, int w, int h,
  1066. real *MultiplyColor,
  1067. real LPadding, real RPadding, real TPadding, real BPadding);
  1068. int tnsTextureMemorySize(tnsTexture *t, int mem);
  1069. void tnsCreateTextureReadbackBuffer(tnsTexture *t);
  1070. void tnsDeleteTextureReadbackBuffer(tnsTexture *t);
  1071. void tnsReadbackTexture(tnsTexture *t);
  1072. #define TNS_CLAMP_TEXTURE_W(t, Col) \
  1073. { \
  1074. if (Col >= t->Width) \
  1075. Col = t->Width - 1; \
  1076. if (Col < 0) \
  1077. Col = 0; \
  1078. }
  1079. #define TNS_CLAMP_TEXTURE_H(t, Row) \
  1080. { \
  1081. if (Row >= t->Height) \
  1082. Row = t->Height - 1; \
  1083. if (Row < 0) \
  1084. Row = 0; \
  1085. }
  1086. #define TNS_CLAMP_TEXTURE_CONTINUE(t, Col, Row) \
  1087. { \
  1088. if (Col >= t->Width) \
  1089. continue; \
  1090. if (Col < 0) \
  1091. continue; \
  1092. if (Row >= t->Height) \
  1093. continue; \
  1094. if (Row < 0) \
  1095. continue; \
  1096. }
  1097. void tnsDelete2DOffscreen(tnsOffscreen *o);
  1098. tnsOffscreen *tnsCreateOffscreenHandle();
  1099. void tnsConfigureOffscreen(tnsOffscreen *off, int w, int h);
  1100. void tnsAttach2DOffscreenBuffer(tnsOffscreen *target, GLuint attatchment, tnsTexture *use);
  1101. void tnsDetach2DOffscreenBuffer(tnsOffscreen *target, GLuint which_attach_point);
  1102. void tnsDrawToOffscreen(tnsOffscreen *toff, int HowMany, GLuint *AttachmentArray);
  1103. void tnsDrawToExtraColorAttachment(tnsOffscreen *toff);
  1104. void tnsDrawToExtraNormalAttachment(tnsOffscreen *toff);
  1105. void tnsDrawToAllExtraAttachments(tnsOffscreen *toff);
  1106. void tnsDrawToOffscreenOnlyBind(tnsOffscreen *toff, int HowMany, GLuint *AttachmentArray);
  1107. void tnsReadFromOffscreen(tnsOffscreen *toff);
  1108. void tnsPassColorBetweenOffscreens(tnsOffscreen *from, tnsOffscreen *to,
  1109. GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLenum FilterMode);
  1110. void tnsDrawToScreen();
  1111. //==============================================[STR]
  1112. int tnsUseFont(char *name);
  1113. int laStopFontService();
  1114. tnsFontSingleCharacter *tfntFetchVectorGraphTextureIDW(uint32_t ID);
  1115. int tnsStringGetDimension(char* content, uint32_t* contentU, int Count, int WLimit, int* Rows, int UseMono);
  1116. int tnsStringGetWidth(char *content, int Count, int UseMono);
  1117. int tnsStringGetWidthU(uint32_t *contentU, int Count, int UseMono);
  1118. void tnsDrawStringM(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags);
  1119. int tnsDrawLCD7_ProgressSystem(real x, real y, real Percent);
  1120. void tnsDrawStringLCD(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags);
  1121. void tnsDrawStringAutoM(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags);
  1122. void tnsDrawStringAuto(char *content, real Color[4], int L, int R, int T, int Flags);
  1123. void tnsDrawStringWithPriority(char *Label, char *MajorContent, real Color[4], int TextAlign, int L, int R, int T, int Flags);
  1124. void tnsDrawVectorGraphPackage(int ID, real Color[4], int L, int R, int T, int B, int Align, int Flags);
  1125. void tnsDrawIcon(uint32_t ID, real Color[4], int L,int R, int T, int Flags);
  1126. void tnsUseFontCoord(real x, real y, real size);
  1127. ///=================================
  1128. void tnsMakeTriangle(real *arr, real x1, real y1, real x2, real y2, real x3, real y3);
  1129. void tnsMakeQuad2d(real *arr, real x1, real y1, real x2, real y2, real x3, real y3, real x4, real y4);
  1130. void tnsMakeQuadT2d(real *arr, real x1, real y1, real x2, real y2, real x3, real y3, real x4, real y4);
  1131. void tnsMakeQuad3d(real *arr, real x1, real y1, real z1, real x2, real y2, real z2, real x3, real y3, real z3, real x4, real y4, real z4);
  1132. void tnsMakeQuad4d(real *arr, real x1, real y1, real z1, real w1, real x2, real y2, real z2, real w2, real x3, real y3, real z3, real w3, real x4, real y4, real z4, real w4);
  1133. void tnsMakeCircle2d(real *arr, int slices, real ctrX, real ctrY, real r, int jump);
  1134. void tnsMakeArc2d(real *arr, int slices, real ctrX, real ctrY, real r, real rad_begin, real rad_end);
  1135. void tnsMakeRing2d(real *arr, int *index, int slices, real ctrX, real ctrY, real r1, real r2);
  1136. void tnsMakeLinerGradient3d(real *arr, int num_points, real r0, real g0, real b0, real r1, real g1, real b1);
  1137. void tnsMakeLinerGradient4d(real *arr, int num_points, real r0, real g0, real b0, real a0, real r1, real g1, real b1, real a1);
  1138. void tnsMakeLinerGradient3dv(real *arr, int num_points, real *rgb0, real *rgb1);
  1139. void tnsMakeLinerGradient4dv(real *arr, int num_points, real *rgb0, real *rgb1);
  1140. void tnsMakeFoucsSquare(int L, int R, int U, int B, int W);
  1141. void tnsDrawFloor(real* CamPosition, real Far, int *ShowAxis);
  1142. void tnsDraw2DGrid10(real L, real R, real U, real B, real xmin, real xmax, real ymin, real ymax, real MostDenseW, real MostDenseH,
  1143. real* color4, real AlphaFactor, int ShowGrid, int TextAlign);
  1144. void tnsMakeIndexUInt(unsigned int *result, int num, ...);
  1145. void tnsMakeBridgedIndex(unsigned int *result, int num, int revert, int begin);
  1146. //================================
  1147. void DrawWireRect2dp(real x, real y, real x2, real y2);
  1148. void tnsViewportWithScissor(int x, int y, int w, int h);
  1149. void tnssRGB2XYZ(tnsVector3d rgb,tnsVector3d xyz);
  1150. void tnsClay2XYZ(tnsVector3d rgb,tnsVector3d xyz);
  1151. void tnsXYZ2sRGB(tnsVector3d xyz,tnsVector3d rgb);
  1152. void tnsXYZ2Clay(tnsVector3d xyz,tnsVector3d rgb);
  1153. void tnsRGB2Clay(tnsVector3d rgb, tnsVector3d clay);
  1154. void tnsClay2RGB(tnsVector3d clay, tnsVector3d rgb);
  1155. void tns2LogsRGBSingle(real* a);
  1156. void tns2LinearsRGBSingle(real* a);
  1157. void tns2LogsRGB(real* srgb);
  1158. void tns2LinearsRGB(real* srgb);
  1159. void tnsRGB2OKLAB(real* rgb, real* oklab);
  1160. void tnsOKLAB2RGB(real* oklab, real* rgb);
  1161. void tnsHCY2RGBLinear(real *hcy, real *rgb);
  1162. void tnsRGB2HCYLinear(real *rgb, real *hcy);
  1163. void tnsHCY2RGB(real *hcy, real *rgb);
  1164. void tnsRGB2HCY(real *rgb, real *hcy);
  1165. tnsLineStrip *tnsCreateLineStrip();
  1166. tnsLineStripPoint *tnsAppendPoint(tnsLineStrip *ls, real X, real Y, real Z);
  1167. tnsLineStripPoint *tnsPushPoint(tnsLineStrip *ls, real X, real Y, real Z);
  1168. void tnsRemovePoint(tnsLineStrip *ls, tnsLineStripPoint *lsp);
  1169. void tnsDestroyLineStrip(tnsLineStrip *ls);
  1170. void tnsGetGaussianKernel(tnsFilterKernel *fk, int size, real sigma);
  1171. void *tnsTextureSampleSafe(tnsTexture *t, int Col, int Row);
  1172. int tnsTextureSampleWeightSafe(tnsTexture *t, int Col, int Row, real Size, tnsVector2d Direction);
  1173. real tnsTextureSampleSafeGaussU8R(tnsTexture *t, tnsFilterKernel *fk, int Col, int Row);
  1174. void tnsTextureSetBitSafeU8R(tnsTexture *t, int Col, int Row, int Bit);
  1175. void tnsTextureSetRGBSafeU8R(tnsTexture *t, int Col, int Row, u8bit r, u8bit g, u8bit b);
  1176. u8bit *tnsTextureSampleU8(tnsTexture *t, int Col, int Row);