Simple ray collision library (bonus if it loads 3ds and b3d) - c++

I've spent quite some time searching a simple / fast c++ library (Win / Linux) that can answer the two questions 'does this ray crosses any of the triangles?' or 'where is the first intersection, if there are any?'.
It's for my little game I'm writing and will be used to see if a NPC can see a player and also to check if a player can fall all the way to the ground (or not).
The triangles will not move (well, if you can flag a triangle group 'on' / 'off' that would be nice).
I actually found some libraries but only non-continued (or it seems) like OZCollide for example.
Of course there are all those new shiny Physics engines out there but I don't need 99% of what they offer.
A bonus would be if the library can load .3ds an .b3d files and even better if it can be used in a multi threaded environment (creating several instances of the search data).
Thanks all!

Bullet Physics (http://bulletphysics.org/) is a physics library, but it's built in several layers.
Because of this it can be used as just a collision library which is quite efficient at casting rays through a scene.
(You wouldn't be using or be bothered by any of its physics features)
It's available on Windows and Linux, but also on several more platforms and even on game consoles.
The library is proven and used professionally by various game developers.
It does not directly support .3ds files, but it does has a pipeline for getting geometry from various 3D modelling applications converted to the right format Bullet understands.
It might feel overkill to use it because it's a physics library. But that is actually the reason you should be using it.
A physics library is highly reliant on a good collision library, which actually forces the collision library to be of high quality and offer excellent performance.

Well, there seems to be no 'simple & small' library / code out there so I guess the answer might be 'roll your own'.
That is what I did anyway:
a tool that uses Irrlicht to load up my (static) geometry and then save off all (triangle/vertex) data to a file, just 9 floats for each triangle.
Then a collision library that loads up the data into an octree and the c2005 triangle / ray intersection test and it works OK.

Related

How do I detect collision with C++, OpenGL, and freeglut?

I am making a maze game, and I know how to do everything except make it so that you can't just cheat your way through the walls. I am using freeglut with OpenGL in C++ and I would like to know the most effective way of using collision detection ( hopefully without needing to use anything other than freeglut).
OpenGL is just for drawing; it makes things appear onscreen at the coordinates you specify, but it doesn't play a role in deciding what the coordinates of your objects should be. For motion and collision, you may want to use a physics library, such as ODE or Bullet. (There are also bigger, more commercially-oriented physics systems like Havok and PhysX, but those are probably overkill for a simple project.)

Recommendations for a free GIS library supporting raster images

I'm quite new to the whole field of GIS, and I'm about to make a small program that essentially overlays GPS tracks on a map together with some other annotations. I primarily need to allow scanned (thus raster) maps (although it would be nice to support proper map formats and something like OpenStreetmap in the long run).
My first exploratory program uses Qt's graphics view framework and overlays the GPS points by simply projecting them onto the tangent plane to the WGS84 ellipsoid at a calibration point. This gives half-decent accuracy, and actually looks good. But then I started wondering. To get the accuracy I need (i.e. remove the "half" in "half-decent"), I have to correct for the map projection. While the math is not a problem in itself, supporting many map projection feels like needless work. Even though a few projections would probably be enough, I started thinking about just using something like the PROJ.4 library to do my projections. But then, why not take it all the way? Perhaps I might aswell use a full-blown map library such as Mapnik (edit: Quantum GIS also looks very nice), which will probably pay off when I start to want even more fancy annotations or some other symptom of featuritis.
So, finally, to the question: What would you do? Would you use a full-blown map library? If so, which one? Again, it's important that it supports using (and zooming in and out with) raster maps and has pretty overlay features. Or would you just keep it simple, and go with Qt's own graphics view framework together with something like PROJ.4 to handle the map projections? I appreciate any feedback!
Some technicalities: I'm writing in C++ with a Qt-based GUI, so I'd prefer something that plays relatively nicely with those. Also, the library must be free software (as in FOSS), and at least decently cross-platform (GNU/Linux, Windows and Mac, at least).
Edit: OK, it seems I didn't do quite enough research before asking this question. Both Quantum GIS and Mapnik seem very well suited for my purpose. The former especially so since it's based on Qt.
See GDAL www.gdal.org for a solid background library for raster formats and manipulation, and it incorporates PROJ.4 for transformations.
QGIS relies on GDAL for some data import, amongst other things.

Is there a middleground between writing raw OpenGL versus using a full-blown game engine?

I'm playing around with OpenGL and I'm finding myself writing code that I feel like I shouldn't have to write.
GLU and GLUT are nice but not really what I'm thinking of.
Code to load .obj models (vertex and normal vectors) from Blender and render them.
Code for collision detection.
Code for navigation/camera stuff.
Code for simple terrain generation.
But at the same time I feel like a full-blown game engine is more than I need.
Are there any good libraries built on top of OpenGL that I could take advantage of, perhaps to create relatively simple games? I don't necessarily need all of the items listed above. Those are just examples of what I'm thinking of.
Yes.
I can't be more specific as I don't write my own game engines but I do have a list of libraries online at this location, most of which sit below being a full engine.
Ogre
Irrlicht
openscenegraph (replaces performer)
Depending on how much you need, one of these toolkits / libraries might suit your purpose.
GLUT - OpenGL Utility Toolkit
Ogre3D - OGRE Object Oriented Graphics Library
Open Inventor - OpenGL toolkit for scene management created by SGI
Performer - OpenGL toolkit for real-time rendering created by SGI
I learnt my opengl stuff from GameTutorials and Gamedev. Unfortunately gametutorials are no longer a free selection of tutorial (there's some examples) but they were good. Coupled with SDL, you would have code to do everything you wanted - and you'd be able to understand what is going on under the covers, something I find is very useful later on (if, for example you wanted to write HTML5/WebGL code later).
A lot of the game engines aren't as well documented as I'd like (well, weren't a few years back when I was looking), but they might still do what you need. Sourceforge has many, including Ogre3d, Irrlicht, and CrystalSpace.
In general I agree with your sentiment. There is a school of thought that says that programming should consist of pluggable modules. Once youve written an OpenGL app, you should be able to grab a model loader, and/or a skeletal animation engine and plug them in.
The depressing thing is, most of the game engines on that list (that Ive looked at) are all or nothing propositions. They provide an entire framework and do not really take into account the more common real case scenario.
That said, all is not lost. A lot of those engines package up a number of other 'utility' libraries into their distribution. With a bit of patience it is possible to piece together the component libraries yourself: OpenAL for the sound, Freetype for font rendering, libpng, libjpeg etc for image codecs

Recommendations for C++ 3d vector/matrix library with targeted camera

I am writing a very simple 3d particle software rendering system, but I am only really interested in coding the particle system and the rasterizer, so what I am looking for, is the easiest way to go from 3d particle coordinates, through camera, to screen coordinates, but with features like variable FOV, and targeted (look at) camera.
Any additional features such as distance from point to point, bounding volumes etc. would be a bonus, but ease of use is more important to me than features.
The only license requirement is that it's free (as in beer).
You probably want a scenegraph library. Many C++ scene graph libraries exist. OpenScenegraph is popular, Coin3D (free for non-commercial use) is an implementation of the OpenInventor spec, any of them would probably fit your need as it doesn't sound like you need any cutting-edge support. There is also Panda3D, which I've heard is good if you're into Python.
You could do all of this in a straight low-level toolkit like OpenGL but without prior experience it takes a lot longer to get a handle on using OpenGL than any of the scenegraph libraries.
When choosing a scenegraph library it will probably just come down to personal preference as to which API you prefer.
Viewing is done with elementary transformations, the same way that model transformations are done. If you want some convenience functions like gluLookAt() in GLU, then I don't know, but it would be really easy to make your own.
If you do want to make your own Look At function etc. then I can recommend eigen which is a really easy to use linear algebra library for C++.
If you're trying to just focus on the rendering portion of a particle system, I'd go with an established 3D rendering library.
Given your description, you could consider trying to just add your particle rasterization to one or both of the software renderers in Irrlicht. One other advantage of this would be that you could compare your results to the DX/OGL particle effect renderers that already exist. All of the plumbing/camera management/etc would be done for you.
You may also want to have a look at the Armadillo C++ library

3D scene file format & viewer

I am looking for a cross-platform solution for saving and viewing 3D scenes (visualizations of engineering simulation models and results) but there (still) doesn't seem to be much out there.
I looked into this almost 10 years ago and settled on VRML then (and started the project that eventually turned in OpenVRML). Unfortunately, VRML/X3D has not become anywhere near ubiquitous in the past decade.
Ideally a solution would offer a C++ library that could be plugged in to a 3D rendering pipeline at some level to capture the 3D scene to a file; and a freely redistributable viewer that allowed view manipulation, part hiding, annotation, dimensioning, etc. At least linux, mac, and windows should be supported.
3D PDFs would seem to meet most of the viewer requirements, but the Adobe sdk is apparently only available on Windows.
Any suggestions ?
The closest thing that I'm aware of is Collada.
Many 3D engines can read it, and most 3D design tools can read and write it.
I believe the Ogre engine has pretty good support.
If you are using OpenGL, GLIntercept will save all OpenGL calls (with the data they were called with) to a XML file. It's only half the solution, though, but it shouldn't be hard to parse it and recreate the scene yourself.
Take a look at Ogre3d.org. Its just an engine, you must program with it. But OGRE is probably the better (free/open) platform to develop 3D right now.