John Ratcliff's Code Suppository

A place where I insert my code into the anus of the Internet.

 

Wednesday, May 21, 2008

Code Snippet to Render a 3d oriented Arrowhead for debug visualization



Today in true code-snippet form I am releasing a handy little debug function that will generate an oriented 3d arrowhead as 24 triangles. This routine will properly orient the arrow head so it faces the correct direction of the line segment it is associated with.

The API is implemented as a single function call that accepts a starting and ending location, and a size for the arrow head. It returns the triangle count and a const float pointer array of triangles as nine floats, x1,y1,z1, x2,y2,z2, and x3,y3,z3. Simply pass these triangles off to your favorite debug rendering library and you will get nicely formed and oriented debug arrow heads that make visualizing ray segments much easier.

The image above shows the debug visualization of the arrow head in my split mesh tool. Note that the interior of the arrow head is slightly hollowed out, which improves the debug visualization in my opinion.

The source files can be downloaded here:

ArrowHead.h
ArrowHead.cpp

5 Comments:

  • At 5:35 AM, Anonymous Anonymous said…

    Something is wrong in your code, i
    ported into a framework of mine, and all that's show its 3 points with no surfaces.
    Could you post your code in a different form ?

     
  • At 7:25 AM, Blogger John said…

    The routine works just fine, you must be calling it wrong. I just updated the source code so that it includes a tiny test/demonstration/usage example. There is a preprocessor define called 'TEST_MAIN' which, if true, will generate an arrow head and print out the results.

    I use this in production code so I know it works fine. You are probably just getting confused by working with direct floats instead of having a more convenient vector class.

    I avoid using vector classes because there are no standards and everyone has their own.

    John

     
  • At 8:05 AM, Anonymous Anonymous said…

    Do you have any code for visualizing spot light cones too?

     
  • At 3:49 PM, Blogger v71 said…

    Arrowhead.cpp is corrupted, file is incomplete.

     
  • At 1:51 PM, Anonymous Anonymous said…

    I'd also like code to visualize spot light code, both inner and outer angles. Please help.

     

Post a Comment

<< Home