*/}}

la_tns.h 47 KB

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