Andre wrote:@Zach: Guimauve described
here his "ToolBox" IDE tool. I think that the feature request has something to do with it, but natively implemented...

Exactly !
@ Zack
For the moment we have TailBite or Moebius to create custom libraries and resident file. Unfortunately, the compiled libraries from PureBasic source code can't be copied from Window to Linux to Mac OS, they need to be compiled for each system (x86 and x86_64) every time the libraries need to be re-compiled every time PureBasic is updated even if the code is the same for each platform. You have to recompile because Fred has make change in the compiler and this change don't affect the source just the binary file created from the source code.
I can include many of my custom function source code without worrying about is my code Linux or Windows compliant or is my code is x86 ou x86_64 compliant. We you work on e very large project such as 3D game, you will probably have 5 or 6 different programs. All of these programs share many instruction such has Vector2, Vector3, Vector4, Matrix22, Matrix33, Matrix44, Quaternion, Line3D, Spline, Indice3, Vertex, Color3f, Color4f, SubMesh, Mesh, Texture, Material, OpenGL Import, SDL Import, GTK Import, it is enough or I need to continue.
The game program just need to read files, but editor need to read and write file. When we include source code on many case the compiler add unwanted code. I mean the command to Write Files stuff will be included to the Game program regardless if it's needed or called somewhere in the program. The only way to solve this is to create custom libraries but we went back to TailBite/Moebius tool to compile libraires again and again, in fact so many times, I waste my precious time to compile and debug my libraries instead of developing programs. This is not acceptable and this is why I have create ToolBox Manager custom tools. But this solution is far from perfect, for example the ToolBoxFile keyword can be placed only in the main source file (the file you need to compile to create program) otherwise you will get a syntax error because we can't associate action with keywords.
For example when the compiler found the "IncludeFile" keyword, he know what to do, read the designated file. But it's not possible for me to tell the compiler what he have to do when he found the "ToolBoxFile" keyword.
Another problem is long access path to file name when you develop program for Window and Linux.
Code: Select all
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
IncludeFile "/home/guimauve/Codes PureBasic/ToolBox/Juste/pour/vraiment/vous/faire/comprendre/le/but/du/logiciel/imaginez/un/chemin/acces/au/fichier/source/très/long/sous/Windows/et/sous/Linux/vector2.pb"
IncludeFile "/home/guimauve/Codes PureBasic/ToolBox/Juste/pour/vraiment/vous/faire/comprendre/le/but/du/logiciel/imaginez/un/chemin/acces/au/fichier/source/très/long/sous/Windows/et/sous/Linux/vector3.pb"
IncludeFile "/home/guimauve/Codes PureBasic/ToolBox/Juste/pour/vraiment/vous/faire/comprendre/le/but/du/logiciel/imaginez/un/chemin/acces/au/fichier/source/très/long/sous/Windows/et/sous/Linux/vector4.pb"
CompilerCase #PB_OS_Windows
IncludeFile "C:\Documents And Settings\guimauve\Codes PureBasic\ToolBox\Juste\pour\vraiment\vous\faire\comprendre\le\but\du\logiciel\imaginez\un\chemin\acces\au\fichier\source\très\long\sous\Windows\et\sous\Linux\vector2.pb"
IncludeFile "C:\Documents And Settings\guimauve\Codes PureBasic\ToolBox\Juste\pour\vraiment\vous\faire\comprendre\le\but\du\logiciel\imaginez\un\chemin\acces\au\fichier\source\très\long\sous\Windows\et\sous\Linux\vector3.pb"
IncludeFile "C:\Documents And Settings\guimauve\Codes PureBasic\ToolBox\Juste\pour\vraiment\vous\faire\comprendre\le\but\du\logiciel\imaginez\un\chemin\acces\au\fichier\source\très\long\sous\Windows\et\sous\Linux\vector4.pb"
CompilerEndSelect
The code become very ugly if you want a single source code for all platform. The other solution is to copy files to the folder of each program using these files. But when you found and correct bugs, you will have to copy all files everywhere but you always miss one somewhere. Moreover the entire PureBasic source codes folder will become a real mess !
What I suggest is native in MatLAB and FreeMat and I think it should be implemented in PureBasic.
@ ts-soft
The following structure is not a native one :
Code: Select all
Structure Vector3
i.f
j.f
k.f
EndStructure
If I want to use it in my programs I need to define it somewhere in the current source code (put it in the top of the code, put in a separate file and include it)
What I suggest by adding a ToolBox folder, I put the "Vector3.pb" source code inside the ToolBox folder
Code: Select all
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; CODE GÉNÉRÉ AUTOMATIQUEMENT, NE PAS MODIFIER À
; MOINS D'AVOIR UNE RAISON TRÈS TRÈS VALABLE !!!
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Code généré par : Dev-Type V2.0.0
; Nom du projet : Maths3D
; Nom du fichier : Vector3.pb
; Version du fichier : 1.0.2
; Programmation : OK
; Programmé par : Guimauve
; Date : 20-05-2007
; Mise à jour : 11-01-2011
; Codé pour PureBasic V4.51
; Plateforme : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Déclaration de la Structure <<<<<
Structure Vector3
i.f
j.f
k.f
EndStructure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Les observateurs <<<<<
Macro GetVector3i(VectorA)
VectorA\i
EndMacro
Macro GetVector3j(VectorA)
VectorA\j
EndMacro
Macro GetVector3k(VectorA)
VectorA\k
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Les mutateurs <<<<<
Macro SetVector3i(VectorA, P_i)
GetVector3i(VectorA) = P_i
EndMacro
Macro SetVector3j(VectorA, P_j)
GetVector3j(VectorA) = P_j
EndMacro
Macro SetVector3k(VectorA, P_k)
GetVector3k(VectorA) = P_k
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur Update <<<<<
Macro UpdateVector3(VectorA, P_i, P_j, P_k)
SetVector3i(VectorA, P_i)
SetVector3j(VectorA, P_j)
SetVector3k(VectorA, P_k)
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur Reset <<<<<
Macro ResetVector3(VectorA)
ClearStructure(VectorA, Vector3)
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur Copy : A = Source : B = Destination <<<<<
Macro CopyVector3(VectorA, VectorB)
CopyMemory(VectorA, VectorB, SizeOf(Vector3))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur Compare <<<<<
Macro CompareVector3(VectorA, VectorB)
CompareMemory(VectorA, VectorB, SizeOf(Vector3))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur Swap <<<<<
Macro SwapVector3(VectorA, VectorB)
Swap GetVector3i(VectorA), GetVector3i(VectorB)
Swap GetVector3j(VectorA), GetVector3j(VectorB)
Swap GetVector3k(VectorA), GetVector3k(VectorB)
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur Equal : A = B <<<<<
Macro EqualVector3(VectorA, VectorB)
CopyMemory(VectorB, VectorA, SizeOf(Vector3))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur Plus : R = A + B <<<<<
Macro PlusVector3(VectorR, VectorA, VectorB)
SetVector3i(VectorR, GetVector3i(VectorA) + GetVector3i(VectorB))
SetVector3j(VectorR, GetVector3j(VectorA) + GetVector3j(VectorB))
SetVector3k(VectorR, GetVector3k(VectorA) + GetVector3k(VectorB))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur Minus : R = A - B <<<<<
Macro MinusVector3(VectorR, VectorA, VectorB)
SetVector3i(VectorR, GetVector3i(VectorA) - GetVector3i(VectorB))
SetVector3j(VectorR, GetVector3j(VectorA) - GetVector3j(VectorB))
SetVector3k(VectorR, GetVector3k(VectorA) - GetVector3k(VectorB))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur Zero <<<<<
Macro ZeroVector3(VectorA)
SetVector3i(VectorA, 0.0)
SetVector3j(VectorA, 0.0)
SetVector3k(VectorA, 0.0)
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur One <<<<<
Macro OneVector3(VectorA)
SetVector3i(VectorA, 1.0)
SetVector3j(VectorA, 1.0)
SetVector3k(VectorA, 1.0)
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur ProductByScalar : R = A * Scalar <<<<<
Macro ProductByScalarVector3(VectorR, VectorA, Scalar)
SetVector3i(VectorR, GetVector3i(VectorA) * Scalar)
SetVector3j(VectorR, GetVector3j(VectorA) * Scalar)
SetVector3k(VectorR, GetVector3k(VectorA) * Scalar)
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur DivideByScalar : R = A / Scalar <<<<<
Macro DivideByScalarVector3(VectorR, VectorA, Scalar)
SetVector3i(VectorR, GetVector3i(VectorA) / Scalar)
SetVector3j(VectorR, GetVector3j(VectorA) / Scalar)
SetVector3k(VectorR, GetVector3k(VectorA) / Scalar)
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Lecture sur fichier Binaire <<<<<
Macro ReadVector3(FileID, VectorA)
ReadData(FileID, VectorA, SizeOf(Vector3))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Écriture sur fichier Binaire <<<<<
Macro WriteVector3(FileID, VectorA)
WriteData(FileID, VectorA, SizeOf(Vector3))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Ajout d'attribus au noeud courant <<<<<
Macro AddVector3XMLAttribute(CurrentNode, VectorA)
SetXMLAttribute(CurrentNode, "i", StrD(GetVector3i(VectorA)))
SetXMLAttribute(CurrentNode, "j", StrD(GetVector3j(VectorA)))
SetXMLAttribute(CurrentNode, "k", StrD(GetVector3k(VectorA)))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Collecte d'attributs à partir du noeud courant <<<<<
Macro CollectVector3XMLAttribute(CurrentNode, VectorA)
SetVector3i(VectorA, ValD(GetXMLAttribute(CurrentNode, "i")))
SetVector3j(VectorA, ValD(GetXMLAttribute(CurrentNode, "j")))
SetVector3k(VectorA, ValD(GetXMLAttribute(CurrentNode, "k")))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Code généré en : 00.012 secondes (23166.67 lignes/seconde) <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Macro de Formatage <<<<<
Macro FormatVector3(VectorA, Decimal = 3, BracketIn = "[", BracketOut = "]", Separator = ", ")
BracketIn + StrF(GetVector3i(VectorA), Decimal) + Separator + StrF(GetVector3j(VectorA), Decimal) + Separator + StrF(GetVector3k(VectorA), Decimal) + BracketOut
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur PlusEx : R = A + B + C <<<<<
Macro PlusVector3Ex(VectorR, VectorA, VectorB, VectorC)
SetVector3i(VectorR, GetVector3i(VectorA) + GetVector3i(VectorB) + GetVector3i(VectorC))
SetVector3j(VectorR, GetVector3j(VectorA) + GetVector3j(VectorB) + GetVector3j(VectorC))
SetVector3k(VectorR, GetVector3k(VectorA) + GetVector3k(VectorB) + GetVector3k(VectorC))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< L'opérateur MinusEx : R = A - B - C <<<<<
Macro MinusVector3Ex(VectorR, VectorA, VectorB, VectorC)
SetVector3i(VectorR, GetVector3i(VectorA) - GetVector3i(VectorB) - GetVector3i(VectorC))
SetVector3j(VectorR, GetVector3j(VectorA) - GetVector3j(VectorB) - GetVector3j(VectorC))
SetVector3k(VectorR, GetVector3k(VectorA) - GetVector3k(VectorB) - GetVector3k(VectorC))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Module d'un vecteur <<<<<
Macro ModulusVector3(VectorA)
Sqr(GetVector3i(VectorA) * GetVector3i(VectorA) + GetVector3j(VectorA) * GetVector3j(VectorA) + GetVector3k(VectorA) * GetVector3k(VectorA))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Produit scalaire de 2 vecteurs : Resultat.f = A · B <<<<<
Macro DotProductVector3(VectorA, VectorB)
(GetVector3i(VectorA) * GetVector3i(VectorB) + GetVector3j(VectorA) * GetVector3j(VectorB) + GetVector3k(VectorA) * GetVector3k(VectorB))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Produit scalaire Triple : Resultat.f = VectorA · (VectorB × VectorC) <<<<<
Macro TripleDotProductVector3(VectorA, VectorB, VectorC)
(Getvector3i(VectorA) * (GetVector3j(VectorB) * GetVector3k(VectorC) - GetVector3k(VectorB) * GetVector3j(VectorC))) + (GetVector3j(VectorA) * (GetVector3k(VectorB) * Getvector3i(VectorC) - Getvector3i(VectorB) * GetVector3k(VectorC))) + (GetVector3k(VectorA) * (Getvector3i(VectorB) * GetVector3j(VectorC) - GetVector3j(VectorB) * Getvector3i(VectorC)))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Produit vectoriel de 2 vecteurs : R = A × B <<<<<
Macro CrossProductVector3(VectorR, VectorA, VectorB)
SetVector3i(VectorR, GetVector3j(VectorA) * GetVector3k(VectorB) - GetVector3k(VectorA) * GetVector3j(VectorB))
SetVector3j(VectorR, GetVector3k(VectorA) * Getvector3i(VectorB) - Getvector3i(VectorA) * GetVector3k(VectorB))
SetVector3k(VectorR, Getvector3i(VectorA) * GetVector3j(VectorB) - GetVector3j(VectorA) * Getvector3i(VectorB))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Trouver la position médiane entre 2 vecteurs positions <<<<<
Macro MedianPositionVector3(VectorR, VectorA, VectorB)
SetVector3i(VectorR, (Getvector3i(VectorA) + Getvector3i(VectorB)) / 2)
SetVector3j(VectorR, (GetVector3j(VectorA) + GetVector3j(VectorB)) / 2)
SetVector3k(VectorR, (GetVector3k(VectorA) + GetVector3k(VectorB)) / 2)
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Calcul d'un point de passage d'une hélice 3D - Équation paramétrique <<<<<
Macro Helix(VectorA, P_Radius, P_TurnsQty, P_Pitch, P_u)
SetVector3i(VectorA, P_Radius * Cos(2 * #PI * P_TurnsQty * P_u))
SetVector3j(VectorA, P_Radius * Sin(2 * #PI * P_TurnsQty * P_u))
SetVector3k(VectorA, P_Pitch * P_TurnsQty * P_u)
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Interpolation linéaire entre 2 vecteurs <<<<<
Macro LerpVector3(VectorR, VectorA, VectorB, P_t)
SetVector3i(VectorR, GetVector3i(VectorA) + P_t * (GetVector3i(VectorB) - GetVector3i(VectorA)))
SetVector3j(VectorR, GetVector3j(VectorA) + P_t * (GetVector3j(VectorB) - GetVector3j(VectorA)))
SetVector3k(VectorR, GetVector3k(VectorA) + P_t * (GetVector3k(VectorB) - GetVector3k(VectorA)))
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Wrap Vector3 avec OpenGL <<<<<
Macro glTranslatedv(VectorA)
glTranslated(GetVector3i(VectorA), GetVector3j(VectorA), GetVector3k(VectorA))
EndMacro
Macro glRotatedv(VectorA)
glRotated(GetVector3i(VectorA), 1.0, 0.0, 0.0) ; Rotate On The X Axis
glRotated(GetVector3j(VectorA), 0.0, 1.0, 0.0) ; Rotate On The Y Axis
glRotated(GetVector3k(VectorA), 0.0, 0.0, 1.0) ; Rotate On The Z Axis
EndMacro
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Vecteur unitaire d'un vecteur <<<<<
Macro UnitVector3Fast(VectorA)
; Le calcule du module dans une variable tampon est nécessaire puisque
; l'écriture et la lecture se fait dans la même zone mémoire.
; Le calcul du module dépend de la valeur i, j et k du vecteur.
Unit_Vector3_Modulus.d = ModulusVector3(VectorA)
If Unit_Vector3_Modulus <> 0.0
DivideByScalarVector3(VectorA, VectorA, Unit_Vector3_Modulus)
EndIf
EndMacro
Procedure UnitVector3(*VectorR.Vector3, *VectorA.Vector3)
; Le calcule du module dans une variable tampon est nécessaire puisque
; l'écriture et la lecture se fait dans la même zone mémoire.
; Le calcul du module dépend de la valeur i, j et k du vecteur.
Unit_Vector3_Modulus.d = ModulusVector3(*VectorA)
If Unit_Vector3_Modulus <> 0.0
DivideByScalarVector3(*VectorR, *VectorA, Unit_Vector3_Modulus)
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< TurncateVector <<<<<
Procedure TurncateVector3(*VectorA.Vector3, MaxLength.f)
Unit_Vector3_Modulus.d = ModulusVector3(*VectorA)
If Unit_Vector3_Modulus >= MaxLength
ProductByScalarVector3(*VectorA, *VectorA, (MaxLength / Unit_Vector3_Modulus))
EndIf
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< LaplacianMeshSmoothing <<<<<
Procedure LaplacianMeshSmoothing(*VertexOut.Vector3, *VertexIn.Vector3, List Surrounding.Vector3(), Lambda.d = 0.15)
ForEach Surrounding()
MinusVector3(Vs_Vin.Vector3, Surrounding(), *VertexIn)
PlusVector3(Result.Vector3, Result, Vs_Vin)
Next
ProductByScalarVector3(Result, Result, Lambda / ListSize(Surrounding()))
PlusVector3(*VertexOut, *VertexIn, Result)
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< FIN DU FICHIER <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<
Then in any other source code I just do this :
Code: Select all
UpdateVector3(MyVector.Vector3, 2.0*#PI, 4.0*#PI, 4.0*#PI)
Debug FormatVector3(MyVector)
And I don't get any :
Structure not found : Vector3
UpdateVector3() is not a function, macro, array, map, or likedlist.
FormatVector3() is not a function, macro, array, map, or likedlist.
Error message, the compiler will seach the ToolBox folder to find the Vector3 structure, the UpdateVector3() and FormatVector3() Macros all by it's self and all unneeded element (constants, other macros, procedures has to be ignored by the compiler). Of course this will probably raise the compiling time a little but it's not very important for me. I can live with 0.5 second longer time to compile.
Best regards.
Guimauve