1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468 |
- /*
- * LaGUI: A graphical application framework.
- * Copyright (C) 2022-2023 Wu Yiming
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- #pragma once
- #include "la_5.h"
- //#include "tinycthread.h"
- #include <float.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- extern const char* TNS_SHADER_COLOR_COMMON;
- extern const char* TNS_VERTEX_SIMPLE_MATCAP;
- extern const char* TNS_FRAGMENT_SIMPLE_MATCAP;
- extern const char* TNS_VERTEX_GRID;
- extern const char* TNS_FRAGMENT_TRANSPARNT_GRID;
- extern const char* LA_FLOOR_VERTEX_SHADER;
- extern const char* LA_FLOOR_FRAGMENT_SHADER;
- extern const char* LA_IMM_VERTEX_SHADER;
- extern const char* LA_IMM_FRAGMENT_SHADER;
- extern const char* LA_RAY_VERTEX_SHADER;
- extern const char* LA_SHADER_LIB_FXAA;
- extern const char* LA_RAY_FRAGMENT_SHADER;
- extern const char* LA_SCENE_VERTEX_SHADER;
- extern const char* LA_SCENE_FRAGMENT_SHADER;
- extern const char* LA_CASCADE_SHADOW_VERTEX_SHADER;
- extern const char* LA_CASCADE_SHADOW_FRAGMENT_SHADER;
- extern const char* LA_SELECTION_VERTEX_SHADER;
- extern const char* LA_SELECTION_FRAGMENT_SHADER;
- #ifdef __cplusplus
- }
- #endif
- #define TNS_PI 3.1415926535897932384626433832795
- #define deg(r) r / TNS_PI * 180.0
- #define rad(d) d *TNS_PI / 180.0
- #define TNS_COLOR_SPACE_SRGB 0
- #define TNS_COLOR_SPACE_CLAY 1
- //typedef real tnsMatrix33d[9];
- typedef float tnsMatrix44f[16];
- typedef real tnsMatrix44d[16];
- typedef real tnsVector2d[2];
- typedef real tnsVector3d[3];
- typedef real tnsVector4d[4];
- typedef float tnsVector3f[3];
- typedef int tnsVector2i[2];
- typedef struct _tnsMatrixStackItem tnsMatrixStackItem;
- struct _tnsMatrixStackItem
- {
- tnsMatrix44d view;
- tnsMatrix44d model;
- tnsMatrix44d projection;
- };
- typedef struct _tnsMatrixStack tnsMatrixStack;
- struct _tnsMatrixStack
- {
- tnsMatrixStackItem *level;
- int current_level;
- int max_level;
- };
- typedef struct _tnsShader tnsShader;
- struct _tnsShader{
- laListItem Item;
- int vtShaderID;
- int fgShaderID;
- int gsShaderID;
- int glProgramID;
- int CustomID;
- int iModel, iProjection, iView, iProjectionInverse;
- int iShadow;
- int iVertex, iNormal, iColor, iUV;
- int iUseNormal;
- int iTexColor,iTexNormal,iTexGPos;
- int iTexColorMS;
- int iMultiplyColor, StateMultiplyColor;
- int iTextureMode, StateTextureMode, iColorMode,iHCYGamma;
- int iSampleAmount, StateSampleAmount;
- int iInputColorSpace, iOutputColorSpace, iShowStripes;
- int iDoOffset;
- int uViewDir,uViewPos,uFOV,uNear,uFar;
- };
- typedef struct _tnsTexture tnsTexture;
- typedef struct _tnsCommand tnsCommand;
- struct _tnsCommand
- {
- GLenum Mode;
- short Dimensions; // 2 or 3
- short UVDimensions; // 2 or 3
- char UseVert;
- char UseColor;
- char UseNormal;
- char UseTexCoord;
- char UseIndex;
- GLenum PolyMode; //0-solid 1-wire
- GLenum Shade; //0-falt 1-smooth
- GLfloat UniformColor[4];
- int NumVert;
- int NumIndex;
- int VertBegin;
- int VertEnd; //'END'is the next one after the last one.
- int ColorBegin;
- int ColorEnd;
- int TexCoordBegin;
- int TexCoordEnd;
- int NormalBegin;
- int NormalEnd;
- GLushort IndexBegin;
- GLushort IndexEnd;
- tnsShader *ReplaceShader;
- tnsTexture *ColorTexture;
- int TextureMode;
- int MultiplyColor;
- };
- typedef struct _tnsMain tnsMain;
- typedef struct _tnsWorld tnsWorld;
- typedef struct _tnsObject tnsObject;
- struct _tnsWorld
- {
- laListItem Item;
- laListHandle RootObjects;
- tnsObject *ActiveRoot;
- laListHandle AllObjects;
- laListHandle Materials;
- u16bit TimeYear;
- u8bit TimeMonth;
- u8bit TimeDay;
- laListHandle BezierCurves;
- laListHandle Meshes;
- };
- NEED_STRUCTURE(tnsLoopItem);
- NEED_STRUCTURE(tnsRenderLine);
- NEED_STRUCTURE(tnsRenderBuffer);
- STRUCTURE(tnsFilterKernel){
- int Size;
- real *Kernel;
- };
- STRUCTURE(tnsTriangulateNode){
- char Picked;
- real Angle; //rad
- tnsLoopItem *LoopItem;
- tnsRenderLine *FowardRL;
- tnsRenderLine *BackwardRL;
- };
- STRUCTURE(tnsTriangulateEdgeNode){
- tnsRenderLine *RL;
- };
- STRUCTURE(tnsImage){
- laListItem Item;
- void* MemPNG;
- tnsTexture* Texture;
- int UserCount;
- };
- struct _tnsMain {
- laListItem Item;
- tnsMatrixStack stack;
- int vsx,vsy,vsw,vsh;//for saving scissor etc.
- int vol,vor,vou,vob;//for saving ortho etc.
- laListHandle Shaders;
- int NextShaderIndex;
- tnsShader *CurrentShader;
- tnsShader *BindedShader;
- //int MatrixMode;
- int IsOffscreen;
- laListHandle Offscreens;
- char *GLVersionStr;
- char *GLVendorStr;
- char *GLRendererStr;
- char *GLSLVersionStr;
- tnsShader* immShader;
- tnsShader* RayShader;
- tnsShader* ShadowShader;
- tnsShader* SceneShader;
- tnsShader* SelectionShader;
- tnsShader* FloorShader;
- int GlobalVAO;
- tnsShader *uiShader;
- tnsShader *stringShader;
- tnsShader *TextureShader;
- tnsShader *RectangleTextureShader;
- tnsShader *TextureMultiplyShader;
- tnsShader *MSTextureShader;
- tnsShader *MSATextureShader;
- tnsShader *TEST_MatcapShader;
- tnsShader *TransparentGridShader;
- tnsShader *SobelColorShader;
- tnsShader *SobelShader;
- tnsShader *ExtraBuffersShader;
- laListHandle Textures;
- tnsTexture *PreviewTexture;
- tnsFilterKernel EdgeGaussFilter;
- GLenum GlTextureSets;
- // Corresponds to current GL_TEXTURE0/1...
- tnsTexture *TexColor;
- tnsTexture *TexRenderbuffer;
- // For commands
- GLenum StateShadeMode;
- GLenum StatePolyMode;
- tnsTexture *StateTexColor;
- int StateTextureMode;
- int StateMultiplyColor;
- int StateUseNormal;
- int SetUseNormal;
-
- tnsShader* StateShader;
- GLfloat StateColor[4];
- GLfloat* Vert;
- GLuint VertBufObject;
- int NextVert, MaxVert;
- GLfloat* Color;
- GLuint ColorBufObject;
- int NextColor, MaxColor;
- GLfloat* Normal;
- GLuint NormalBufObject;
- int NextNormal, MaxNormal;
- GLfloat* TexCoord;
- GLuint TexCoordBufObject;
- int NextTexCoord, MaxTexCoord;
- GLuint* Index;
- GLuint IndexBufObject;
- int NextIndex, MaxIndex;
- tnsCommand* DrawingCommand;
- int NextCommand, MaxCommand;
- tnsWorld World;
- laListHandle RenderBuffers;
- tnsRenderBuffer *ActiveRenderBuffer;
- laListHandle Images;
- };
- typedef struct _tnsLineStripPoint tnsLineStripPoint;
- struct _tnsLineStripPoint
- {
- laListItem Item;
- tnsVector3d P;
- };
- typedef struct _tnsLineStrip tnsLineStrip;
- struct _tnsLineStrip
- {
- laListItem Item;
- laListHandle Points;
- int PointCount;
- };
- #define TNS_SNAKE_STRENGTH_LIMIT 30
- #define TNS_SNAKE_STEP_LENGTH 5
- #define TNS_SNAKE_STRENGTH_MARCHING_LIMIT 30
- #define TNS_SNAKE_EDGE_WIDTH 2
- #define TNS_SNAKE_FILTER_SIZE 6
- #define TNS_SNAKE_ANGLE_DEVIATE 0.5
- #define TNS_SNAKE_ANGLE_PRICISION 1
- #define TNS_SNAKE_STEP1 3
- #define TNS_SNAKE_STEP2 5
- typedef struct _tnsTextureSample tnsTextureSample;
- struct _tnsTextureSample
- {
- laListItem Item;
- u8bit Sample;
- int X, Y;
- real Z;
- };
- typedef struct _tnsTexture tnsTexture;
- struct _tnsTexture
- {
- laListItem Item;
- int IsRenderBuffer;
- GLuint GLTexHandle;
- GLint GLTexBitsType; //like GL_RGBA
- GLuint GLTexType; //like GL_TEXTURE_2D
- int Multisample;
- int Width;
- int Height;
- int Slices;
- void *DrawData;
- int RBWidth, RBHeight;
- int ElemSize;
- void *TextureReadBack;
- void **SamplePtr;
- laListHandle PendingSamples;
- laListHandle ErasedSamples;
- laListHandle LineStrips;
- };
- typedef struct _tnsOffscreen tnsOffscreen;
- struct _tnsOffscreen
- {
- laListItem Item;
- tnsTexture *pColor[16];
- tnsTexture *pDepth;
- GLuint FboHandle;
- int UseSecondary;
- };
- extern const GLuint TNS_ATTACHMENT_ARRAY_NONE[];
- extern const GLuint TNS_ATTACHMENT_ARRAY[];
- extern const GLuint TNS_ATTACHMENT_ARRAY_1[];
- extern const GLuint TNS_ATTACHMENT_ARRAY_2[];
- extern const GLuint TNS_ATTACHMENT_ARRAY_1_2[];
- extern const GLuint TNS_ATTACHMENT_ARRAY_0_1_2[];
- extern const GLenum TNS_WINDOW_DRAWBUFFER_ARRAY[];
- #define TNS_PROJECTION_MATRIX 1
- #define TNS_MODEL_MATRIX 2
- #define TNS_VIEW_MATRIX 3
- #define TNS_TEXTURE_MATRIX 4
- //==========================================================================[FT]
- #include "freetype/ftglyph.h"
- #include "freetype/ftoutln.h"
- #include "freetype/fttrigon.h"
- #include "ft2build.h"
- #include <stdarg.h>
- #include <stdlib.h>
- #include <string.h>
- NEED_STRUCTURE(tnsTexture);
- typedef struct _tnsFontSingleCharacter tnsFontSingleCharacter;
- struct _tnsFontSingleCharacter
- {
- tnsTexture *Tex;
- int Generated;
- short width;
- short height;
- real advx;
- short advy;
- short deltax;
- short deltay;
- short bufferx;
- short buffery;
- };
- #define TNS_UNICODE_COUNT ((unsigned int)(1<<17))
- #define TNS_MONO_COUNT (0x045f)
- typedef struct _tnsFont tnsFont;
- struct _tnsFont
- {
- laListItem Item;
- char *fontName;
- char *IconFontName;
- tnsFontSingleCharacter** characters; /* [(1<<17)] TNS_UNICODE_COUNT Unicode plane 0-1 */
- tnsFontSingleCharacter** monocharacters; /* [0x045f] TNS_MONO_COUNT Up to cryllic. */
- FT_Library ftlib;
- FT_Face ftface[16];
- FT_Face ftfacemono;
- int NumFaces;/* excludes mono. */
- real MonoScale;
- real MonoAdvance;
- real size;
- unsigned int height;
- tnsTexture TexBuffer;
- int CurrentX;
- int CurrentY;
- };
- typedef struct _tnsFontManager tnsFontManager;
- struct _tnsFontManager
- {
- laListHandle Fonts;
- tnsFont *UsingFont;
- tnsFont *VectorsGrapghs;
- unsigned LastDlst;
- };
- typedef struct _tnsFontBoundBox tnsFontBoundBox;
- struct _tnsFontBoundBox
- {
- int x, y, w, h; /* Upper Left and width,height */
- };
- #define TNS_FONT_BUFFER_W 2048
- #define TNS_FONT_BUFFER_H 2048
- #define TNS_FONT_ALIGN_LEFT 1
- #define TNS_FONT_ALIGN_CENTER 2
- #define TNS_FONT_ALIGN_RIGHT 4
- #define TNS_FONT_ALIGN_LEFT_PROTECT 8
- #define TNS_FONT_ALIGN_CENTER_FIRST (2 | 8)
- #define CSS_FLOW_DIRECTION_LR 1
- #define CSS_FLOW_DIRECTION_TD 0
- //typedef struct _tnsCssBorder tnsCssBorder;
- //struct _tnsCssBorder{
- // real Px;//thickness
- // real Color[4];//rgba
- // int Style;//Like________ or ....... or __.__.__. or ======== or ~~~~~~~
- // int Padding;
- // int Margin;
- //};
- //
- //typedef struct _tnsCssBackground tnsCssBackground;
- //struct _tnsCssBackground{
- // real Color[4];
- // int ImageID;//LA SPECIFIC
- // int Repeat;
- // int PositionFixed;
- // real PositionRatio;
- //};
- //
- //typedef struct _tnsCssText tnsCssText;
- //struct _tnsCssText{
- // real Color[4];
- // int LineSpacing;
- // int LetterSpacing;
- // int Align;//0-LR 1-C 2-L 3-R all support number-ready display
- // int Decoration;
- // int Underline;
- // int Shadow;
- //};
- //
- //typedef struct _tnsCssMisc tnsCssMisc;
- //struct _tnsCssMisc{
- // real Color[4];
- // int Size;
- // const char * Name;
- // const char * Description;
- //};
- //
- //typedef struct _tnsCssState tnsCssState;
- //struct _tnsCssState{
- // char NameReplace[36];
- // tnsCssBackground Bkg;
- // tnsCssBorder BorderLeft;
- // tnsCssBorder BorderRight;
- // tnsCssBorder BorderTop;
- // tnsCssBorder BorderBottom;
- // tnsCssText Text;
- // tnsCssMisc Misc1;
- // tnsCssMisc Misc2;
- // tnsCssMisc Misc3;
- // tnsCssMisc Misc4;
- //};
- #define TNS_STATE_NORMAL 0
- #define TNS_STATE_PUSHED 1
- #define TNS_STATE_HIGHLIGHT 2
- #define TNS_STATE_HIGHLIGHT_SELECT 3
- #define TNS_STATE_KEYING 4
- #define TNS_STATE_INTERPOLATING 5
- #define TNS_STATE_LIMITED 6
- //
- //typedef struct _tnsCssStyle tnsCssStyle;
- //struct _tnsCssStyle{
- // tnsCssState Normal;
- // tnsCssState Pushed;
- // tnsCssState Highlight;
- // tnsCssState HighlightSelect;
- // tnsCssState Keying;
- // tnsCssState Interpolating;
- // tnsCssState Limited;
- //};
- //=====================================================[3d comp]
- typedef struct _tnsWorld tnsWorld;
- typedef struct _tnsObject tnsObject;
- #define TNS_ROTATION_XYZ_EULER 0
- #define TNS_ROTATION_XZY_EULER 1
- #define TNS_ROTATION_YXZ_EULER 2
- #define TNS_ROTATION_YZX_EULER 3
- #define TNS_ROTATION_ZXY_EULER 4
- #define TNS_ROTATION_ZYX_EULER 5
- #define TNS_ROTATION_QUATERNION 6
- #define TNS_OBJECT_ROOT 0
- #define TNS_OBJECT_EMPTY (1<<0)
- #define TNS_OBJECT_CAMERA (1<<1)
- #define TNS_OBJECT_LIGHT (1<<2)
- #define TNS_OBJECT_MESH (1<<3)
- //typedef struct _tnsObjectLinker tnsObjectLinker;
- //struct _tnsObjectLinker {
- // laListItem Item;
- // tnsObject* o;
- //};
- NEED_STRUCTURE(tnsRenderTriangle);
- NEED_STRUCTURE(tnsRenderVert);
- #define TNS_OBJECT_FLAGS_SELECTED 1
- NEED_STRUCTURE(tnsBatch)
- typedef struct _tnsObject tnsObject;
- struct _tnsObject
- {
- laListItem Item;
- int Type;
- int SelectID;
- int Flags;
- //u64bit ID;
- laSafeString *Name;
- int DrawMode;
- int Show;
- int ShowOnRender;
- int HideChildren;
- int RotationMode;
- int IsInstanced;
- real GLocation[3];
- real GRotation[3];
- real GScale;//Only allow uniform scale
- real Location[3];
- real Rotation[4];
- real Scale;
- // delta transforms for animation & drivers.
- real DLocation[3];
- real DRotation[3];
- real DScale;
- tnsMatrix44d GlobalTransform;
- tnsMatrix44d SelfTransform;
- tnsMatrix44d DeltaTransform;
- tnsMatrix44d InstanceTransform;
- //tnsMatrix44d CameraTransform;
- tnsObject *Active; // may be used to store last select info in child objects.
- tnsObject *InRoot;
- tnsObject *ParentObject; // reused as root active sun.
- laListHandle ChildObjects;
- laListHandle Drivers; // rack
- laListHandle Actions;
- };
- NEED_STRUCTURE(laNodeInSocket);
- NEED_STRUCTURE(laNodeOutSocket);
- STRUCTURE(tnsTransformNode){
- laBaseNode Base;
- laNodeInSocket* Mat;
- tnsObject* Target;
- };
- STRUCTURE(tnsMakeTransformNode){
- laBaseNode Base;
- laNodeInSocket* Loc; laNodeInSocket* Rot; laNodeInSocket* Angle; laNodeInSocket* Sca;
- laNodeOutSocket* Out;
- tnsMatrix44d Mat; tnsVector3d UseLoc; tnsVector3d UseRot; real UseSca; real UseAngle;
- };
- #define TNS_PRESPECTIVE_CAMERA 0
- #define TNS_ORTHOGRAPHICAL_CAMERA 1
- #define TNS_FISHEYE_CAMERA 2
- #define TNS_ID_TO_COLOR(color, i) \
- {color[0]=(real)((i & 0x000000FF)>>0)/255.0; color[1]=(real)((i & 0x0000FF00)>>8)/255.0; color[2]=(real)((i & 0x00FF0000)>>16)/255.0;}
- #define TNS_MATERIAL_DRAW_MODE_SOLID 0
- #define TNS_MATERIAL_DRAW_MODE_WIRE 1
- typedef struct _tnsMaterial tnsMaterial;
- struct _tnsMaterial
- {
- laListItem Item;
- laSafeString *Name;
- int ID;
- int DrawMode;
- real Color[4];
- real LinearColor[4];
- real SpectacularColor[4];
- real ReflexThreshold;
- real ReflexStrengh;
- real ReflexSharpeness;
- real LowBrightnessColor[4]; //Windows are lighten up in the evenings
- u8bit HaloMode;
- };
- #define TNS_CAMERA_PERSPECTIVE 0
- #define TNS_CAMERA_ORTHO 1
- #define TNS_CAMERA_FISHEYE 2
- typedef struct _tnsCamera tnsCamera;
- struct _tnsCamera
- {
- tnsObject Base;
- int CameraType;
- real FOV;
- real ZMin, ZMax;
- real FocusDistance;
- real OrthScale;
- tnsVector3d RenderViewDir;
- };
- typedef struct _tnsLight tnsLight;
- struct _tnsLight
- {
- tnsObject Base;
- int LightType;
- int UniDirectional;
- real Strength;
- tnsMaterial *Material;
- };
- STRUCTURE(tnsGroup){
- laListItem Item;
- laListHandle ObjectLinks;
- laSafeString *Name;
- tnsVector4d Color1;
- tnsVector4d Color2;
- int ExcludeFromCalculation;
- };
- #define TNS_MESH_FLAG_SELECTED (1<<0)
- #define TNS_MESH_FLAG_PICKED (1<<1)
- #define TNS_MESH_FLAG_LOOP_REVERSE (1<<2)
- STRUCTURE(tnsMVert){
- laListItem Item;
- tnsVector3d p;
- tnsVector3d n;
- int flags;
- u32bit i;
- laListHandle elink;
- //laListHandle flink;
- };
- NEED_STRUCTURE(tnsMFace);
- STRUCTURE(tnsMEdge){
- laListItem Item;
- tnsMVert *vl;
- tnsMVert *vr;
- tnsMFace *fl;
- tnsMFace *fr;
- u32bit i;
- int flags;
- };
- STRUCTURE(tnsMFace){
- laListItem Item;
- laListHandle l; //list item pointer of edges
- tnsVector3d n;
- tnsVector3d c;
- short looplen;
- short mat;
- u32bit i;
- int flags;
- };
- STRUCTURE(tnsVert){
- tnsVector3f p;
- tnsVector3f n;
- int flags;
- };
- STRUCTURE(tnsEdge){
- int l,r;
- int flags;
- };
- STRUCTURE(tnsFace){
- int* loop;
- int flags;
- tnsVector3f n;
- short looplen;
- };
- STRUCTURE(tnsBatchCommand){
- laListItem Item;
- char* name;
- int DrawElements;
- GLuint EBO; //elem
- u32bit ElementCount;
- GLenum DrawAs;
- GLuint CBO; int ColorDimension; int OverrideColorArray;
- int Dimension;
- int HiddenByDefault;
- int UseUniformColor; real UniformColor[4];
- real Width;
- };
- STRUCTURE(tnsBatch){
- laListItem Item;
- GLuint VBO; //vert
- GLuint NBO; int HasNormal; //normal
- GLuint CBO; int HasColor; //color
- u32bit NumVert;
- int Dimension;
- int NormalDimension;
- int ColorDimension;
- laListHandle Branches;
- GLuint BeginElementOffset;
- };
- #define TNS_MESH_OBJECT_MODE 0
- #define TNS_MESH_EDIT_MODE 1
- extern laPropContainer* TNS_PC_OBJECT_GENERIC;
- extern laPropContainer* TNS_PC_OBJECT_CAMERA;
- extern laPropContainer* TNS_PC_OBJECT_LIGHT;
- extern laPropContainer* TNS_PC_OBJECT_MESH;
- #define TNS_HINT_TRANSFORM (1<<1)
- #define TNS_HINT_GEOMETRY (1<<0)
- STRUCTURE(tnsMeshFaceStorageSingleHead){
- int looplen, flags; //[1] [5] [4] [2] ... [-1 as end]
- };
- STRUCTURE(tnsMeshFaceStorage){
- int len; int arr;
- };
- STRUCTURE(tnsMeshObject){
- tnsObject Base;
- tnsVert* v; int totv, maxv;
- tnsEdge* e; int tote, maxe; // I intend this to only stores floating edges.
- tnsFace* f; int totf, maxf;
- laListHandle mv; int totmv;
- laListHandle me; int totme;
- laListHandle mf; int totmf;
- int TriangleCount;
- int TriangulatedEdgeCount;
- tnsMVert* LastSelectV, *FirstSelectV;
- tnsMEdge* LastSelectE, *FirstSelectE;
-
- tnsBatch *Batch;
- tnsBatch *ExtraBatch;
- int Mode;
- };
- STRUCTURE(tnsEdgeHashEdge){
- int tv; tnsMEdge* me;
- };
- STRUCTURE(tnsEdgeHashVert){
- tnsEdgeHashEdge* e; int max, next; tnsMVert* mv;
- };
- STRUCTURE(tnsEdgeHash){
- tnsEdgeHashVert* vl; int max,next;
- };
- #define TNS_TILE(tile, r, c, CCount) \
- tile[r * CCount + c]
- #define TNS_CLAMP(a, Min, Max) \
- a = a < Min ? Min : (a > Max ? Max : a)
- #define TNS_MAX2(a, b) \
- (a > b ? a : b)
- #define TNS_MIN2(a, b) \
- (a < b ? a : b)
- #define TNS_MAX3(a, b, c) \
- (a > TNS_MAX2(b, c) ? a : TNS_MAX2(b, c))
- #define TNS_MIN3(a, b, c) \
- (a < TNS_MIN2(b, c) ? a : TNS_MIN2(b, c))
- #define TNS_MAX2_INDEX(a, b) \
- (a > b ? 0 : 1)
- #define TNS_MIN2_INDEX(a, b) \
- (a < b ? 0 : 1)
- #define TNS_MAX3_INDEX(a, b, c) \
- (a > b ? (a > c ? 0 : (b > c ? 1 : 2)) : (b > c ? 1 : 2))
- #define TNS_MIN3_INDEX(a, b, c) \
- (a < b ? (a < c ? 0 : (b < c ? 1 : 2)) : (b < c ? 1 : 2))
- #define TNS_MAX3_INDEX_ABC(x, y, z) \
- (x > y ? (x > z ? a : (y > z ? b : c)) : (y > z ? b : c))
- #define TNS_MIN3_INDEX_ABC(x, y, z) \
- (x < y ? (x < z ? a : (y < z ? b : c)) : (y < z ? b : c))
- #define TNS_ABC(index) \
- (index == 0 ? a : (index == 1 ? b : c))
- #define TNS_DOUBLE_CLOSE_ENOUGH(a, b) \
- (((a) + DBL_EDGE_LIM) >= (b) && ((a)-DBL_EDGE_LIM) <= (b))
- //#define TNS_DOUBLE_CLOSE_ENOUGH(a,b) \
- //(((a)+0.00000000001)>=(b) && ((a)-0.0000000001)<=(b))
- #define TNS_FLOAT_CLOSE_ENOUGH_WIDER(a, b) \
- (((a) + 0.0000001) >= (b) && ((a)-0.0000001) <= (b))
- #define TNS_FRAMEBUFFER_PIXEL(FrameBuffer, Row, Column) \
- &((FrameBuffer)->Pixels[Row * FrameBuffer->TileSizeW * FrameBuffer->W * FrameBuffer->SubPixelSample + Column * FrameBuffer->H * FrameBuffer->TileSizeH * FrameBuffer->SubPixelSample])
- #define TNS_IN_TILE_X(RenderTile, Fx) \
- (RenderTile->FX <= Fx && RenderTile->FXLim >= Fx)
- #define TNS_IN_TILE_Y(RenderTile, Fy) \
- (RenderTile->FY <= Fy && RenderTile->FYLim >= Fy)
- #define TNS_IN_TILE(RenderTile, Fx, Fy) \
- (TNS_IN_TILE_X(RenderTile, Fx) && TNS_IN_TILE_Y(RenderTile, Fy))
- #define TNS_RENDERBUFFER_INCOMPLETE 0
- #define TNS_RENDERBUFFER_GEOMETRY_COMPLETE 1
- #define TNS_RENDERBUFFER_RASTERIZER_COMPLETE 2
- #define TNS_RENDERBUFFER_COMPLETE (TNS_RENDERBUFFER_GEOMETRY_COMPLETE | TNS_RENDERBUFFER_RASTERIZER_COMPLETE)
- #define TNS_DISPLAY_MODE_WIRE GL_LINE_LOOP
- #define TNS_DISPLAY_MODE_SOLID GL_TRIANGLES
- #define TNS_INTERNAL_MODE_WIRE 1
- #define TNS_INTERNAL_MODE_SOLID 2
- #define TNS_ARROW_L 1
- #define TNS_ARROW_R 2
- #define TNS_ARROW_U 3
- #define TNS_ARROW_D 4
- #define TNS_KEYWORD_OBJECT_COUNT 1
- #define TNS_KEYWORD_OBJECT_NAME 2
- #define TNS_KEYWORD_OBJECT_TYPE 3
- #define TNS_KEYWORD_OBJECT_LOCATION 4
- #define TNS_KEYWORD_OBJECT_ROTATION 5
- #define TNS_KEYWORD_OBJECT_SCALE 6
- #define TNS_KEYWORD_OBJECT_CHILDREN_COUNT 7
- #define TNS_KEYWORD_OBJECT_CHILDREN_NAMES 8
- //#define TNS_KEYWORD_MESH_COUNT 9
- //#define TNS_KEYWORD_MESH_NAME 10
- #define TNS_KEYWORD_MESH_VERTEX_COUNT 11
- #define TNS_KEYWORD_MESH_VERTICES 12
- #define TNS_KEYWORD_MESH_LOOP_COUNT 13
- #define TNS_KEYWORD_MESH_TOPOLOGY 14
- #define TNS_KEYWORD_MESH_UV_COUNT 15
- #define TNS_KEYWORD_MESH_UV_NAME 16
- #define TNS_KEYWORD_MATERIAL_COUNT 17
- #define TNS_KEYWORD_MATERIAL_NAME 18
- #define TNS_KEYWORD_MATERIAL_COLOR 19
- #define TNS_KEYWORD_MATERIAL_END 20
- #define TNS_KEYWORD_CAMERA_FOV 20
- #define TNS_KEYWORD_CAMERA_IS_ACTIVE 21
- #define TNS_KEYWORD_CAMERA_NEAR 22
- #define TNS_KEYWORD_CAMERA_FAR 23
- #define TNS_KEYWORD_GROUP_COUNT 24
- #define TNS_KEYWORD_GROUP_NAME 25
- #define TNS_KEYWORD_OBJECT_GROUP_COUNT 26
- void tnsSetuptnsFontManager();
- tnsShader *tnsNewShaderProgram(int VertexShaderID, int FragmentShaderID, int GeometryShaderID);
- int tnsNewGeometryShader(char *Content);
- int tnsNewFragmentShader(char *Content);
- int tnsNewVertexShader(char *Content);
- void tnsDeleteShaderProgram(tnsShader* s);
- int tnsNextPowOf2(int i);
- int tnsEnableShader(int index);
- int tnsEnableShaderv(tnsShader *shader);
- int tnsUseShader(tnsShader *shader);
- void tnsUseImmShader();
- void tnsUseShadowShader();
- void tnsUseSceneShader();
- void tnsUseRayShader();
- void tnsUseTransparentGridShader();
- void tnsUseImagePeelShader();
- void tnsInitRenderKernel(int matrixStackLevel);
- void tnsInitBuiltinShaders();
- void tnsInitWindowDefaultRenderConfig();
- void tnsQuit();
- void tnsRestoreFromNanoVG();
- real *tnsGetModelMatrix();
- real *tnsGetViewMatrix();
- real *tnsGetProjectionMatrix();
- void tnsGetMVMatrix(tnsMatrix44d r);
- void tnsGetMVPMatrix(tnsMatrix44d r);
- void tnsResetModelMatrix();
- void tnsResetViewMatrix();
- void tnsResetProjectionMatrix();
- void tnsOrtho(real xMin, real xMax, real yMin, real yMax, real zMin, real zMax);
- void tnsPerspective(real fFov_rad, real fAspect, real zMin, real zMax);
- void tnsPopMatrix();
- void tnsPushMatrix();
- void tnsTranslate3d(real x, real y, real z);
- void tnsPreTranslate3d(real x, real y, real z);
- void tnsRotate4d(real degrees, real x, real y, real z);
- void tnsPreRotate4d(real degrees, real x, real y, real z);
- void tnsScale3d(real x, real y, real z);
- void tnsPreScale3d(real x, real y, real z);
- void tnsColor4d(real r, real g, real b, real a);
- void tnsColor4dv(real *rgba);
- void tnsPolygonMode(GLenum PolyMode);
- void tnsShadeMode(GLenum ShadeMode);
- tnsBatch *tnsCreateBatch(u32bit NumVert, int Dimension, float *Data, int NormalDimension, float *Normal, int ColorDimension, float *Colors);
- tnsBatch *tnsCreateBatchi(u32bit NumVert, int Dimension, int *Data);
- void tnsCommandUseWidth(tnsBatchCommand*c, real width);
- void tnsCommandUseUniformColor(tnsBatchCommand*c,real* color);
- void tnsCommandOverrideColorArray(tnsBatchCommand*c, int VertCount, int ColorDimension, float* colors);
- tnsBatchCommand *tnsCreateCommand(tnsBatch *b, const char* name, u32bit ElementCount, int Dimension, GLenum DrawAs, u32bit *Elements, int HiddenByDefault);
- void tnsDeleteBatch(tnsBatch *b);
- void tnsDrawBatch(tnsBatch* batch, const char* OverrideCommand, real* OverrideUniformColor, int OverrideAsArray);
- void tnsVertex3d(real x, real y, real z);
- void tnsVertex2d(real x, real y);
- void tnsVertexArray2d(real *verts, int amount);
- void tnsVertexArray3d(real *verts, int amount);
- void tnsColorArray4d(real *colors, int amount);
- void tnsNormalArray3d(real *normals, int amount);
- void tnsTexCoordArray2d(real *coords, int amount);
- void tnsTexCoordArray3d(real *coords, int amount);
- void tnsIndexArray(GLuint *index, short amount);
- void tnsPackAs(GLenum Mode);
- void tnsFlush();
- #define tnsLinearItp(L, R, T) \
- ((L) * (1.0f - (T)) + (R) * (T))
- double tnsGetRatiod(real L, real R, real FromL);
- void tnsShaderApplyProjectionInverse(tnsShader *tns, tnsMatrix44d m);
- void tnsShaderApplyProjection(tnsShader *tns, tnsMatrix44d m);
- void tnsShaderApplyModel(tnsShader *tns, tnsMatrix44d m);
- void tnsShaderApplyView(tnsShader *tns, tnsMatrix44d m);
- void tnsShaderApplyNormalScaler(tnsShader *tns, tnsMatrix44d m);
- int tnsLineIntersectTest2d(tnsVector2d a1, tnsVector2d a2, tnsVector2d b1, tnsVector2d b2, double *aRatio);
- double tnsGetLineZ(tnsVector3d L, tnsVector3d R, real Ratio);
- double tnsGetLineZPoint(tnsVector3d L, tnsVector3d R, tnsVector3d FromL);
- double tnsGetRatio3d(tnsVector3d L, tnsVector3d R, tnsVector3d FromL);
- double tnsGetRatiod(real L, real R, real FromL);
- real tnsInterpolate(real L, real R, real T);
- void tnsInterpolate2dv(real *L, real *R, real T, real *Result);
- void tnsInterpolate3dv(real *L, real *R, real T, real *Result);
- void tnsInterpolateTripple2d(tnsVector2d v1, tnsVector2d v2, tnsVector2d v3, real ratio, tnsVector2d result);
- void tnsVectorMinus2d(tnsVector2d result, tnsVector2d l, tnsVector2d r);
- void tnsVectorMinus3d(tnsVector3d result, tnsVector3d l, tnsVector3d r);
- void tnsVectorSubtract3d(tnsVector3d l, tnsVector3d r);
- void tnsVectorPlus3d(tnsVector3d result, tnsVector3d l, tnsVector3d r);
- void tnsVectorAccum3d(tnsVector3d l, tnsVector3d r);
- void tnsVectorAccum2d(tnsVector2d l, tnsVector2d r);
- void tnsVectorNegate3d(tnsVector3d result, tnsVector3d l);
- void tnsVectorNegateSelf3d(tnsVector3d l);
- void tnsVectorCopy2d(tnsVector2d from, tnsVector2d to);
- void tnsVectorCopy3d(tnsVector3d from, tnsVector3d to);
- void tnsVectorCopy4d(tnsVector4d from, tnsVector4d to);
- void tnsVectorMultiSelf4d(tnsVector4d from, real num);
- void tnsVectorMultiSelf3d(tnsVector3d from, real num);
- void tnsVectorMultiSelf2d(tnsVector2d from, real num);
- void tnsVectorMulti4d(tnsVector4d to, tnsVector4d from, real num);
- void tnsVectorMulti3d(tnsVector3d to, tnsVector3d from, real num);
- void tnsVectorMulti2d(tnsVector2d to, tnsVector2d from, real num);
- real tnsDirectionToRad(tnsVector2d Dir);
- void tnsConvert44df(tnsMatrix44d from, tnsMatrix44f to);
- int tnsTrangleLineBoundBoxTest(tnsRenderTriangle *rt, tnsRenderLine *rl);
- #define tnsVectorSet2(to, x,y) \
- {(to)[0]=x;(to)[1]=y;}
- #define tnsVectorSet3(to, x,y,z) \
- {(to)[0]=x;(to)[1]=y;(to)[2]=z;}
- #define tnsVectorSet4(to, x,y,z,w) \
- {(to)[0]=x;(to)[1]=y;(to)[2]=z;(to)[3]=w;}
- #define tnsVectorSet2v(to, from) \
- tnsVectorSet2(to,(from)[0],(from)[1])
- #define tnsVectorSet3v(to, from) \
- tnsVectorSet3(to,(from)[0],(from)[1],(from)[2])
- #define tnsVectorSet4v(to, from) \
- tnsVectorSet4(to,(from)[0],(from)[1],(from)[2],(from)[3])
- real tnsDistIdv2(real x1, real y1, real x2, real y2);
- real tnsDist3dv(tnsVector3d l, tnsVector3d r);
- real tnsDist2dv(tnsVector2d l, tnsVector2d r);
- real tnsLength3d(tnsVector3d l);
- real tnsLength2d(tnsVector3d l);
- void tnsNormalize3d(tnsVector3d result, tnsVector3d l);
- void tnsNormalizeSelf2d(tnsVector3d result);
- void tnsNormalizeSelf3d(tnsVector3d result);
- real tnsDot3d(tnsVector3d l, tnsVector3d r, int normalize);
- real tnsDot2d(tnsVector2d l, tnsVector2d r, int normalize);
- real tnsVectorCross3d(tnsVector3d result, tnsVector3d l, tnsVector3d r);
- real tnsAngleRad3d(tnsVector3d from, tnsVector3d to, tnsVector3d PositiveReference);
- void tnsApplyRotation33d(tnsVector3d result, tnsMatrix44d mat, tnsVector3d v);
- void tnsApplyRotation43d(tnsVector3d result, tnsMatrix44d mat, tnsVector3d v);
- void tnsApplyTransform43d(tnsVector3d result, tnsMatrix44d mat, tnsVector3d v);
- void tnsApplyNormalTransform43d(tnsVector3d result, tnsMatrix44d mat, tnsVector3d v);
- void tnsApplyTransform44d(tnsVector4d result, tnsMatrix44d mat, tnsVector4d v);
- void tnsApplyTransform44dTrue(tnsVector4d result, tnsMatrix44d mat, tnsVector4d v);
- void tnsLoadIdentity44d(tnsMatrix44d m);
- void tnsMakeOrthoMatrix44d(tnsMatrix44d mProjection, real xMin, real xMax, real yMin, real yMax, real zMin, real zMax);
- void tnsMakePerspectiveMatrix44d(tnsMatrix44d mProjection, real fFov_rad, real fAspect, real zMin, real zMax);
- void tnsMakeTranslationMatrix44d(tnsMatrix44d mTrans, real x, real y, real z);
- void tnsMakeRotationMatrix44d(tnsMatrix44d m, real angle_rad, real x, real y, real z);
- void tnsMakeScaleMatrix44d(tnsMatrix44d m, real x, real y, real z);
- void tnsMakeViewportMatrix44d(tnsMatrix44d m, real w, real h, real Far, real Near);
- void tnsInverse44d(tnsMatrix44d inverse, tnsMatrix44d mat);
- void tnsMultiply44d(tnsMatrix44d result, tnsMatrix44d l, tnsMatrix44d r);
- void tnsMakeRotationXMatrix44d(tnsMatrix44d m, real angle_rad);
- void tnsMakeRotationYMatrix44d(tnsMatrix44d m, real angle_rad);
- void tnsMakeRotationZMatrix44d(tnsMatrix44d m, real angle_rad);
- void tnsRemoveTranslation44d(tnsMatrix44d result, tnsMatrix44d mat);
- void tnsClearTranslation44d(tnsMatrix44d mat);
- real tnsAngleRad3d(tnsVector3d from, tnsVector3d to, tnsVector3d PositiveReference);
- real tnsLength3d(tnsVector3d l);
- void tnsNormalize2d(tnsVector2d result, tnsVector2d l);
- void tnsNormalize3d(tnsVector3d result, tnsVector3d l);
- void tnsNormalizeSelf3d(tnsVector3d result);
- real tnsDot3d(tnsVector3d l, tnsVector3d r, int normalize);
- real tnsVectorCross3d(tnsVector3d result, tnsVector3d l, tnsVector3d r);
- void tnsVectorCrossOnly3d(tnsVector3d result, tnsVector3d l, tnsVector3d r);
- void tnsExtractXYZEuler44d(tnsMatrix44d mat, real *xyz_result);
- void tnsPrintMatrix44d(tnsMatrix44d l);
- int tnsPointInsideTriangle3d(tnsVector3d v, tnsVector3d v0, tnsVector3d v1, tnsVector3d v2);
- int tnsIntersectPlaneRay(tnsVector3d n, tnsVector3d p0, tnsVector3d l0, tnsVector3d l, real* t);
- void tnsExtractXYZEuler44d(tnsMatrix44d mat, real *xyz_result);
- void tnsExtractLocation44d(tnsMatrix44d mat, real *xyz_result);
- void tnsExtractUniformScale44d(tnsMatrix44d mat, real *uniform_result);
- void tnsSelfMatrixChanged(tnsObject* o, int ApplyToChild);
- void tnsGlobalMatrixChanged(tnsObject* o, int ApplyToChild);
- void tnsGlobalMatrixChangedForDelta(tnsObject* o, int ApplyToChild);
- void tnsSelfTransformValueChanged(tnsObject* o);
- void tnsDeltaTransformValueChanged(tnsObject* o);
- void tnsGlobalTransformValueChanged(tnsObject* o);
- void tnsExtractDeltaTransformValue(tnsObject *o);
- void tnsExtractSelfTransformValue(tnsObject *o);
- void tnsExtractGlobalTransformValue(tnsObject *o);
- void tnsSetCurrentRoot(tnsObject *o);
- void tnsInitObjectBase(tnsObject *o, tnsObject *under, char *Name, int Type,
- real AtX, real AtY, real AtZ,
- real RotX, real RotY, real RotZ, real RotW, u8bit RotationMode,
- real Scale);
- tnsMeshObject *tnsLoadObjectFromFile(char *FileName);
- int tnsLoadExchange(char *FileName);
- tnsObject *tnsFindObject(char *Name, tnsObject *From);
- void tns_RegisterNodes();
- void tnsCopyObjectTransformationsLocal(tnsObject* to, tnsObject* from);
- void tnsCopyObjectTransformationsGlobal(tnsObject* to, tnsObject* from);
- void tnsRotateObjectGlobal(tnsObject *o, real x, real y, real z, real angle, real cx,real cy,real cz);
- void tnsRotateObjectLocal(tnsObject *o, real x, real y, real z, real angle, real gcx,real gcy,real gcz);
- void tnsRotateObjectLocalValues(tnsObject *o, real x, real y, real z);
- void tnsRotateObjectGlobalForDelta(tnsObject *o, real x, real y, real z, real angle, real cx,real cy,real cz);
- void tnsTranslateObjectGlobal(tnsObject *o, real x, real y, real z);
- void tnsTranslateObjectLocal(tnsObject *o, real x, real y, real z);
- void tnsMoveObjectLocal(tnsObject *o, real x, real y, real z);
- void tnsMoveObjectDelta(tnsObject *o, real x, real y, real z);
- void tnsMoveObjectGlobal(tnsObject *o, real x, real y, real z);
- void tnsMoveObjectGlobalForDelta(tnsObject *o, real x, real y, real z);
- void tnsScaleObject(tnsObject *o, real fac, real cx,real cy,real cz);
- void tnsScaleObjectDelta(tnsObject *o, real fac, real cx,real cy,real cz);
- int tnsCheckParentable(tnsObject* child, tnsObject* parent);
- void tnsParentObject(tnsObject *child, tnsObject *parent, int KeepTransform);
- void tnsUnparentObject(tnsObject *o, int KeepTransform);
- void tnsZoomViewingCamera(tnsCamera *c, real Ratio);
- void tnsRotateViewingCamera(tnsCamera *c, real x, real z);
- void tnsTranslateViewingCamera(tnsCamera *c, int ViewportW, int ViewportH, real x, real y);
- void tnsGetCameraMovingDeltas(tnsCamera *c, int ViewportW, int ViewportH, real x, real y, tnsVector4d p);
- laPropContainer* tnsget_ObjectType(tnsObject* o);
- void tnsDestroyRootObject(tnsObject *root);
- void tnsDestroyObject(tnsObject *o);
- tnsObject *tnsCreateRootObject(char *name);
- tnsCamera *tnsCreateCamera(tnsObject *under, char *Name, real FOV,
- real AtX, real AtY, real AtZ,
- real RotX, real RotY, real RotZ,
- real FocusDistance);
- tnsObject *tnsCreateEmpty(tnsObject *under, char *Name, real AtX, real AtY, real AtZ);
- tnsLight *tnsCreateLight(tnsObject *under, char *Name, real AtX, real AtY, real AtZ, real Strength, int UniDirectional);
- tnsMeshObject *tnsCreateMeshEmpty(tnsObject *under, char *Name, real AtX, real AtY, real AtZ);
- tnsMeshObject *tnsCreateMeshPlane(tnsObject *under, char *Name, real AtX, real AtY, real AtZ, real size);
- int tnsMergeMeshObjects(tnsMeshObject* into, tnsMeshObject* mo);
- tnsMeshObject* tnsDuplicateMeshObjects(tnsMeshObject* from);
- void tnsInitMeshPlane(tnsMeshObject* mo, real size);
- void tnsAddMMeshPlane(tnsMeshObject* mo, real size);
- int tnsAnyObjectsSelected(tnsObject* parent);
- void tnsDeselectAllObjects(tnsObject* parent);
- void tnsSelectAllObjects(tnsObject* parent);
- void tnsSelectObject(tnsObject* o, int Select, int Toggle);
- #define TNS_MMESH_EDGE_BIT 0x800000
- #define TNS_MMESH_FACE_BIT 0xC00000
- #define TNS_MMESH_TYPE_BIT (TNS_MMESH_FACE_BIT|TNS_MMESH_EDGE_BIT)
- tnsMFace* tnsMMeshNewFace(tnsMeshObject* mo);
- tnsMEdge* tnsMMeshNewEdge(tnsMeshObject* mo);
- tnsMVert* tnsMMeshNewVert(tnsMeshObject* mo);
- void tnsMMeshCalculateNormalFrom(tnsMFace* mf);
- int tnsMMeshCalculateNormal(tnsMeshObject* mo);
- void tnsMMeshEdgeAssignVerts(tnsMEdge* me,tnsMVert* mv1,tnsMVert* mv2);
- tnsMEdge* tnsMMeshVertsShareEdge(tnsMVert* mv0, tnsMVert* mv1);
- int tnsMMeshEdgeHasVert(tnsMEdge* me, tnsMVert* MV);
- tnsMFace* tnsMMeshEdgeShareFace(tnsMEdge* me0, tnsMEdge* me1);
- tnsMVert* tnsMMeshEdgeShareVert(tnsMEdge* me0, tnsMEdge* me1);
- tnsMVert* tnsMMeshEdgeAnotherVert(tnsMEdge* me, tnsMVert* v);
- tnsMVert* tnsMMeshEdgeStartingVert(tnsMEdge* me0, tnsMEdge* me1);
- int tnsMMeshSplitFace(tnsMeshObject* mo, tnsMFace* mf, tnsMEdge* me, tnsMFace** r_f1, tnsMFace** r_f2);
- tnsMFace* tnsMMeshVertsShareFace(tnsMVert* v1, tnsMVert* v2);
- tnsMEdge* tnsMMeshMakeEdge(tnsMeshObject* mo, tnsMVert* v1, tnsMVert* v2);
- void tnsMMeshFaceAddEdge(tnsMFace* mf, tnsMEdge* me);
- int tnsMMeshFaceMatches(tnsMFace* mf, int ecount, ...);
- tnsMFace* tnsMMeshMakeFaceN(tnsMeshObject* mo, int count, laListHandle* vip, tnsMEdge** r_fallback_me);
- tnsMFace* tnsMMeshMakeFace4v(tnsMeshObject* mo, tnsMVert* v1,tnsMVert* v2,tnsMVert* v3,tnsMVert* v4);
- int tnsMMeshLoopIsInverted(laListItemPointer* l);
- int tnsMMeshEdgeInsertVert(tnsMeshObject* mo, tnsMEdge* me, tnsMVert* mv, tnsMVert* ref_e1v_optional, tnsMEdge** r_e1, tnsMEdge** r_e2);
- tnsMVert* tnsMMeshEdgeInsertVertAt(tnsMeshObject* mo, tnsMEdge* me, real at, tnsMVert* ref_e1v_optional, tnsMEdge** r_e1, tnsMEdge** r_e2);
- void tnsMMeshRemoveFaceOnly(tnsMeshObject* mo, tnsMFace* mf);
- void tnsMMeshRemoveEdgeFace(tnsMeshObject* mo, tnsMEdge* me);
- void tnsMMeshRemoveVertEdgeFace(tnsMeshObject* mo, tnsMVert* mv);
- void tnsMMeshRefreshIndex(tnsMeshObject* mo);
- void tnsMeshEnterEditMode(tnsMeshObject* mo);
- void tnsMeshLeaveEditMode(tnsMeshObject* mo);
- int tnsMMeshAnySelected(tnsMeshObject* mo);
- void tnsMMeshClearExtraFlags(tnsMeshObject* mo);
- void tnsMMeshDeselectAll(tnsMeshObject* mo);
- void tnsMMeshSelectAll(tnsMeshObject* mo);
- void tnsMMeshSelectVert(tnsMeshObject* mo, tnsMVert* mv, int select, int toggle);
- void tnsMMeshSelectEdge(tnsMeshObject* mo, tnsMEdge* me, int select, int toggle);
- void tnsMMeshEnsureSelectionFromVerts(tnsMeshObject* mo);
- void tnsMMeshEnsureSelectionFromEdges(tnsMeshObject* mo);
- void tnsMMeshEnsureSelection(tnsMeshObject* mo, int SelectMode);
- void tnsMMeshExpandBandList(tnsMeshObject* mo, tnsMEdge* me, laListHandle* lst);
- int tnsMMeshSelectRingBandFrom(tnsMeshObject* mo, tnsMEdge* me, int ring_band, int select, int toggle);
- int tnsMMeshVertsCanMerge(tnsMeshObject* mo, tnsMVert* into, tnsMVert* mv);
- int tnsMMeshMergeVerts(tnsMeshObject* mo, tnsMVert* into, tnsMVert* mv);
- void tnsInvalidateMeshBatch(tnsMeshObject* mo);
- void tnsRegenerateMeshBatch(tnsMeshObject* mo);
- void tnsEnsureMeshBatch(tnsMeshObject* mo);
- void tnsDrawMeshObject(tnsMeshObject* mo, int DrawAsObjectSelection, int MeshSelectionMode, tnsMeshObject* Active,
- int ViewMode, int SelectThrough, laListHandle* XRayCommands);
- void tnsDrawMeshObjectXRay(tnsMeshObject* mo, int MeshSelectionMode, int ViewMode, int SelectThrough);
- void la_RegisterModellingOperators();
- void tnsGetCameraProjection(tnsMatrix44d* mat, int w, int h, tnsCamera* Camera);
- void tnsGetCameraViewProjection(tnsMatrix44d* mat, int w, int h, tnsCamera* Camera);
- void tnsApplyCameraView(int W, int H, tnsCamera *Camera);
- void tnsApplyShadowCameraView(tnsLight *Light);
- void tnsApplyObjectMatrix(tnsObject *Object);
- void tnsLookAt(tnsObject *o, tnsVector3d Target, tnsVector3d Up);
- void tnsDrawThisObject(tnsObject *o, tnsObject *active, int DrawAsObjectSelection, int MeshSelectionMode,
- int ViewMode, int SelectThrough, laListHandle* XRayCommands);
- void tnsDrawObjectTree(tnsObject *from, tnsObject *active, int DrawAsObjectSelection, int MeshSelectionMode,
- int ViewMode, int SelectThrough, laListHandle* XRayCommands);
- void tnsDrawXRay(laListHandle* XRayPasses, int MeshSelectionMode, int ViewMode, int SelectThrough);
- void tnsDrawObjectOrigins(tnsObject *from, tnsObject *active, int AllOrigins);
- void tnsDrawCursor(tnsObject* root);
- void tnsDrawScene(int W, int H, tnsObject *root);
- void tnsDrawWorld(int W, int H);
- tnsMaterial *tnsCreateMaterial(char *Name);
- tnsMaterial *tnsFindMaterialByIndex(int index);
- tnsMaterial *tnsFindMaterial(char *name);
- void tnsClearAll();
- void tnsClearColorv(real *rgba);
- void tnsClearColor(real r, real g, real b, real a);
- void tnsSwitchToCurrentWindowContext(void *wnd);
- void tnsRecalculateVertNormal(tnsVert *v);
- void tnsRecalculateFaceAverageNormal(tnsFace *f);
- int tnsLoadVectorGraphPackage(const char *name, unsigned int size);
- real tnsGetMonoFontAdvance();
- int tnsInvalidateFontCache();
- int tnsLoadSystemFontMono(char* from, char* mono);
- int tnsLoadSystemFont(char* from, char* name);
- int tnsGetTextureMemoryComponetCount(tnsTexture *t);
- void tnsUseNormal(int Use);
- void tnsUniformUseOffset(tnsShader* s, int use);
- tnsImage* tnsNewImage(void* MemPNG);
- void tnsUseImage(tnsImage* im);
- void tnsStopUsingImage(tnsImage* im);
- void tnsSetRayShaderUniformTextures(tnsOffscreen* doff);
- int tnsInit2DTexture(tnsTexture *t, GLint glInternalFormat, int w, int h, int Multisample);
- tnsTexture *tnsCreate2DTexture(GLint glInternalFormat, int w, int h, int Multisample);
- tnsTexture *tnsCreate3DTexture(GLint glInternalFormat, int w, int h, int slices);
- void tnsConfigure2DTexture(tnsTexture *t);
- void tnsConfigure3DTexture(tnsTexture *t);
- void tnsReconfigureTextureParameters(int Multisample);
- tnsOffscreen *tnsCreate2DOffscreen(int glInternalFormat, int w, int h, int Multisample, int WithDepth, int WithStencil);
- tnsOffscreen *tnsCreateDeferredOffscreen(int w, int h, int Multisample);
- void tnsCopyScreenTo2DTexture(tnsTexture *target, int x_lower_left, int y_lower_left, int w, int h);
- void tnsActiveTexture(GLenum tex);
- void tnsBindTexture(tnsTexture *t);
- void tnsUnbindTexture();
- void tnsUniformUseNormal(tnsShader* s, int Use);
- void tnsUniformUseTexture(tnsShader* s, int mode, int sample);
- void tnsUniformColorMode(tnsShader *s, int mode);
- void tnsUniformHCYGamma(tnsShader* s, float Gamma);
- void tnsUniformInputColorSpace(tnsShader* s, int ColorSpace);
- void tnsUniformOutputColorSpace(tnsShader* s, int ColorSpace);
- void tnsUniformShowColorOverflowStripes(tnsShader* s, int Show);
- void tnsUniformUseMultiplyColor(tnsShader* s, int enable);
- void tnsUseMaskTexture(tnsTexture *t);
- void tnsUseTexture(tnsTexture *t);
- void tnsUseNoTexture();
- void tnsUseMultiplyColor(int enable);
- void tnsDeleteTexture(tnsTexture *t);
- void tnsDraw2DTextureDirectly(tnsTexture *t, real x, real y, real w, real h);
- void tnsDraw2DTextureArg(tnsTexture *t,
- real x_upper_right, real y_upper_right, int w, int h,
- real *MultiplyColor,
- real LPadding, real RPadding, real TPadding, real BPadding);
- int tnsTextureMemorySize(tnsTexture *t, int mem);
- void tnsCreateTextureReadbackBuffer(tnsTexture *t);
- void tnsDeleteTextureReadbackBuffer(tnsTexture *t);
- void tnsReadbackTexture(tnsTexture *t);
- #define TNS_CLAMP_TEXTURE_W(t, Col) \
- { \
- if (Col >= t->Width) \
- Col = t->Width - 1; \
- if (Col < 0) \
- Col = 0; \
- }
- #define TNS_CLAMP_TEXTURE_H(t, Row) \
- { \
- if (Row >= t->Height) \
- Row = t->Height - 1; \
- if (Row < 0) \
- Row = 0; \
- }
- #define TNS_CLAMP_TEXTURE_CONTINUE(t, Col, Row) \
- { \
- if (Col >= t->Width) \
- continue; \
- if (Col < 0) \
- continue; \
- if (Row >= t->Height) \
- continue; \
- if (Row < 0) \
- continue; \
- }
- void tnsDelete2DOffscreen(tnsOffscreen *o);
- tnsOffscreen *tnsCreateOffscreenHandle();
- void tnsConfigureOffscreen(tnsOffscreen *off, int w, int h);
- void tnsAttach2DOffscreenBuffer(tnsOffscreen *target, GLuint attatchment, tnsTexture *use);
- void tnsDetach2DOffscreenBuffer(tnsOffscreen *target, GLuint which_attach_point);
- void tnsDrawToOffscreen(tnsOffscreen *toff, int HowMany, GLuint *AttachmentArray);
- void tnsDrawToExtraColorAttachment(tnsOffscreen *toff);
- void tnsDrawToExtraNormalAttachment(tnsOffscreen *toff);
- void tnsDrawToAllExtraAttachments(tnsOffscreen *toff);
- void tnsDrawToOffscreenOnlyBind(tnsOffscreen *toff, int HowMany, GLuint *AttachmentArray);
- void tnsReadFromOffscreen(tnsOffscreen *toff);
- void tnsPassColorBetweenOffscreens(tnsOffscreen *from, tnsOffscreen *to,
- GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLenum FilterMode);
- void tnsDrawToScreen();
- //==============================================[STR]
- int tnsUseFont(char *name);
- int laStopFontService();
- tnsFontSingleCharacter *tfntFetchVectorGraphTextureIDW(uint32_t ID);
- int tnsStringGetDimension(char* content, uint32_t* contentU, int Count, int WLimit, int* Rows, int UseMono);
- int tnsStringGetWidth(char *content, int Count, int UseMono);
- int tnsStringGetWidthU(uint32_t *contentU, int Count, int UseMono);
- void tnsDrawStringM(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags);
- int tnsDrawLCD7_ProgressSystem(real x, real y, real Percent);
- void tnsDrawStringLCD(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags);
- void tnsDrawStringAutoM(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags);
- void tnsDrawStringAuto(char *content, real Color[4], int L, int R, int T, int Flags);
- void tnsDrawStringWithPriority(char *Label, char *MajorContent, real Color[4], int TextAlign, int L, int R, int T, int Flags);
- void tnsDrawVectorGraphPackage(int ID, real Color[4], int L, int R, int T, int B, int Align, int Flags);
- void tnsDrawIcon(uint32_t ID, real Color[4], int L,int R, int T, int Flags);
- void tnsUseFontCoord(real x, real y, real size);
- ///=================================
- void tnsMakeTriangle(real *arr, real x1, real y1, real x2, real y2, real x3, real y3);
- void tnsMakeQuad2d(real *arr, real x1, real y1, real x2, real y2, real x3, real y3, real x4, real y4);
- void tnsMakeQuadT2d(real *arr, real x1, real y1, real x2, real y2, real x3, real y3, real x4, real y4);
- 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);
- 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);
- void tnsMakeCircle2d(real *arr, int slices, real ctrX, real ctrY, real r, int jump);
- void tnsMakeArc2d(real *arr, int slices, real ctrX, real ctrY, real r, real rad_begin, real rad_end);
- void tnsMakeRing2d(real *arr, int *index, int slices, real ctrX, real ctrY, real r1, real r2);
- void tnsMakeLinerGradient3d(real *arr, int num_points, real r0, real g0, real b0, real r1, real g1, real b1);
- void tnsMakeLinerGradient4d(real *arr, int num_points, real r0, real g0, real b0, real a0, real r1, real g1, real b1, real a1);
- void tnsMakeLinerGradient3dv(real *arr, int num_points, real *rgb0, real *rgb1);
- void tnsMakeLinerGradient4dv(real *arr, int num_points, real *rgb0, real *rgb1);
- void tnsMakeFoucsSquare(int L, int R, int U, int B, int W);
- void tnsDrawFloor(real* CamPosition, real Far, int *ShowAxis);
- void tnsDraw2DGrid10(real L, real R, real U, real B, real xmin, real xmax, real ymin, real ymax, real MostDenseW, real MostDenseH,
- real* color4, real AlphaFactor, int ShowGrid, int TextAlign);
- void tnsMakeIndexUInt(unsigned int *result, int num, ...);
- void tnsMakeBridgedIndex(unsigned int *result, int num, int revert, int begin);
- //================================
- void DrawWireRect2dp(real x, real y, real x2, real y2);
- void tnsViewportWithScissor(int x, int y, int w, int h);
- void tnssRGB2XYZ(tnsVector3d rgb,tnsVector3d xyz);
- void tnsClay2XYZ(tnsVector3d rgb,tnsVector3d xyz);
- void tnsXYZ2sRGB(tnsVector3d xyz,tnsVector3d rgb);
- void tnsXYZ2Clay(tnsVector3d xyz,tnsVector3d rgb);
- void tnsRGB2Clay(tnsVector3d rgb, tnsVector3d clay);
- void tnsClay2RGB(tnsVector3d clay, tnsVector3d rgb);
- void tns2LogsRGBSingle(real* a);
- void tns2LinearsRGBSingle(real* a);
- void tns2LogsRGB(real* srgb);
- void tns2LinearsRGB(real* srgb);
- void tnsRGB2OKLAB(real* rgb, real* oklab);
- void tnsOKLAB2RGB(real* oklab, real* rgb);
- void tnsHCY2RGBLinear(real *hcy, real *rgb);
- void tnsRGB2HCYLinear(real *rgb, real *hcy);
- void tnsHCY2RGB(real *hcy, real *rgb);
- void tnsRGB2HCY(real *rgb, real *hcy);
- tnsLineStrip *tnsCreateLineStrip();
- tnsLineStripPoint *tnsAppendPoint(tnsLineStrip *ls, real X, real Y, real Z);
- tnsLineStripPoint *tnsPushPoint(tnsLineStrip *ls, real X, real Y, real Z);
- void tnsRemovePoint(tnsLineStrip *ls, tnsLineStripPoint *lsp);
- void tnsDestroyLineStrip(tnsLineStrip *ls);
- void tnsGetGaussianKernel(tnsFilterKernel *fk, int size, real sigma);
- void *tnsTextureSampleSafe(tnsTexture *t, int Col, int Row);
- int tnsTextureSampleWeightSafe(tnsTexture *t, int Col, int Row, real Size, tnsVector2d Direction);
- real tnsTextureSampleSafeGaussU8R(tnsTexture *t, tnsFilterKernel *fk, int Col, int Row);
- void tnsTextureSetBitSafeU8R(tnsTexture *t, int Col, int Row, int Bit);
- void tnsTextureSetRGBSafeU8R(tnsTexture *t, int Col, int Row, u8bit r, u8bit g, u8bit b);
- u8bit *tnsTextureSampleU8(tnsTexture *t, int Col, int Row);
|