Tokamak-c (Windows/Linux 32/64-bit) Tue Oct 17
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Tokamak-c (Windows/Linux 32/64-bit) Tue Oct 17
Tokamak is a small C++ physics rigidbody library for games. (without any graphic engine)
Tokamak-c is an C wrapper I wrote completely new.
I'm sure nobody will learn or use it however I share all my work here since 2005 :-)
Joshy
My youtube tokamak playlist: https://www.youtube.com/watch?v=FUQwghB ... 0812CA9448
Download: tokamak-c.zip Tue Oct 17
Codeblocks project: tokamak-c-src.zip
Tokamak in action rendered with the modern Horde3D engine for FreeBASIC.
Tokamak-c is an C wrapper I wrote completely new.
I'm sure nobody will learn or use it however I share all my work here since 2005 :-)
Joshy
My youtube tokamak playlist: https://www.youtube.com/watch?v=FUQwghB ... 0812CA9448
Download: tokamak-c.zip Tue Oct 17
Codeblocks project: tokamak-c-src.zip
Tokamak in action rendered with the modern Horde3D engine for FreeBASIC.
Last edited by D.J.Peters on Oct 12, 2022 18:36, edited 10 times in total.
Re: Tokamak-c (Windows/Linux 32/64-bit)
hi Joshy
that looks really good, thanks for sharing. :-)
that looks really good, thanks for sharing. :-)
Re: Tokamak-c (Windows/Linux 32/64-bit)
Thank you for sharing it, maybe its helpful for somebody now or in the future. I probably wont need it, though - at least I haven't yet in the past. Haven't you shared some other physics engine in the past?
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Tokamak-c (Windows/Linux 32/64-bit)
OpenDE Physics SDK version 0.11.1 for FreeBASIC (before ODE headers was included in FreeBASIC)St_W wrote: Haven't you shared some other physics engine in the past?
Simple Physics Engine for FreeBASIC (WIN32 only)
first Tokamak Physics SDK (Windows/Linux 32-bit only)
TrueAxis for FreeBASIC (Windows/Linux 32/64-bit)
...
Joshy
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Tokamak-c (Windows/Linux 32/64-bit)
Added some commands and a simple OpenGL preview renderer.
The renderer can render some of Tokamak classes: neAnimatedBody, neRigidBody, neSensor and the neTriangleMesh = Terrain.
Joshy
The renderer can render some of Tokamak classes: neAnimatedBody, neRigidBody, neSensor and the neTriangleMesh = Terrain.
Joshy
Re: Tokamak-c (Windows/Linux 32/64-bit)
compiling on windows 10, 64 bit
I copy
libtokamak-c-64.dll.a
libtokamak-c-32.dll.a
To \FreeBASIC-1.05.0-win64\lib\win64
I keep these files in the C:\FreeBASIC-1.05.0-win64\tokamak-c folder
tokamak-c-64.dll
tokamak-c-32.dll
my build error is
C:\FreeBASIC-1.05.0-win64\fbc -s console "test01.bas"
C:\FreeBASIC-1.05.0-win64\bin\win64\ld.exe: skipping incompatible C:\FreeBASIC-1.05.0-win64\lib\win64/libtokamak-c-32.dll.a when searching for -ltokamak-c-32
C:\FreeBASIC-1.05.0-win64\bin\win64\ld.exe: skipping incompatible ./tokamak-c-32.dll when searching for -ltokamak-c-32
C:\FreeBASIC-1.05.0-win64\bin\win64\ld.exe: skipping incompatible C:\FreeBASIC-1.05.0-win64\lib\win64/libtokamak-c-32.dll.a when searching for -ltokamak-c-32
C:\FreeBASIC-1.05.0-win64\bin\win64\ld.exe: skipping incompatible ./tokamak-c-32.dll when searching for -ltokamak-c-32
C:\FreeBASIC-1.05.0-win64\bin\win64\ld.exe: cannot find -ltokamak-c-32
I feel so stupid, why is this not compiling?
I copy
libtokamak-c-64.dll.a
libtokamak-c-32.dll.a
To \FreeBASIC-1.05.0-win64\lib\win64
I keep these files in the C:\FreeBASIC-1.05.0-win64\tokamak-c folder
tokamak-c-64.dll
tokamak-c-32.dll
my build error is
C:\FreeBASIC-1.05.0-win64\fbc -s console "test01.bas"
C:\FreeBASIC-1.05.0-win64\bin\win64\ld.exe: skipping incompatible C:\FreeBASIC-1.05.0-win64\lib\win64/libtokamak-c-32.dll.a when searching for -ltokamak-c-32
C:\FreeBASIC-1.05.0-win64\bin\win64\ld.exe: skipping incompatible ./tokamak-c-32.dll when searching for -ltokamak-c-32
C:\FreeBASIC-1.05.0-win64\bin\win64\ld.exe: skipping incompatible C:\FreeBASIC-1.05.0-win64\lib\win64/libtokamak-c-32.dll.a when searching for -ltokamak-c-32
C:\FreeBASIC-1.05.0-win64\bin\win64\ld.exe: skipping incompatible ./tokamak-c-32.dll when searching for -ltokamak-c-32
C:\FreeBASIC-1.05.0-win64\bin\win64\ld.exe: cannot find -ltokamak-c-32
I feel so stupid, why is this not compiling?
Re: Tokamak-c (Windows/Linux 32/64-bit)
There seems to be a small error in the header; it wants to import the 32-bit library although you are using 64-bit FreeBasic.
In tokamak-c.bi change
to
I don't think __FB_WIN64__ is a valid symbol defined by the compiler; at least it's not listed here: http://freebasic.net/wiki/wikka.php?wak ... gDddefines
In tokamak-c.bi change
Code: Select all
#Ifndef __FB_WIN64__
#Inclib "tokamak-c-32"
#else
#inclib "tokamak-c-64"
#EndIf
Code: Select all
#Ifndef __FB_64BIT__
#Inclib "tokamak-c-32"
#else
#inclib "tokamak-c-64"
#EndIf
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Tokamak-c (Windows/Linux 32/64-bit)
Thank you for testing It's fixed now.
I tested it on 4 boxes Win XP 32-bit / Windows 10 64-bit and Linux Slackware 32-bit / Linux Ubuntu 64-bit.
test02.bas are new and was fun a small challenge !
Normally you can shot 4 spheres near bottom of the wall and it will break
but the challenge are "how to destroy it slowly" :-)
There is a problem with the lib if I compile it with -O2
capsule capsule collision becomes error this version is compiles with -O0 (no optimation)
the error are gone but it's slow.
Last two days I study the complete tokamak C++ code and fixed some small bugs.
I understand currently 70% of all the stuff but the rest are a big secret or challenge for me.
If I find the problem I will recompile it with -O2 and make a new upload.
Joshy
I tested it on 4 boxes Win XP 32-bit / Windows 10 64-bit and Linux Slackware 32-bit / Linux Ubuntu 64-bit.
test02.bas are new and was fun a small challenge !
Normally you can shot 4 spheres near bottom of the wall and it will break
but the challenge are "how to destroy it slowly" :-)
There is a problem with the lib if I compile it with -O2
capsule capsule collision becomes error this version is compiles with -O0 (no optimation)
the error are gone but it's slow.
Last two days I study the complete tokamak C++ code and fixed some small bugs.
I understand currently 70% of all the stuff but the rest are a big secret or challenge for me.
If I find the problem I will recompile it with -O2 and make a new upload.
Joshy
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Tokamak-c (Windows/Linux 32/64-bit) Jan 19, 2017
Code: Select all
#include once "rendering.bi"
const MAX_CUBES = 30*30
dim as neSimulatorSizeInfo SizeInfo
with SizeInfo
.rigidBodiesCount = MAX_CUBES + 1 ' one sphere
.animatedBodiesCount = 1
.geometriesCount = .rigidBodiesCount + .animatedBodiesCount
.overlappedPairsCount = (.geometriesCount*(.geometriesCount-1))/2
end with
var sim = CreateSimulator(SizeInfo)
var grd = CreateAnimatedBodyBox(sim,1000,2,1000)
AnimatedBodySetPosition(grd,0,-2,0)
const as integer SQR_CUBES = sqr(MAX_CUBES)
dim as neRigidBody ptr cubes(MAX_CUBES-1)
for i as integer = 0 to MAX_CUBES-1
cubes(i) = CreateRigidBodyCube(sim,1,1)
var col = i \ SQR_CUBES
var row = i mod SQR_CUBES
RigidBodySetPosition(cubes(i),(-SQR_CUBES\2) + col + (row and 1)*0.5,-.5+row*1.01,50)
RigidbodySetLinearDamping (cubes(i),.5)
RigidbodySetAngularDamping(cubes(i),.5)
next
dim as RENDERER gfx
glLoadIdentity()
LookAt(0,40,-5, 0,30,20, 0,1,0)
var n=0
var flag=true
while flag=true
n=0
flag=false
for i as integer = 1 to 30
SimulatorAdvance(sim)
next
gfx.cls
gfx.render(grd)
for i as integer = 0 to MAX_CUBES-1
if RigidBodyIsIdle(cubes(i))=false then n+=1:flag=true
gfx.render(cubes(i))
next
gfx.Swapbuffers
windowtitle "build a wall of stacking bricks please wait until all bricks becomes resting ! ... " & n
wend
for i as integer = 0 to MAX_CUBES-1
RigidbodySetLinearDamping (cubes(i),0.01)
RigidbodySetAngularDamping(cubes(i),0.01)
next
var sphere = CreateRigidBodySphere(sim,1,1000)
RigidBodySetPosition(sphere,0,SQR_CUBES\4,60)
dim as neV3 spherepos,heightpos,boxpos
dim as neV3 cannon
dim as integer frame
windowtitle "OK"
while inkey()=""
SimulatorAdvance(sim,1/100)
if frame mod 3=0 then
gfx.cls
gfx.render(grd)
gfx.render(sphere)
heightpos.y=0
for i as integer = 0 to MAX_CUBES-1
if RigidBodyIsIdle(cubes(i)) then
boxpos=RigidBodyGetPositionV3(cubes(i))
if boxpos.y>heightpos.y then heightpos=boxpos
end if
gfx.render(cubes(i))
next
gfx.Swapbuffers
end if
spherepos = RigidBodyGetPositionV3(sphere)
if spherepos.z>55 then
for i as integer = 0 to MAX_CUBES-1
if RigidBodyIsIdle(cubes(i)) then
boxpos=RigidBodyGetPositionV3(cubes(i))
if boxpos.y>heightpos.y then heightpos=boxpos
end if
next
spherepos.x=0 : spherepos.y=heightpos.y/2 : spherepos.z=0
heightpos.x-=spherepos.x : heightpos.y-=spherepos.y : heightpos.z-=spherepos.z
heightpos.x+=(rnd-rnd)*0.1:heightpos.y+=(rnd-rnd)*0.1
V3Normalize(heightpos)
heightpos.x*=60 : heightpos.y*=60 : heightpos.z*=60
RigidBodySetPosition(sphere,0,spherepos.y+4,0)
RigidBodySetVelocity(sphere,heightpos)
end if
sleep 10
frame+=1
wend
DestroySimulator(sim)
Re: Tokamak-c (Windows/Linux 32/64-bit) Jan 19, 2017
Very cool. I had to realize that commenting out the Sleep 10 and if frame mod 2=0 then... statements will make the simulation go faster on this slow laptop.
I assume complex bodies are made by adding triangles to neTriangleMesh object.
Great job DJ !
I assume complex bodies are made by adding triangles to neTriangleMesh object.
Great job DJ !
Re: Tokamak-c (Windows/Linux 32/64-bit)
on my Win xp 32D.J.Peters wrote:...
I tested it on 4 boxes Win XP 32-bit / Windows 10 64-bit and Linux Slackware 32-bit / Linux Ubuntu 64-bit.
...
Joshy
The "physictest01.bas" compiles ok, however at run time:
error: h3dInit() !
normally my screen resolution is 1280x1024.
Through the control panel screen res changed to: 1024x768 -- same error message at run time.
What program modifications should be made to avoid the run time error?
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Tokamak-c (Windows/Linux 32/64-bit) Jan 19, 2017
@integer I tested my latest version of tokamak here
but you talk about a problem with Horde3D engine it's here here: http://www.freebasic.net/forum/viewtopi ... 14&t=23969
if h3dInit() fails it means you don't have a working OpenGL 2.x gfx card ?
Joshy
but you talk about a problem with Horde3D engine it's here here: http://www.freebasic.net/forum/viewtopi ... 14&t=23969
if h3dInit() fails it means you don't have a working OpenGL 2.x gfx card ?
Joshy
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Tokamak-c (Windows/Linux 32/64-bit) Jan 19, 2017
Does anyone knows how to calculate the Inertia Tensor for a combined volume ?
Here are I combine 4 boxes and one sphere in the center but I don't know how to get the tensor for this kind of object.
Is it the sum of 4 box and 1 sphere inertia tensor or the sum/5 or a multiply of 5 inertia tensor matrixes ?
Joshy
Here are I combine 4 boxes and one sphere in the center but I don't know how to get the tensor for this kind of object.
Is it the sum of 4 box and 1 sphere inertia tensor or the sum/5 or a multiply of 5 inertia tensor matrixes ?
Joshy
Code: Select all
#include once "rendering.bi"
const as f32 MASS = 100
function CreateCombinedRigidBody(sim as neSimulator ptr) as neRigidBody ptr
var rb = SimulatorCreateRigidBody(sim)
var g0 = RigidBodyAddGeometry(rb)
var g1 = RigidBodyAddGeometry(rb)
var g2 = RigidBodyAddGeometry(rb)
var g3 = RigidBodyAddGeometry(rb)
var g4 = RigidBodyAddGeometry(rb)
var p0 = neV3(0,0,0)
var p1 = neV3(-1,0,-1)
var p2 = neV3(-1,0, 1)
var p3 = neV3( 1,0, 1)
var p4 = neV3( 1,0,-1)
var zero = neV3()
GeometrySetSphereDiameter(g0,1.5) : GeometrySetPositionRotationV3(g0,p0,zero)
GeometrySetBoxSize(g1,1,1,1) : GeometrySetPositionRotationV3(g1,p1, zero)
GeometrySetBoxSize(g2,1,1,1) : GeometrySetPositionRotationV3(g2,p2, zero)
GeometrySetBoxSize(g3,1,1,1) : GeometrySetPositionRotationV3(g3,p3, zero)
GeometrySetBoxSize(g4,1,1,1) : GeometrySetPositionRotationV3(g4,p4, zero)
RigidBodyUpdateBoundingInfo(rb)
return rb
end function
'
' main
'
var sim = CreateSimulator()
var ground = CreateAnimatedBodyBox(sim,500,2,500)
AnimatedBodySetPosition(ground,0,-1,0) ' make top face at zero (ground)
var rb1 = CreateCombinedRigidBody(sim)
RigidBodySetInertiaTensor(rb1,neSphereInertiaTensor(3, MASS*5))
RigidBodySetMass(rb1,MASS*5)
RigidBodyUpdateBoundingInfo(rb1)
RigidBodySetPositionRotation(rb1,-3,1.75,0, 120,0,0)
var rb2 = CreateCombinedRigidBody(sim)
RigidBodySetInertiaTensor(rb2,neBoxInertiaTensor(3,1.5,3,MASS*5))
RigidBodySetMass(rb2,MASS*5)
RigidBodyUpdateBoundingInfo(rb2)
RigidBodySetPositionRotation(rb2, 3,1.75,0, 120,0,0)
dim as RENDERER gfx
dim as integer frame
windowtitle "sleepinmg: " & RigidBodyGetSleepingParameter(rb1)
while inkey()=""
SimulatorAdvance(sim) ' 60 Hz.
if frame mod 2=0 then ' 30 Hz.
gfx.cls
glLoadIdentity()
glTransLatef(0,-4,-20)
gfx.render(ground)
gfx.render(rb1)
gfx.render(rb2)
gfx.Swapbuffers
else
sleep(10) ' don't use all CPU cycles
end if
frame+=1
wend
DestroySimulator(sim)
Re: Tokamak-c (Windows/Linux 32/64-bit) Jan 26, 2017
We use your work DJ! Let's say I use your FLTK lib on almost everyday baseI'm sure nobody will learn or use it however I share all my work here since 2005 :-)
But I have nothing to say or ask, I didnot find any bug or so ..
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Tokamak-c (Windows/Linux 32/64-bit) Jan 26, 2017
fixed a bug for 64-bit
Joshy
Joshy