## Ray-Sphere intersection

After the creation of [We.are.in.Helsinki,3D] i came across a problemwhen using GL_SELECT opengl mode for intersections and picking. I got few complains that when picking a generator the application freezed. I had two options:  1. Make a simplified version of the generator’s spheres to render on the GL_SELECT mode. 2. Create a function that would tell me which object i clicked on using ray-sphere intersections.

I took option 2 and made an example in processing. It uses my own library, Vitamin. Its in the zipfile, make sure it is in the right place.

Explanation:
First i already had my mouse position in 3D. Just had to convert it to world-space and put it in  the magic function that would tell me if the ray has hit anything, in this case a sphere. Magic function below:

```// This function is part of the VRay class. // Takes a point and a radius and returns number of hits int intersectRaySphereHits( Vector3 center, float radius ) { // Solve quadratic equation float a = _direction.lengthSqr(); if (a == 0.0)  return 0; float b = 2.0f * (_point.dot(_direction) - _direction.dot(center)); Vector3 tempDiff = Vector3.sub( center, _point ); float c = tempDiff.lengthSqr() - (radius*radius); float disc = b * b - 4 * a * c; if( disc &lt; 0.0f ) return 0; int numIntersections; if (disc == 0.0f) numIntersections = 1; else numIntersections = 2;   return numIntersections; }```

## Another .obj file loader for java/processing

I’ve noticed people have been looking for a obj file importer for processing/java.
Many thanks to Fabien Sanglard for his original code. I’ve added few more things i found to be important to me and added support for JOGL and processing. It runs over part of my framework called Vitamin, so if you are a pure processing user you might want to check the objscene.pde and change the rendering code.  I wanted to keep the obj importer independent of any API/Bind, so it can be easily used by different API/frameworks/whatever. Hopefully it will work that way.

—–
* Groups (+scene management implemented)
* Vertex, Normal, Texture coordinates
* MTL (material) references.

This Java OBJ Loader DOES NOT support:
* Relative vertex references.
* Anything other than GL_TRIANGLE and GL_QUAD polygons

—–
Includes:
1. Library
2. Documentation
3. Example

—–
How to use it:
1. Copy library folder to processing’s folder
2. Run the example

,