View Full Version : 3D Tubes: Knot and spiral with physics
i will post the code even it is still in spaghetti mode.
to make a 3D tube, we plot the one dimensional curve point by point then we use frenet frame to extrude points from every point so it form a circle and after many circles (Bands) we connect the points with triangles, look:
http://www.dbfinteractive.com/forum/index.php?topic=5993.0
download everything needed to run the 2 examples (code + xors3D dlls + pictures all in one folder) from here:
https://www.mediafire.com/?ffbt3ahu0docy8p
included:
1- 3D knot from tube, with concave physical body, and a sphere run inside it
2- spiral from tube
you need the DirectX 9 installed in your machine
http://download.microsoft.com/download/8/4/A/84A35BF1-DAFE-4AE8-82AF-AD2AE20B6B14/directx_Jun2010_redist.exe
Tested in windows xp/32
9707
EDIT: to close the knot (approx) replace:
While angle <= 2*Pi - 0.1
with:
While angle <= 2*Pi
Really impressive Primo. Both of the examples ran at 61 fps!
I will look through the code later to study, but just had fun running it right now to test.
Again, very nice!
Thanks kryton9, there is not much documentation about xors3d but we can learn more from examples ,there is a version for purebasic here:
https://github.com/Guevara-chan/Xors3D-for-PB
which have much more examples from several years.
there is also a short documentation file in the above link
but there is not much talk about 3D in general in most basic languages forums.
it is as if the users prefer 2D graphics.
i have made an experiment, usually the owners of new computers don't like to install DX9 on there computers. so i have downloaded directx_Jun2010_redist.exe from microsoft, then we extract it to some folder, and since the files have *x86 and *x64 names, we need only x86 for xors3d, then from command prompt:
C:\DX9>copy *x86.* c:\DX9_x86
we then go to c:\DX9_x86 and select all the archives and with right click choose extract here, and overright all files. then we need only the dll files begins with d3dx9 it is smaller than x64 versions such as d3dx9_42.dll size is 1.8 MB for x86 while it is 2.4 for x64
here is all dx9 dlls x86 files
https://www.mediafire.com/?fu3yd9pvv631hyq
i have tested the files in xors3d_thinbasic in a laptop with win10_x64 and it seems there is no DX9 installed on it since running the Knot example gives an error like this:
9709
then i have copied all the DX9 dlls extracted in the above method to the xors3d_thinbasic folder and now the knot example works okay.
so for distribution we need only to provide dx9 dlls without asking the user to install dx9 on his expensive machine. i am happy this method works , but still not sure for all windows machines which does not have DX9 installed explicitly on it.
Since thinBasic is a Windows Development Language and anyone interested in 3D is probably also some sort of gamer, they probably have directx installed. DirectX 9 is was a great version for DirectX, so I wouldn't be worried about having it installed. Good to know you can just copy the dll's though. If I ever do a clean install again, I will try to remember that.
1-
i have found how to convert your graphics with xors3d to OBJ file
in the above example http://www.thinbasic.com/community/showthread.php?12771-3D-Tubes-Knot-and-spiral-with-physics&p=93604&viewfull=1#post93604 ( https://www.mediafire.com/?ffbt3ahu0docy8p ) add after Line While IsFalse xKeyDown(%KEY_ESCAPE):
If xKeyUp(%KEY_S) Then
xSaveMesh(mesh, "spiral")
End If
this will save the mesh to spiral.fbx if you press 'S' key
now download Autodesk FBX Converter 2013, FBX® 2013.3 Converter: http://usa.autodesk.com/adsk/servlet/pc/item?siteID=123112&id=22694909
how to use:
to view your file spiral.fbx
Tools -> add fbx viewer
File -> choose your file
=======================
to convert the file to Obj or DXF or DAE collada
Tools -> add fbx converter
Add -> choose your fbx file
Destination Format -> Obj ,DXF, DAE collada
Convert
==============================================
view your Obj file with a small good viewer :view3dscene from https://castle-engine.sourceforge.io/view3dscene.php
********************************************
2-
regarding running thinbasic xors3d without installing DX9, i have found that for the above specific knot and spiral examples it is enough to put d3dx9_36.dll only in the folder of the source code together with xors3d dlls files. surprisingly i can't do the same trick with purebasic in windows 10 without DX9