FreeCAD game
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
FreeCAD game
Hi!
I have done a script for a small 'game' using FreeCAD, see it in action here: https://www.youtube.com/watch?v=dORV7CjtmtA
I know this is something non-productive, but I had fun to working at it and it shows something that no other CAD engine has shown jet: to serve as game engine .
Though this assumption is relative, because there are not complex rotations or collisions, so basically is playing with the keyboard input and the placement of the objects. But who knows, maybe in a future it becomes able to handle collisions and other effects
The code is here: https://github.com/JMG1/FreeTruck
Have fun!
Javier.
I have done a script for a small 'game' using FreeCAD, see it in action here: https://www.youtube.com/watch?v=dORV7CjtmtA
I know this is something non-productive, but I had fun to working at it and it shows something that no other CAD engine has shown jet: to serve as game engine .
Though this assumption is relative, because there are not complex rotations or collisions, so basically is playing with the keyboard input and the placement of the objects. But who knows, maybe in a future it becomes able to handle collisions and other effects
The code is here: https://github.com/JMG1/FreeTruck
Have fun!
Javier.
FreeCAD scripts, animations, experiments and more: http://linuxforanengineer.blogspot.com.es/
Open source CNC hot wire cutter project (NiCr): https://github.com/JMG1/NiCr
Exploded Assembly Workbench: https://github.com/JMG1/ExplodedAssembly
Open source CNC hot wire cutter project (NiCr): https://github.com/JMG1/NiCr
Exploded Assembly Workbench: https://github.com/JMG1/ExplodedAssembly
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: FreeCAD game
Such functionality can be useful for architecture application, I guess. Cool!
Re: FreeCAD game
It's easy to do sth similar in V-REP (or other robot simulators), but with working dynamics and collisions . Maybe a little off-topic, but i'd love to see sth like V-REP or Gazebo built upon FreeCAD. It could be used not only for robot simulations but also for simulation of some production lines where there's need for more advanced control (PySimEd for that?) than in simple MBD simulations (NX have similar module). Just food for thought.
Re: FreeCAD game
Looking good.
Re: FreeCAD game
Wow thats awesome, and yes thats really usefull for building modells !!!
Re: FreeCAD game
It really makes fun. And yes this is no game at all. In architecture this is highly appreciated feature. Has anyone an idea how to implement the impact of the truck. The truck should stay on the street. We would need to check if the truck intersects with any other part. I if the truck intersects the truck should go in the opposite direction as long as it intersects. But to test if the truck intersects with all the parts of the model in every second is quite heavy. Only the ones near the truck needs to be checked. Do I write some crap or is this doable. I have never tried something in this regard.
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: FreeCAD game
As for collision testing, I think this can be done by somehow constructing a solid (or, actually, just a face) that contains all the points that truck's origin can be in. I guess, testing a point for being inside a solid is quite quick, should be doable in real time. The generation of the solid, of course, can take as long as needed.
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: FreeCAD game
Spying the Blender collision dedection there is a simple algorithm to check the collisons of the bounding boxes.bernd wrote: But to test if the truck intersects with all the parts of the model in every second is quite heavy.
For more complex structures in most cases its good enough to create a helper composite of some more boxes which approximate the figure.
I have done such scripts with javascript in vrml some years ago and I hope i can recover them.
Re: FreeCAD game
Thanks for your support
I have uploaded a new version that does a very simple collision detection (with the .isInside function). It stops the truck if any of the vertexes is inside of the map.
I've also tried to link the bullet library included in Panda3D with FreeCAD, but without success, and currently, I'm struggling with a complete collision detection that would allow the truck to climb a ramp and something similar to free-fall (surprisingly, testing all the vertexes of the truck takes very little time).
I´ll post here any news about this.
I have uploaded a new version that does a very simple collision detection (with the .isInside function). It stops the truck if any of the vertexes is inside of the map.
I've also tried to link the bullet library included in Panda3D with FreeCAD, but without success, and currently, I'm struggling with a complete collision detection that would allow the truck to climb a ramp and something similar to free-fall (surprisingly, testing all the vertexes of the truck takes very little time).
I´ll post here any news about this.
FreeCAD scripts, animations, experiments and more: http://linuxforanengineer.blogspot.com.es/
Open source CNC hot wire cutter project (NiCr): https://github.com/JMG1/NiCr
Exploded Assembly Workbench: https://github.com/JMG1/ExplodedAssembly
Open source CNC hot wire cutter project (NiCr): https://github.com/JMG1/NiCr
Exploded Assembly Workbench: https://github.com/JMG1/ExplodedAssembly
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: FreeCAD game
A simple and fast boundbox collision detection. In most cases this is realistic enough.
https://www.youtube.com/watch?v=UgImdIQ ... e=youtu.be
https://www.youtube.com/watch?v=UgImdIQ ... e=youtu.be
Code: Select all
def col(actor,obstacles):
av=actor.Shape.BoundBox
for obl in obstacles:
ov=obl.Shape.BoundBox
if ov.XMin < av.XMax and ov.XMax > av.XMin and ov.YMin <= av.YMax and ov.YMax >= av.YMin and ov.ZMin <= av.ZMax and ov.ZMax >= av.ZMin:
print obl.Label
obl.ViewObject.DiffuseColor=(1.0,0.0,0.0)
else:
obl.ViewObject.DiffuseColor=(1.0,1.0,0.0)
def checkCollision():
App=FreeCAD
cy=App.ActiveDocument.Cylinder
c=App.ActiveDocument.Cone
gd=App.ActiveDocument.GeodesicDome
b=App.ActiveDocument.Box
col(b,[cy,c,gd,App.ActiveDocument.Torus])