*/}}

la_tns.h 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284
  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. STRUCTURE(tnsCommand){
  96. GLenum Mode;
  97. short Dimensions; // 2 or 3
  98. short UVDimensions; // 2 or 3
  99. char UseVert;
  100. char UseColor;
  101. char UseNormal;
  102. char UseTexCoord;
  103. char UseIndex;
  104. GLenum PolyMode; //0-solid 1-wire
  105. GLenum Shade; //0-falt 1-smooth
  106. GLfloat UniformColor[4];
  107. int NumVert;
  108. int NumIndex;
  109. int VertBegin;
  110. int VertEnd; //'END'is the next one after the last one.
  111. int ColorBegin;
  112. int ColorEnd;
  113. int TexCoordBegin;
  114. int TexCoordEnd;
  115. int NormalBegin;
  116. int NormalEnd;
  117. GLushort IndexBegin;
  118. GLushort IndexEnd;
  119. tnsShader *ReplaceShader;
  120. tnsTexture *ColorTexture;
  121. int TextureMode;
  122. int MultiplyColor;
  123. GLfloat LineWidth,PointSize;
  124. };
  125. typedef struct _tnsMain tnsMain;
  126. typedef struct _tnsWorld tnsWorld;
  127. typedef struct _tnsObject tnsObject;
  128. struct _tnsWorld
  129. {
  130. laListItem Item;
  131. laListHandle RootObjects;
  132. tnsObject *ActiveRoot;
  133. laListHandle AllObjects;
  134. laListHandle Materials;
  135. u16bit TimeYear;
  136. u8bit TimeMonth;
  137. u8bit TimeDay;
  138. laListHandle BezierCurves;
  139. laListHandle Meshes;
  140. };
  141. NEED_STRUCTURE(tnsLoopItem);
  142. NEED_STRUCTURE(tnsRenderLine);
  143. NEED_STRUCTURE(tnsRenderBuffer);
  144. STRUCTURE(tnsImage){
  145. laListItem Item;
  146. void* MemPNG;
  147. tnsTexture* Texture;
  148. int UserCount;
  149. };
  150. struct _tnsMain {
  151. laListItem Item;
  152. tnsMatrixStack stack;
  153. int vsx,vsy,vsw,vsh;//for saving scissor etc.
  154. int vol,vor,vou,vob;//for saving ortho etc.
  155. laListHandle Shaders;
  156. int NextShaderIndex;
  157. tnsShader *CurrentShader;
  158. tnsShader *BindedShader;
  159. //int MatrixMode;
  160. int IsOffscreen;
  161. laListHandle Offscreens;
  162. char *GLVersionStr;
  163. char *GLVendorStr;
  164. char *GLRendererStr;
  165. char *GLSLVersionStr;
  166. tnsShader* immShader;
  167. tnsShader* RayShader;
  168. tnsShader* ShadowShader;
  169. tnsShader* SceneShader;
  170. tnsShader* SelectionShader;
  171. tnsShader* FloorShader;
  172. int GlobalVAO;
  173. tnsShader *uiShader;
  174. tnsShader *stringShader;
  175. tnsShader *TextureShader;
  176. tnsShader *RectangleTextureShader;
  177. tnsShader *TextureMultiplyShader;
  178. tnsShader *MSTextureShader;
  179. tnsShader *MSATextureShader;
  180. tnsShader *TEST_MatcapShader;
  181. tnsShader *TransparentGridShader;
  182. tnsShader *SobelColorShader;
  183. tnsShader *SobelShader;
  184. tnsShader *ExtraBuffersShader;
  185. laListHandle Textures;
  186. tnsTexture *PreviewTexture;
  187. GLenum GlTextureSets;
  188. // Corresponds to current GL_TEXTURE0/1...
  189. tnsTexture *TexColor;
  190. tnsTexture *TexRenderbuffer;
  191. // For commands
  192. tnsTexture *StateTexColor;
  193. int StateTextureMode;
  194. int StateMultiplyColor;
  195. int StateUseNormal;
  196. int SetUseNormal;
  197. tnsShader* StateShader;
  198. GLfloat StateColor[4];
  199. GLfloat StateLineWidth,SetLineWidth;
  200. GLfloat StatePointSize,SetPointSize;
  201. GLfloat* Vert;
  202. GLuint VertBufObject;
  203. int NextVert, MaxVert;
  204. GLfloat* Color;
  205. GLuint ColorBufObject;
  206. int NextColor, MaxColor;
  207. GLfloat* Normal;
  208. GLuint NormalBufObject;
  209. int NextNormal, MaxNormal;
  210. GLfloat* TexCoord;
  211. GLuint TexCoordBufObject;
  212. int NextTexCoord, MaxTexCoord;
  213. GLuint* Index;
  214. GLuint IndexBufObject;
  215. int NextIndex, MaxIndex;
  216. tnsCommand* DrawingCommand;
  217. int NextCommand, MaxCommand;
  218. tnsWorld* World;
  219. laListHandle RenderBuffers;
  220. tnsRenderBuffer *ActiveRenderBuffer;
  221. laListHandle Images;
  222. };
  223. typedef struct _tnsTexture tnsTexture;
  224. struct _tnsTexture
  225. {
  226. laListItem Item;
  227. int IsRenderBuffer;
  228. GLuint GLTexHandle;
  229. GLint GLTexBitsType; //like GL_RGBA
  230. GLuint GLTexType; //like GL_TEXTURE_2D
  231. int Multisample;
  232. int Width;
  233. int Height;
  234. int Slices;
  235. void *DrawData;
  236. int RBWidth, RBHeight;
  237. int ElemSize;
  238. void *TextureReadBack;
  239. void **SamplePtr;
  240. laListHandle PendingSamples;
  241. laListHandle ErasedSamples;
  242. laListHandle LineStrips;
  243. };
  244. typedef struct _tnsOffscreen tnsOffscreen;
  245. struct _tnsOffscreen
  246. {
  247. laListItem Item;
  248. tnsTexture *pColor[16];
  249. tnsTexture *pDepth;
  250. GLuint FboHandle;
  251. int UseSecondary;
  252. };
  253. extern const GLuint TNS_ATTACHMENT_ARRAY_NONE[];
  254. extern const GLuint TNS_ATTACHMENT_ARRAY[];
  255. extern const GLuint TNS_ATTACHMENT_ARRAY_1[];
  256. extern const GLuint TNS_ATTACHMENT_ARRAY_2[];
  257. extern const GLuint TNS_ATTACHMENT_ARRAY_1_2[];
  258. extern const GLuint TNS_ATTACHMENT_ARRAY_0_1_2[];
  259. extern const GLenum TNS_WINDOW_DRAWBUFFER_ARRAY[];
  260. #define TNS_PROJECTION_MATRIX 1
  261. #define TNS_MODEL_MATRIX 2
  262. #define TNS_VIEW_MATRIX 3
  263. #define TNS_TEXTURE_MATRIX 4
  264. //==========================================================================[FT]
  265. #include "freetype/ftglyph.h"
  266. #include "freetype/ftoutln.h"
  267. #include "freetype/fttrigon.h"
  268. #include "ft2build.h"
  269. #include <stdarg.h>
  270. #include <stdlib.h>
  271. #include <string.h>
  272. NEED_STRUCTURE(tnsTexture);
  273. typedef struct _tnsFontSingleCharacter tnsFontSingleCharacter;
  274. struct _tnsFontSingleCharacter
  275. {
  276. tnsTexture *Tex;
  277. int Generated;
  278. short width;
  279. short height;
  280. real advx;
  281. short advy;
  282. short deltax;
  283. short deltay;
  284. short bufferx;
  285. short buffery;
  286. };
  287. #define TNS_UNICODE_COUNT ((unsigned int)(1<<17))
  288. #define TNS_MONO_COUNT (0x045f)
  289. typedef struct _tnsFont tnsFont;
  290. struct _tnsFont
  291. {
  292. laListItem Item;
  293. char *fontName;
  294. char *IconFontName;
  295. tnsFontSingleCharacter** characters; /* [(1<<17)] TNS_UNICODE_COUNT Unicode plane 0-1 */
  296. tnsFontSingleCharacter** monocharacters; /* [0x045f] TNS_MONO_COUNT Up to cryllic. */
  297. FT_Library ftlib;
  298. FT_Face ftface[16];
  299. FT_Face ftfacemono;
  300. int NumFaces;/* excludes mono. */
  301. real MonoScale;
  302. real MonoAdvance;
  303. real size;
  304. unsigned int height;
  305. tnsTexture TexBuffer;
  306. int CurrentX;
  307. int CurrentY;
  308. };
  309. typedef struct _tnsFontManager tnsFontManager;
  310. struct _tnsFontManager
  311. {
  312. laListHandle Fonts;
  313. tnsFont *UsingFont;
  314. tnsFont *VectorsGrapghs;
  315. unsigned LastDlst;
  316. };
  317. typedef struct _tnsFontBoundBox tnsFontBoundBox;
  318. struct _tnsFontBoundBox
  319. {
  320. int x, y, w, h; /* Upper Left and width,height */
  321. };
  322. #define TNS_FONT_BUFFER_W 512
  323. #define TNS_FONT_BUFFER_H 512
  324. //=====================================================[3d comp]
  325. typedef struct _tnsWorld tnsWorld;
  326. typedef struct _tnsObject tnsObject;
  327. #define TNS_ROTATION_XYZ_EULER 0
  328. #define TNS_ROTATION_XZY_EULER 1
  329. #define TNS_ROTATION_YXZ_EULER 2
  330. #define TNS_ROTATION_YZX_EULER 3
  331. #define TNS_ROTATION_ZXY_EULER 4
  332. #define TNS_ROTATION_ZYX_EULER 5
  333. #define TNS_ROTATION_QUATERNION 6
  334. #define TNS_OBJECT_ROOT 0
  335. #define TNS_OBJECT_INSTANCER (1<<0)
  336. #define TNS_OBJECT_CAMERA (1<<1)
  337. #define TNS_OBJECT_LIGHT (1<<2)
  338. #define TNS_OBJECT_MESH (1<<3)
  339. #define TNS_OBJECT_FLAGS_SELECTED (1<<0)
  340. #define TNS_OBJECT_FLAGS_PLAY_DUPLICATE (1<<1)
  341. NEED_STRUCTURE(tnsBatch)
  342. #define TNS_EVAL_LAYER_SOLID (1<<0)
  343. #define TNS_EVAL_LAYER_OVERLAY (1<<1)
  344. #define TNS_EVAL_LAYER_OUTLINE (1<<2)
  345. #define TNS_EVAL_LAYER_SELECTION (1<<3)
  346. #define TNS_EVAL_MODE_INIT (1<<0)
  347. #define TNS_EVAL_MODE_ALWAYS (1<<1)
  348. #define TNS_EvAL_MODE_DEINIT (1<<2)
  349. NEED_STRUCTURE(tnsEvaluatedInstance);
  350. typedef void (*tnsDrawEvaluatedInstanceF)(tnsEvaluatedInstance* ei, void* CustomData);
  351. STRUCTURE(tnsEvaluatedNode){
  352. laListItem Item;
  353. tnsMatrix44d Mat;
  354. tnsObject* Target;
  355. laListHandle Children;
  356. };
  357. STRUCTURE(tnsEvaluatedScene){
  358. tnsEvaluatedNode* Root;
  359. tnsEvaluatedNode* CurrentParent;
  360. tnsEvaluatedNode* CurrentChild;
  361. };
  362. STRUCTURE(tnsEvaluatedInstance){
  363. tnsObject *Object;
  364. tnsMatrix44d Mat;
  365. int IsActive;
  366. int MeshSelectionType;
  367. int InstanceSelectionID;
  368. tnsDrawEvaluatedInstanceF Draw;
  369. };
  370. STRUCTURE(tnsEvaluateData){
  371. int Done;
  372. int SceneEvaluateMode;
  373. tnsObject *Active;
  374. int FillOutline;
  375. int FillSelectionID;
  376. int OverrideID;
  377. tnsEvaluatedInstance* Commands; int NextCommand, MaxCommand;
  378. tnsEvaluatedInstance* Outlines; int NextOutline, MaxOutline;
  379. tnsEvaluatedInstance* Overlays; int NextOverlay, MaxOverlay;
  380. tnsEvaluatedInstance* Selections; int NextSelection, MaxSelection;
  381. tnsMatrix44d* MatArr; int NextMat, MaxMat;
  382. tnsEvaluatedScene* Scene;
  383. };
  384. NEED_STRUCTURE(laRackPageCollection);
  385. STRUCTURE(tnsObject){
  386. laListItem Item;
  387. int Type;
  388. int SelectID;
  389. int Flags;
  390. //u64bit ID;
  391. laSafeString *Name;
  392. int DrawMode;
  393. int Show;
  394. int ShowOnRender;
  395. int HideChildren;
  396. int RotationMode;
  397. int IsInstanced;
  398. real GLocation[3];
  399. real GRotation[3];
  400. real GScale;//Only allow uniform scale
  401. real Location[3];
  402. real Rotation[4];
  403. real Scale;
  404. // delta transforms for animation & drivers.
  405. real DLocation[3];
  406. real DRotation[3];
  407. real DScale;
  408. tnsMatrix44d GlobalTransform;
  409. tnsMatrix44d SelfTransform;
  410. tnsMatrix44d DeltaTransform;
  411. tnsObject *Active; // may be used to store last select info in child objects.
  412. tnsObject *InRoot;
  413. tnsObject *ParentObject; // reused as root active sun.
  414. laListHandle ChildObjects;
  415. laRackPageCollection* Drivers; // rack
  416. laListHandle Actions;
  417. tnsEvaluateData Evaluated; // runtime
  418. tnsEvaluateData EvaluatedPlay;
  419. tnsObject* PlayDuplicate;
  420. };
  421. NEED_STRUCTURE(laNodeInSocket);
  422. NEED_STRUCTURE(laNodeOutSocket);
  423. STRUCTURE(tnsTransformNode){
  424. laBaseNode Base;
  425. laNodeInSocket* Mat;
  426. tnsObject* Target;
  427. };
  428. STRUCTURE(tnsMakeTransformNode){
  429. laBaseNode Base;
  430. laNodeInSocket* Loc; laNodeInSocket* Rot; laNodeInSocket* Angle; laNodeInSocket* Sca;
  431. laNodeOutSocket* Out;
  432. tnsMatrix44d Mat; tnsVector3d UseLoc; tnsVector3d UseRot; real UseSca; real UseAngle;
  433. };
  434. #define TNS_CAMERA_PERSP 0
  435. #define TNS_CAMERA_ORTHO 1
  436. #define TNS_ID_TO_COLOR(color, i) \
  437. {color[0]=(real)((i & 0x000000FF)>>0)/255.0; color[1]=(real)((i & 0x0000FF00)>>8)/255.0; color[2]=(real)((i & 0x00FF0000)>>16)/255.0;}
  438. #define TNS_MATERIAL_DRAW_MODE_SOLID 0
  439. #define TNS_MATERIAL_DRAW_MODE_WIRE 1
  440. typedef struct _tnsMaterial tnsMaterial;
  441. struct _tnsMaterial
  442. {
  443. laListItem Item;
  444. laSafeString *Name;
  445. int ID;
  446. int DrawMode;
  447. real Color[4];
  448. real LinearColor[4];
  449. real SpectacularColor[4];
  450. real ReflexThreshold;
  451. real ReflexStrengh;
  452. real ReflexSharpeness;
  453. real LowBrightnessColor[4]; //Windows are lighten up in the evenings
  454. u8bit HaloMode;
  455. };
  456. #define TNS_CAMERA_PERSPECTIVE 0
  457. #define TNS_CAMERA_ORTHO 1
  458. #define TNS_CAMERA_FISHEYE 2
  459. STRUCTURE(tnsInstancer){
  460. tnsObject Base;
  461. tnsObject* Instance;
  462. };
  463. STRUCTURE(tnsCamera){
  464. tnsObject Base;
  465. int CameraType;
  466. real FOV;
  467. real ZMin, ZMax;
  468. real FocusDistance;
  469. real OrthScale;
  470. tnsVector3d RenderViewDir;
  471. };
  472. STRUCTURE(tnsLight){
  473. tnsObject Base;
  474. int LightType;
  475. int UniDirectional;
  476. real Strength;
  477. tnsMaterial *Material;
  478. };
  479. #define TNS_MESH_FLAG_SELECTED (1<<0)
  480. #define TNS_MESH_FLAG_PICKED (1<<1)
  481. #define TNS_MESH_FLAG_LOOP_REVERSE (1<<2)
  482. STRUCTURE(tnsMVert){
  483. laListItem Item;
  484. tnsVector3d p;
  485. tnsVector3d n;
  486. int flags;
  487. u32bit i;
  488. laListHandle elink;
  489. //laListHandle flink;
  490. };
  491. NEED_STRUCTURE(tnsMFace);
  492. STRUCTURE(tnsMEdge){
  493. laListItem Item;
  494. tnsMVert *vl;
  495. tnsMVert *vr;
  496. tnsMFace *fl;
  497. tnsMFace *fr;
  498. u32bit i;
  499. int flags;
  500. };
  501. STRUCTURE(tnsMFace){
  502. laListItem Item;
  503. laListHandle l; //list item pointer of edges
  504. tnsVector3d n;
  505. tnsVector3d c;
  506. short looplen;
  507. short mat;
  508. u32bit i;
  509. int flags;
  510. };
  511. STRUCTURE(tnsVert){
  512. tnsVector3f p;
  513. tnsVector3f n;
  514. int flags;
  515. };
  516. STRUCTURE(tnsEdge){
  517. int l,r;
  518. int flags;
  519. };
  520. STRUCTURE(tnsFace){
  521. int* loop;
  522. int flags;
  523. tnsVector3f n;
  524. short looplen;
  525. };
  526. STRUCTURE(tnsBatchCommand){
  527. laListItem Item;
  528. char* name;
  529. int DrawElements;
  530. GLuint EBO; //elem
  531. u32bit ElementCount;
  532. GLenum DrawAs;
  533. GLuint CBO; int ColorDimension; int OverrideColorArray;
  534. int Dimension;
  535. int HiddenByDefault;
  536. int UseUniformColor; real UniformColor[4];
  537. real Width;
  538. };
  539. STRUCTURE(tnsBatch){
  540. laListItem Item;
  541. GLuint VBO; //vert
  542. GLuint NBO; int HasNormal; //normal
  543. GLuint CBO; int HasColor; //color
  544. u32bit NumVert;
  545. int Dimension;
  546. int NormalDimension;
  547. int ColorDimension;
  548. laListHandle Branches;
  549. GLuint BeginElementOffset;
  550. };
  551. #define TNS_MESH_OBJECT_MODE 0
  552. #define TNS_MESH_EDIT_MODE 1
  553. extern laPropContainer* TNS_PC_OBJECT_GENERIC;
  554. extern laPropContainer* TNS_PC_OBJECT_INSTANCER;
  555. extern laPropContainer* TNS_PC_OBJECT_CAMERA;
  556. extern laPropContainer* TNS_PC_OBJECT_LIGHT;
  557. extern laPropContainer* TNS_PC_OBJECT_MESH;
  558. #define TNS_HINT_TRANSFORM (1<<1)
  559. #define TNS_HINT_GEOMETRY (1<<0)
  560. STRUCTURE(tnsMeshFaceStorageSingleHead){
  561. int looplen, flags; //[1] [5] [4] [2] ... [-1 as end]
  562. };
  563. STRUCTURE(tnsMeshFaceStorage){
  564. int len; int arr;
  565. };
  566. STRUCTURE(tnsMeshObject){
  567. tnsObject Base;
  568. tnsVert* v; int totv, maxv;
  569. tnsEdge* e; int tote, maxe; // I intend this to only stores floating edges.
  570. tnsFace* f; int totf, maxf;
  571. laListHandle mv; int totmv;
  572. laListHandle me; int totme;
  573. laListHandle mf; int totmf;
  574. int TriangleCount;
  575. int TriangulatedEdgeCount;
  576. tnsMVert* LastSelectV, *FirstSelectV;
  577. tnsMEdge* LastSelectE, *FirstSelectE;
  578. tnsBatch *Batch;
  579. tnsBatch *ExtraBatch;
  580. int Mode;
  581. };
  582. STRUCTURE(tnsEdgeHashEdge){
  583. int tv; tnsMEdge* me;
  584. };
  585. STRUCTURE(tnsEdgeHashVert){
  586. tnsEdgeHashEdge* e; int max, next; tnsMVert* mv;
  587. };
  588. STRUCTURE(tnsEdgeHash){
  589. tnsEdgeHashVert* vl; int max,next;
  590. };
  591. #define TNS_TILE(tile, r, c, CCount) \
  592. tile[r * CCount + c]
  593. #define TNS_CLAMP(a, Min, Max) \
  594. a = a < Min ? Min : (a > Max ? Max : a)
  595. #define TNS_MAX2(a, b) \
  596. (a > b ? a : b)
  597. #define TNS_MIN2(a, b) \
  598. (a < b ? a : b)
  599. #define TNS_MAX3(a, b, c) \
  600. (a > TNS_MAX2(b, c) ? a : TNS_MAX2(b, c))
  601. #define TNS_MIN3(a, b, c) \
  602. (a < TNS_MIN2(b, c) ? a : TNS_MIN2(b, c))
  603. #define TNS_MAX2_INDEX(a, b) \
  604. (a > b ? 0 : 1)
  605. #define TNS_MIN2_INDEX(a, b) \
  606. (a < b ? 0 : 1)
  607. #define TNS_MAX3_INDEX(a, b, c) \
  608. (a > b ? (a > c ? 0 : (b > c ? 1 : 2)) : (b > c ? 1 : 2))
  609. #define TNS_MIN3_INDEX(a, b, c) \
  610. (a < b ? (a < c ? 0 : (b < c ? 1 : 2)) : (b < c ? 1 : 2))
  611. #define TNS_MAX3_INDEX_ABC(x, y, z) \
  612. (x > y ? (x > z ? a : (y > z ? b : c)) : (y > z ? b : c))
  613. #define TNS_MIN3_INDEX_ABC(x, y, z) \
  614. (x < y ? (x < z ? a : (y < z ? b : c)) : (y < z ? b : c))
  615. #define TNS_ABC(index) \
  616. (index == 0 ? a : (index == 1 ? b : c))
  617. #define TNS_DOUBLE_CLOSE_ENOUGH(a, b) \
  618. (((a) + DBL_EDGE_LIM) >= (b) && ((a)-DBL_EDGE_LIM) <= (b))
  619. //#define TNS_DOUBLE_CLOSE_ENOUGH(a,b) \
  620. //(((a)+0.00000000001)>=(b) && ((a)-0.0000000001)<=(b))
  621. #define TNS_FLOAT_CLOSE_ENOUGH_WIDER(a, b) \
  622. (((a) + 0.0000001) >= (b) && ((a)-0.0000001) <= (b))
  623. #define TNS_FRAMEBUFFER_PIXEL(FrameBuffer, Row, Column) \
  624. &((FrameBuffer)->Pixels[Row * FrameBuffer->TileSizeW * FrameBuffer->W * FrameBuffer->SubPixelSample + Column * FrameBuffer->H * FrameBuffer->TileSizeH * FrameBuffer->SubPixelSample])
  625. #define TNS_IN_TILE_X(RenderTile, Fx) \
  626. (RenderTile->FX <= Fx && RenderTile->FXLim >= Fx)
  627. #define TNS_IN_TILE_Y(RenderTile, Fy) \
  628. (RenderTile->FY <= Fy && RenderTile->FYLim >= Fy)
  629. #define TNS_IN_TILE(RenderTile, Fx, Fy) \
  630. (TNS_IN_TILE_X(RenderTile, Fx) && TNS_IN_TILE_Y(RenderTile, Fy))
  631. void tnsSetuptnsFontManager();
  632. tnsShader *tnsNewShaderProgram(int VertexShaderID, int FragmentShaderID, int GeometryShaderID);
  633. int tnsNewGeometryShader(char *Content);
  634. int tnsNewFragmentShader(char *Content);
  635. int tnsNewVertexShader(char *Content);
  636. void tnsDeleteShaderProgram(tnsShader* s);
  637. int tnsNextPowOf2(int i);
  638. int tnsEnableShader(int index);
  639. int tnsEnableShaderv(tnsShader *shader);
  640. int tnsUseShader(tnsShader *shader);
  641. void tnsUseImmShader();
  642. void tnsUseShadowShader();
  643. void tnsUseSceneShader();
  644. void tnsUseRayShader();
  645. void tnsUseTransparentGridShader();
  646. void tnsUseImagePeelShader();
  647. void tnsInitRenderKernel(int matrixStackLevel);
  648. void tnsInitBuiltinShaders();
  649. void tnsInitWindowDefaultRenderConfig();
  650. void tnsQuit();
  651. void tnsRestoreFromNanoVG();
  652. real *tnsGetModelMatrix();
  653. real *tnsGetViewMatrix();
  654. real *tnsGetProjectionMatrix();
  655. void tnsGetMVMatrix(tnsMatrix44d r);
  656. void tnsGetMVPMatrix(tnsMatrix44d r);
  657. void tnsResetModelMatrix();
  658. void tnsResetViewMatrix();
  659. void tnsResetProjectionMatrix();
  660. void tnsOrtho(real xMin, real xMax, real yMin, real yMax, real zMin, real zMax);
  661. void tnsPerspective(real fFov_rad, real fAspect, real zMin, real zMax);
  662. void tnsPopMatrix();
  663. void tnsPushMatrix();
  664. void tnsTranslate3d(real x, real y, real z);
  665. void tnsPreTranslate3d(real x, real y, real z);
  666. void tnsRotate4d(real degrees, real x, real y, real z);
  667. void tnsPreRotate4d(real degrees, real x, real y, real z);
  668. void tnsScale3d(real x, real y, real z);
  669. void tnsPreScale3d(real x, real y, real z);
  670. void tnsColor4d(real r, real g, real b, real a);
  671. void tnsColor4dv(real *rgba);
  672. void tnsLineWidth(real Width);
  673. void tnsPointSize(real PointSize);
  674. tnsBatch *tnsCreateBatch(u32bit NumVert, int Dimension, float *Data, int NormalDimension, float *Normal, int ColorDimension, float *Colors);
  675. tnsBatch *tnsCreateBatchi(u32bit NumVert, int Dimension, int *Data);
  676. void tnsCommandUseWidth(tnsBatchCommand*c, real width);
  677. void tnsCommandUseUniformColor(tnsBatchCommand*c,real* color);
  678. void tnsCommandOverrideColorArray(tnsBatchCommand*c, int VertCount, int ColorDimension, float* colors);
  679. tnsBatchCommand *tnsCreateCommand(tnsBatch *b, const char* name, u32bit ElementCount, int Dimension, GLenum DrawAs, u32bit *Elements, int HiddenByDefault);
  680. void tnsDeleteBatch(tnsBatch *b);
  681. void tnsDrawBatch(tnsBatch* batch, const char* OverrideCommand, real* OverrideUniformColor, int OverrideAsArray);
  682. void tnsVertex3d(real x, real y, real z);
  683. void tnsVertex2d(real x, real y);
  684. void tnsVertexArray2d(real *verts, int amount);
  685. void tnsVertexArray3d(real *verts, int amount);
  686. void tnsColorArray4d(real *colors, int amount);
  687. void tnsNormalArray3d(real *normals, int amount);
  688. void tnsTexCoordArray2d(real *coords, int amount);
  689. void tnsTexCoordArray3d(real *coords, int amount);
  690. void tnsIndexArray(GLuint *index, short amount);
  691. void tnsPackAs(GLenum Mode);
  692. void tnsFlush();
  693. #define tnsLinearItp(L, R, T) \
  694. ((L) * (1.0f - (T)) + (R) * (T))
  695. double tnsGetRatiod(real L, real R, real FromL);
  696. void tnsShaderApplyProjectionInverse(tnsShader *tns, tnsMatrix44d m);
  697. void tnsShaderApplyProjection(tnsShader *tns, tnsMatrix44d m);
  698. void tnsShaderApplyModel(tnsShader *tns, tnsMatrix44d m);
  699. void tnsShaderApplyView(tnsShader *tns, tnsMatrix44d m);
  700. void tnsShaderApplyNormalScaler(tnsShader *tns, tnsMatrix44d m);
  701. int tnsLineIntersectTest2d(tnsVector2d a1, tnsVector2d a2, tnsVector2d b1, tnsVector2d b2, double *aRatio);
  702. double tnsGetLineZ(tnsVector3d L, tnsVector3d R, real Ratio);
  703. double tnsGetLineZPoint(tnsVector3d L, tnsVector3d R, tnsVector3d FromL);
  704. double tnsGetRatio3d(tnsVector3d L, tnsVector3d R, tnsVector3d FromL);
  705. double tnsGetRatiod(real L, real R, real FromL);
  706. real tnsInterpolate(real L, real R, real T);
  707. void tnsInterpolate2dv(real *L, real *R, real T, real *Result);
  708. void tnsInterpolate3dv(real *L, real *R, real T, real *Result);
  709. void tnsInterpolateTripple2d(tnsVector2d v1, tnsVector2d v2, tnsVector2d v3, real ratio, tnsVector2d result);
  710. void tnsVectorMinus2d(tnsVector2d result, tnsVector2d l, tnsVector2d r);
  711. void tnsVectorMinus3d(tnsVector3d result, tnsVector3d l, tnsVector3d r);
  712. void tnsVectorSubtract3d(tnsVector3d l, tnsVector3d r);
  713. void tnsVectorPlus3d(tnsVector3d result, tnsVector3d l, tnsVector3d r);
  714. void tnsVectorAccum3d(tnsVector3d l, tnsVector3d r);
  715. void tnsVectorAccum2d(tnsVector2d l, tnsVector2d r);
  716. void tnsVectorNegate3d(tnsVector3d result, tnsVector3d l);
  717. void tnsVectorNegateSelf3d(tnsVector3d l);
  718. void tnsVectorCopy2d(tnsVector2d from, tnsVector2d to);
  719. void tnsVectorCopy3d(tnsVector3d from, tnsVector3d to);
  720. void tnsVectorCopy4d(tnsVector4d from, tnsVector4d to);
  721. void tnsVectorMultiSelf4d(tnsVector4d from, real num);
  722. void tnsVectorMultiSelf3d(tnsVector3d from, real num);
  723. void tnsVectorMultiSelf2d(tnsVector2d from, real num);
  724. void tnsVectorMulti4d(tnsVector4d to, tnsVector4d from, real num);
  725. void tnsVectorMulti3d(tnsVector3d to, tnsVector3d from, real num);
  726. void tnsVectorMulti2d(tnsVector2d to, tnsVector2d from, real num);
  727. real tnsDirectionToRad(tnsVector2d Dir);
  728. void tnsConvert44df(tnsMatrix44d from, tnsMatrix44f to);
  729. #define tnsVectorSet2(to, x,y) \
  730. {(to)[0]=x;(to)[1]=y;}
  731. #define tnsVectorSet3(to, x,y,z) \
  732. {(to)[0]=x;(to)[1]=y;(to)[2]=z;}
  733. #define tnsVectorSet4(to, x,y,z,w) \
  734. {(to)[0]=x;(to)[1]=y;(to)[2]=z;(to)[3]=w;}
  735. #define tnsVectorSet2v(to, from) \
  736. tnsVectorSet2(to,(from)[0],(from)[1])
  737. #define tnsVectorSet3v(to, from) \
  738. tnsVectorSet3(to,(from)[0],(from)[1],(from)[2])
  739. #define tnsVectorSet4v(to, from) \
  740. tnsVectorSet4(to,(from)[0],(from)[1],(from)[2],(from)[3])
  741. real tnsDistIdv2(real x1, real y1, real x2, real y2);
  742. real tnsDist3dv(tnsVector3d l, tnsVector3d r);
  743. real tnsDist2dv(tnsVector2d l, tnsVector2d r);
  744. real tnsLength3d(tnsVector3d l);
  745. real tnsLength2d(tnsVector3d l);
  746. void tnsNormalize3d(tnsVector3d result, tnsVector3d l);
  747. void tnsNormalizeSelf2d(tnsVector3d result);
  748. void tnsNormalizeSelf3d(tnsVector3d result);
  749. real tnsDot3d(tnsVector3d l, tnsVector3d r, int normalize);
  750. real tnsDot2d(tnsVector2d l, tnsVector2d r, int normalize);
  751. real tnsVectorCross3d(tnsVector3d result, tnsVector3d l, tnsVector3d r);
  752. real tnsAngleRad3d(tnsVector3d from, tnsVector3d to, tnsVector3d PositiveReference);
  753. void tnsApplyRotation33d(tnsVector3d result, tnsMatrix44d mat, tnsVector3d v);
  754. void tnsApplyRotation43d(tnsVector3d result, tnsMatrix44d mat, tnsVector3d v);
  755. void tnsApplyTransform43d(tnsVector3d result, tnsMatrix44d mat, tnsVector3d v);
  756. void tnsApplyNormalTransform43d(tnsVector3d result, tnsMatrix44d mat, tnsVector3d v);
  757. void tnsApplyTransform44d(tnsVector4d result, tnsMatrix44d mat, tnsVector4d v);
  758. void tnsApplyTransform44dTrue(tnsVector4d result, tnsMatrix44d mat, tnsVector4d v);
  759. void tnsLoadIdentity44d(tnsMatrix44d m);
  760. void tnsMakeOrthoMatrix44d(tnsMatrix44d mProjection, real xMin, real xMax, real yMin, real yMax, real zMin, real zMax);
  761. void tnsMakePerspectiveMatrix44d(tnsMatrix44d mProjection, real fFov_rad, real fAspect, real zMin, real zMax);
  762. void tnsMakeTranslationMatrix44d(tnsMatrix44d mTrans, real x, real y, real z);
  763. void tnsMakeRotationMatrix44d(tnsMatrix44d m, real angle_rad, real x, real y, real z);
  764. void tnsMakeScaleMatrix44d(tnsMatrix44d m, real x, real y, real z);
  765. void tnsMakeViewportMatrix44d(tnsMatrix44d m, real w, real h, real Far, real Near);
  766. void tnsInverse44d(tnsMatrix44d inverse, tnsMatrix44d mat);
  767. void tnsMultiply44d(tnsMatrix44d result, tnsMatrix44d l, tnsMatrix44d r);
  768. void tnsMakeRotationXMatrix44d(tnsMatrix44d m, real angle_rad);
  769. void tnsMakeRotationYMatrix44d(tnsMatrix44d m, real angle_rad);
  770. void tnsMakeRotationZMatrix44d(tnsMatrix44d m, real angle_rad);
  771. void tnsRemoveTranslation44d(tnsMatrix44d result, tnsMatrix44d mat);
  772. void tnsClearTranslation44d(tnsMatrix44d mat);
  773. real tnsAngleRad3d(tnsVector3d from, tnsVector3d to, tnsVector3d PositiveReference);
  774. real tnsLength3d(tnsVector3d l);
  775. void tnsNormalize2d(tnsVector2d result, tnsVector2d l);
  776. void tnsNormalize3d(tnsVector3d result, tnsVector3d l);
  777. void tnsNormalizeSelf3d(tnsVector3d result);
  778. real tnsDot3d(tnsVector3d l, tnsVector3d r, int normalize);
  779. real tnsVectorCross3d(tnsVector3d result, tnsVector3d l, tnsVector3d r);
  780. void tnsVectorCrossOnly3d(tnsVector3d result, tnsVector3d l, tnsVector3d r);
  781. void tnsExtractXYZEuler44d(tnsMatrix44d mat, real *xyz_result);
  782. void tnsPrintMatrix44d(tnsMatrix44d l);
  783. int tnsPointInsideTriangle3d(tnsVector3d v, tnsVector3d v0, tnsVector3d v1, tnsVector3d v2);
  784. int tnsIntersectPlaneRay(tnsVector3d n, tnsVector3d p0, tnsVector3d l0, tnsVector3d l, real* t);
  785. void tnsExtractXYZEuler44d(tnsMatrix44d mat, real *xyz_result);
  786. void tnsExtractLocation44d(tnsMatrix44d mat, real *xyz_result);
  787. void tnsExtractUniformScale44d(tnsMatrix44d mat, real *uniform_result);
  788. void tnsSelfMatrixChanged(tnsObject* o, int ApplyToChild);
  789. void tnsGlobalMatrixChanged(tnsObject* o, int ApplyToChild);
  790. void tnsGlobalMatrixChangedForDelta(tnsObject* o, int ApplyToChild);
  791. void tnsSelfTransformValueChanged(tnsObject* o);
  792. void tnsDeltaTransformValueChanged(tnsObject* o);
  793. void tnsGlobalTransformValueChanged(tnsObject* o);
  794. void tnsExtrtnsEnsurePlayDuplicateactDeltaTransformValue(tnsObject *o);
  795. void tnsExtractSelfTransformValue(tnsObject *o);
  796. void tnsExtractGlobalTransformValue(tnsObject *o);
  797. void tnsSetCurrentRoot(tnsObject *o);
  798. void tnsInitObjectBase(tnsObject *o, tnsObject *under, char *Name, int Type,
  799. real AtX, real AtY, real AtZ,
  800. real RotX, real RotY, real RotZ, real RotW, u8bit RotationMode,
  801. real Scale);
  802. tnsMeshObject *tnsLoadObjectFromFile(char *FileName);
  803. int tnsLoadExchange(char *FileName);
  804. tnsObject *tnsFindObject(char *Name, tnsObject *From);
  805. void tns_RegisterNodes();
  806. void tnsCopyObjectTransformationsLocal(tnsObject* to, tnsObject* from);
  807. void tnsCopyObjectTransformationsGlobal(tnsObject* to, tnsObject* from);
  808. void tnsRotateObjectGlobal(tnsObject *o, real x, real y, real z, real angle, real cx,real cy,real cz);
  809. void tnsRotateObjectLocal(tnsObject *o, real x, real y, real z, real angle, real gcx,real gcy,real gcz);
  810. void tnsRotateObjectLocalValues(tnsObject *o, real x, real y, real z);
  811. void tnsRotateObjectGlobalForDelta(tnsObject *o, real x, real y, real z, real angle, real cx,real cy,real cz);
  812. void tnsTranslateObjectGlobal(tnsObject *o, real x, real y, real z);
  813. void tnsTranslateObjectLocal(tnsObject *o, real x, real y, real z);
  814. void tnsMoveObjectLocal(tnsObject *o, real x, real y, real z);
  815. void tnsMoveObjectDelta(tnsObject *o, real x, real y, real z);
  816. void tnsMoveObjectGlobal(tnsObject *o, real x, real y, real z);
  817. void tnsMoveObjectGlobalForDelta(tnsObject *o, real x, real y, real z);
  818. void tnsScaleObject(tnsObject *o, real fac, real cx,real cy,real cz);
  819. void tnsScaleObjectDelta(tnsObject *o, real fac, real cx,real cy,real cz);
  820. int tnsCheckParentable(tnsObject* child, tnsObject* parent);
  821. void tnsParentObject(tnsObject *child, tnsObject *parent, int KeepTransform);
  822. void tnsUnparentObject(tnsObject *o, int KeepTransform);
  823. void tnsZoomViewingCamera(tnsCamera *c, real Ratio);
  824. void tnsRotateViewingCamera(tnsCamera *c, real x, real z);
  825. void tnsTranslateViewingCamera(tnsCamera *c, int ViewportW, int ViewportH, real x, real y);
  826. void tnsGetCameraMovingDeltas(tnsCamera *c, int ViewportW, int ViewportH, real x, real y, tnsVector4d p);
  827. laPropContainer* tnsget_ObjectType(tnsObject* o);
  828. void tnsDestroyRootObject(tnsObject *root);
  829. void tnsDestroyObject(tnsObject *o);
  830. tnsObject *tnsCreateRootObject(char *name);
  831. tnsCamera *tnsCreateCamera(tnsObject *under, char *Name, real FOV,
  832. real AtX, real AtY, real AtZ,
  833. real RotX, real RotY, real RotZ,
  834. real FocusDistance);
  835. tnsObject *tnsCreateInstancer(tnsObject *under, char *Name, real AtX, real AtY, real AtZ);
  836. tnsLight *tnsCreateLight(tnsObject *under, char *Name, real AtX, real AtY, real AtZ, real Strength, int UniDirectional);
  837. tnsMeshObject *tnsCreateMeshEmpty(tnsObject *under, char *Name, real AtX, real AtY, real AtZ);
  838. tnsMeshObject *tnsCreateMeshPlane(tnsObject *under, char *Name, real AtX, real AtY, real AtZ, real size);
  839. int tnsMergeMeshObjects(tnsMeshObject* into, tnsMeshObject* mo);
  840. tnsMeshObject* tnsDuplicateMeshObjects(tnsMeshObject* from);
  841. void tnsInitMeshPlane(tnsMeshObject* mo, real size);
  842. void tnsAddMMeshPlane(tnsMeshObject* mo, real size);
  843. int tnsAnyObjectsSelected(tnsObject* parent);
  844. void tnsDeselectAllObjects(tnsObject* parent);
  845. void tnsSelectAllObjects(tnsObject* parent);
  846. void tnsSelectObject(tnsObject* o, int Select, int Toggle);
  847. #define TNS_MMESH_EDGE_BIT 0x800000
  848. #define TNS_MMESH_FACE_BIT 0xC00000
  849. #define TNS_MMESH_TYPE_BIT (TNS_MMESH_FACE_BIT|TNS_MMESH_EDGE_BIT)
  850. tnsMFace* tnsMMeshNewFace(tnsMeshObject* mo);
  851. tnsMEdge* tnsMMeshNewEdge(tnsMeshObject* mo);
  852. tnsMVert* tnsMMeshNewVert(tnsMeshObject* mo);
  853. void tnsMMeshCalculateNormalFrom(tnsMFace* mf);
  854. int tnsMMeshCalculateNormal(tnsMeshObject* mo);
  855. void tnsMMeshEdgeAssignVerts(tnsMEdge* me,tnsMVert* mv1,tnsMVert* mv2);
  856. tnsMEdge* tnsMMeshVertsShareEdge(tnsMVert* mv0, tnsMVert* mv1);
  857. int tnsMMeshEdgeHasVert(tnsMEdge* me, tnsMVert* MV);
  858. tnsMFace* tnsMMeshEdgeShareFace(tnsMEdge* me0, tnsMEdge* me1);
  859. tnsMVert* tnsMMeshEdgeShareVert(tnsMEdge* me0, tnsMEdge* me1);
  860. tnsMVert* tnsMMeshEdgeAnotherVert(tnsMEdge* me, tnsMVert* v);
  861. tnsMVert* tnsMMeshEdgeStartingVert(tnsMEdge* me0, tnsMEdge* me1);
  862. int tnsMMeshSplitFace(tnsMeshObject* mo, tnsMFace* mf, tnsMEdge* me, tnsMFace** r_f1, tnsMFace** r_f2);
  863. tnsMFace* tnsMMeshVertsShareFace(tnsMVert* v1, tnsMVert* v2);
  864. tnsMEdge* tnsMMeshMakeEdge(tnsMeshObject* mo, tnsMVert* v1, tnsMVert* v2);
  865. void tnsMMeshFaceAddEdge(tnsMFace* mf, tnsMEdge* me);
  866. int tnsMMeshFaceMatches(tnsMFace* mf, int ecount, ...);
  867. tnsMFace* tnsMMeshMakeFaceN(tnsMeshObject* mo, int count, laListHandle* vip, tnsMEdge** r_fallback_me);
  868. tnsMFace* tnsMMeshMakeFace4v(tnsMeshObject* mo, tnsMVert* v1,tnsMVert* v2,tnsMVert* v3,tnsMVert* v4);
  869. int tnsMMeshLoopIsInverted(laListItemPointer* l);
  870. int tnsMMeshEdgeInsertVert(tnsMeshObject* mo, tnsMEdge* me, tnsMVert* mv, tnsMVert* ref_e1v_optional, tnsMEdge** r_e1, tnsMEdge** r_e2);
  871. tnsMVert* tnsMMeshEdgeInsertVertAt(tnsMeshObject* mo, tnsMEdge* me, real at, tnsMVert* ref_e1v_optional, tnsMEdge** r_e1, tnsMEdge** r_e2);
  872. void tnsMMeshRemoveFaceOnly(tnsMeshObject* mo, tnsMFace* mf);
  873. void tnsMMeshRemoveEdgeFace(tnsMeshObject* mo, tnsMEdge* me);
  874. void tnsMMeshRemoveVertEdgeFace(tnsMeshObject* mo, tnsMVert* mv);
  875. void tnsMMeshRefreshIndex(tnsMeshObject* mo);
  876. void tnsMeshEnterEditMode(tnsMeshObject* mo);
  877. void tnsMeshLeaveEditMode(tnsMeshObject* mo);
  878. int tnsMMeshAnySelected(tnsMeshObject* mo);
  879. void tnsMMeshClearExtraFlags(tnsMeshObject* mo);
  880. void tnsMMeshDeselectAll(tnsMeshObject* mo);
  881. void tnsMMeshSelectAll(tnsMeshObject* mo);
  882. void tnsMMeshSelectVert(tnsMeshObject* mo, tnsMVert* mv, int select, int toggle);
  883. void tnsMMeshSelectEdge(tnsMeshObject* mo, tnsMEdge* me, int select, int toggle);
  884. void tnsMMeshEnsureSelectionFromVerts(tnsMeshObject* mo);
  885. void tnsMMeshEnsureSelectionFromEdges(tnsMeshObject* mo);
  886. void tnsMMeshEnsureSelection(tnsMeshObject* mo, int SelectMode);
  887. void tnsMMeshExpandBandList(tnsMeshObject* mo, tnsMEdge* me, laListHandle* lst);
  888. int tnsMMeshSelectRingBandFrom(tnsMeshObject* mo, tnsMEdge* me, int ring_band, int select, int toggle);
  889. int tnsMMeshVertsCanMerge(tnsMeshObject* mo, tnsMVert* into, tnsMVert* mv);
  890. int tnsMMeshMergeVerts(tnsMeshObject* mo, tnsMVert* into, tnsMVert* mv);
  891. void tnsInvalidateMeshBatch(tnsMeshObject* mo);
  892. void tnsRegenerateMeshBatch(tnsMeshObject* mo);
  893. void tnsEnsureMeshBatch(tnsMeshObject* mo);
  894. void tnsEvaluateMeshObject(tnsMeshObject* mo, tnsEvaluateData* ed);
  895. void la_RegisterModellingOperators();
  896. void tnsGetCameraProjection(tnsMatrix44d* mat, int w, int h, tnsCamera* Camera);
  897. void tnsGetCameraViewProjection(tnsMatrix44d* mat, int w, int h, tnsCamera* Camera);
  898. void tnsApplyCameraView(int W, int H, tnsCamera *Camera);
  899. void tnsApplyShadowCameraView(tnsLight *Light);
  900. void tnsApplyModelMatrix(tnsMatrix44d m);
  901. void tnsLookAt(tnsObject *o, tnsVector3d Target, tnsVector3d Up);
  902. tnsObject* tnsEnsurePlayDuplicate(tnsObject* o);
  903. void tnsFreePlayDuplicate(tnsObject* o);
  904. void tnsInvalidateEvaluation(tnsObject* o);
  905. void tnsFreeEvaluatedArray(tnsEvaluateData* ed);
  906. void tnsEvaluateThisObject(tnsObject *o, tnsEvaluateData* ed);
  907. void tnsSetObjectTreeEvaluationArgs(tnsObject* from, tnsObject* Active, int FillOutline, int FillSelectionID);
  908. void tnsEvaluateObjectTree(tnsObject* from, tnsEvaluateData* UseED, int EvaluatePlay);
  909. void tnsAddEvaluatedInstance(tnsEvaluateData* ed, tnsObject* ob, tnsDrawEvaluatedInstanceF Draw, int Layer,
  910. int IsActive, int MeshSelectionType, int InstanceSelectionID);
  911. void tnsDrawLayer(tnsEvaluateData* ed,int Layer,void* CustomData);
  912. void tnsEvaluateNewNode(tnsEvaluateData* ed, tnsObject* ob);
  913. int tnsEvaluateTryRelinkExistingNode(tnsEvaluateData* ed, tnsObject* ob);
  914. void tnsEvaluateFreeNode(tnsEvaluatedNode* en);
  915. void tnsEvaluateSyncNode(tnsEvaluateData* ed, tnsObject* ob);
  916. void tnsEnsureEvalueatedScene(tnsEvaluateData* ed, tnsObject* root);
  917. void tnsPrintEvaluatedNode(tnsEvaluatedNode* en,int level);
  918. void tnsDrawObjectTree(tnsObject* from, int Layers,void* CustomData, int DrawRuntime);
  919. void tnsDrawObjectOrigins(tnsObject *from, tnsObject *active, int AllOrigins);
  920. void tnsDrawCursor(tnsObject* root);
  921. void tnsDrawScene(int W, int H, tnsObject *root);
  922. void tnsDrawWorld(int W, int H);
  923. tnsMaterial *tnsCreateMaterial(char *Name);
  924. tnsMaterial *tnsFindMaterialByIndex(int index);
  925. tnsMaterial *tnsFindMaterial(char *name);
  926. void tnsClearAll();
  927. void tnsClearColorv(real *rgba);
  928. void tnsClearColor(real r, real g, real b, real a);
  929. void tnsSwitchToCurrentWindowContext(void *wnd);
  930. void tnsRecalculateVertNormal(tnsVert *v);
  931. void tnsRecalculateFaceAverageNormal(tnsFace *f);
  932. int tnsLoadVectorGraphPackage(const char *name, unsigned int size);
  933. real tnsGetMonoFontAdvance();
  934. int tnsInvalidateFontCache();
  935. int tnsLoadSystemFontMono(char* from, char* mono);
  936. int tnsLoadSystemFont(char* from, char* name);
  937. int tnsGetTextureMemoryComponetCount(tnsTexture *t);
  938. void tnsUseNormal(int Use);
  939. void tnsUniformUseOffset(tnsShader* s, int use);
  940. tnsImage* tnsNewImage(void* MemPNG);
  941. void tnsUseImage(tnsImage* im);
  942. void tnsStopUsingImage(tnsImage* im);
  943. void tnsSetRayShaderUniformTextures(tnsOffscreen* doff);
  944. int tnsInit2DTexture(tnsTexture *t, GLint glInternalFormat, int w, int h, int Multisample);
  945. tnsTexture *tnsCreate2DTexture(GLint glInternalFormat, int w, int h, int Multisample);
  946. tnsTexture *tnsCreate3DTexture(GLint glInternalFormat, int w, int h, int slices);
  947. void tnsConfigure2DTexture(tnsTexture *t);
  948. void tnsConfigure3DTexture(tnsTexture *t);
  949. void tnsReconfigureTextureParameters(int Multisample);
  950. tnsOffscreen *tnsCreate2DOffscreen(int glInternalFormat, int w, int h, int Multisample, int WithDepth, int WithStencil);
  951. tnsOffscreen *tnsCreateDeferredOffscreen(int w, int h, int Multisample);
  952. void tnsCopyScreenTo2DTexture(tnsTexture *target, int x_lower_left, int y_lower_left, int w, int h);
  953. void tnsActiveTexture(GLenum tex);
  954. void tnsBindTexture(tnsTexture *t);
  955. void tnsUnbindTexture();
  956. void tnsUniformUseNormal(tnsShader* s, int Use);
  957. void tnsUniformUseTexture(tnsShader* s, int mode, int sample);
  958. void tnsUniformColorMode(tnsShader *s, int mode);
  959. void tnsUniformHCYGamma(tnsShader* s, float Gamma);
  960. void tnsUniformInputColorSpace(tnsShader* s, int ColorSpace);
  961. void tnsUniformOutputColorSpace(tnsShader* s, int ColorSpace);
  962. void tnsUniformShowColorOverflowStripes(tnsShader* s, int Show);
  963. void tnsUniformUseMultiplyColor(tnsShader* s, int enable);
  964. void tnsUseMaskTexture(tnsTexture *t);
  965. void tnsUseTexture(tnsTexture *t);
  966. void tnsUseNoTexture();
  967. void tnsUseMultiplyColor(int enable);
  968. void tnsDeleteTexture(tnsTexture *t);
  969. void tnsDraw2DTextureDirectly(tnsTexture *t, real x, real y, real w, real h);
  970. void tnsDraw2DTextureArg(tnsTexture *t,
  971. real x_upper_right, real y_upper_right, int w, int h,
  972. real *MultiplyColor,
  973. real LPadding, real RPadding, real TPadding, real BPadding);
  974. int tnsTextureMemorySize(tnsTexture *t, int mem);
  975. void tnsDelete2DOffscreen(tnsOffscreen *o);
  976. tnsOffscreen *tnsCreateOffscreenHandle();
  977. void tnsConfigureOffscreen(tnsOffscreen *off, int w, int h);
  978. void tnsAttach2DOffscreenBuffer(tnsOffscreen *target, GLuint attatchment, tnsTexture *use);
  979. void tnsDetach2DOffscreenBuffer(tnsOffscreen *target, GLuint which_attach_point);
  980. void tnsDrawToOffscreen(tnsOffscreen *toff, int HowMany, GLuint *AttachmentArray);
  981. void tnsDrawToExtraColorAttachment(tnsOffscreen *toff);
  982. void tnsDrawToExtraNormalAttachment(tnsOffscreen *toff);
  983. void tnsDrawToAllExtraAttachments(tnsOffscreen *toff);
  984. void tnsDrawToOffscreenOnlyBind(tnsOffscreen *toff, int HowMany, GLuint *AttachmentArray);
  985. void tnsReadFromOffscreen(tnsOffscreen *toff);
  986. void tnsPassColorBetweenOffscreens(tnsOffscreen *from, tnsOffscreen *to,
  987. GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLenum FilterMode);
  988. void tnsDrawToScreen();
  989. //==============================================[STR]
  990. int tnsUseFont(char *name);
  991. int laStopFontService();
  992. tnsFontSingleCharacter *tfntFetchVectorGraphTextureIDW(uint32_t ID);
  993. int tnsStringGetDimension(char* content, uint32_t* contentU, int Count, int WLimit, int* Rows, int UseMono);
  994. int tnsStringGetWidth(char *content, int Count, int UseMono);
  995. int tnsStringGetWidthU(uint32_t *contentU, int Count, int UseMono);
  996. void tnsDrawStringM(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags);
  997. int tnsDrawLCD7_ProgressSystem(real x, real y, real Percent);
  998. void tnsDrawStringLCD(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags, real Scale);
  999. void tnsDrawStringAutoM(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags);
  1000. void tnsDrawStringAuto(char *content, real Color[4], int L, int R, int T, int Flags);
  1001. void tnsDrawStringWithPriority(char *Label, char *MajorContent, real Color[4], int TextAlign, int L, int R, int T, int Flags);
  1002. void tnsDrawVectorGraphPackage(int ID, real Color[4], int L, int R, int T, int B, int Align, int Flags);
  1003. void tnsDrawIcon(uint32_t ID, real Color[4], int L,int R, int T, int Flags);
  1004. void tnsUseFontCoord(real x, real y, real size);
  1005. ///=================================
  1006. void tnsMakeTriangle(real *arr, real x1, real y1, real x2, real y2, real x3, real y3);
  1007. void tnsMakeQuad2d(real *arr, real x1, real y1, real x2, real y2, real x3, real y3, real x4, real y4);
  1008. void tnsMakeQuadT2d(real *arr, real x1, real y1, real x2, real y2, real x3, real y3, real x4, real y4);
  1009. 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);
  1010. 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);
  1011. void tnsMakeCircle2d(real *arr, int slices, real ctrX, real ctrY, real r, int jump);
  1012. void tnsMakeArc2d(real *arr, int slices, real ctrX, real ctrY, real r, real rad_begin, real rad_end);
  1013. void tnsMakeRing2d(real *arr, int *index, int slices, real ctrX, real ctrY, real r1, real r2);
  1014. void tnsMakeLinerGradient3d(real *arr, int num_points, real r0, real g0, real b0, real r1, real g1, real b1);
  1015. void tnsMakeLinerGradient4d(real *arr, int num_points, real r0, real g0, real b0, real a0, real r1, real g1, real b1, real a1);
  1016. void tnsMakeLinerGradient3dv(real *arr, int num_points, real *rgb0, real *rgb1);
  1017. void tnsMakeLinerGradient4dv(real *arr, int num_points, real *rgb0, real *rgb1);
  1018. void tnsMakeFoucsSquare(int L, int R, int U, int B, int W);
  1019. void tnsDrawFloor(real* CamPosition, real Far, int *ShowAxis);
  1020. void tnsDraw2DGrid10(real L, real R, real U, real B, real xmin, real xmax, real ymin, real ymax, real MostDenseW, real MostDenseH,
  1021. real* color4, real AlphaFactor, int ShowGrid, int TextAlign);
  1022. void tnsMakeIndexUInt(unsigned int *result, int num, ...);
  1023. void tnsMakeBridgedIndex(unsigned int *result, int num, int revert, int begin);
  1024. //================================
  1025. void DrawWireRect2dp(real x, real y, real x2, real y2);
  1026. void tnsViewportWithScissor(int x, int y, int w, int h);
  1027. void tnssRGB2XYZ(tnsVector3d rgb,tnsVector3d xyz);
  1028. void tnsClay2XYZ(tnsVector3d rgb,tnsVector3d xyz);
  1029. void tnsXYZ2sRGB(tnsVector3d xyz,tnsVector3d rgb);
  1030. void tnsXYZ2Clay(tnsVector3d xyz,tnsVector3d rgb);
  1031. void tnsRGB2Clay(tnsVector3d rgb, tnsVector3d clay);
  1032. void tnsClay2RGB(tnsVector3d clay, tnsVector3d rgb);
  1033. void tns2LogsRGBSingle(real* a);
  1034. void tns2LinearsRGBSingle(real* a);
  1035. void tns2LogsRGB(real* srgb);
  1036. void tns2LinearsRGB(real* srgb);
  1037. void tnsRGB2OKLAB(real* rgb, real* oklab);
  1038. void tnsOKLAB2RGB(real* oklab, real* rgb);
  1039. void tnsHCY2RGBLinear(real *hcy, real *rgb);
  1040. void tnsRGB2HCYLinear(real *rgb, real *hcy);
  1041. void tnsHCY2RGB(real *hcy, real *rgb);
  1042. void tnsRGB2HCY(real *rgb, real *hcy);