Epy, no. BRL-CAD uses constructive solid geometry, using primitive solids and their unions, intersections, and exclusions to define the object. It has very limited support for triangular meshes.
Nyah Check, if you only wanted to construct a heart, you could easily do so using ellipsoids and cuboids (cuboids intersecting with the ellipsoids to make it easier to join the parts seamlessly, and build the heart from easier building blocks) -- perhaps just two ellipsoids, one for each half, with a cuboid intersecting with that half, and joined at x=0 plane. (That's what I'd do. I don't like the nipple at the bottom of the heart at all.)
However, I am assuming you want to see how you could add the heart as a primitive solid to the program.
The main work is pretty much math. I didn't bother to check exactly how BRL-CAD does it, so I'm offering the points below as they relate to constructive solid geometry in general.
(x2 + 9/4 y2 + z2 - 1)3 - x2 y3 - 9/80 y3 z3 = 0defines the surface of the heart. It happens to be symmetric along the x axis, so you can rewrite it into x=±(function(y,z)), will probably turn out to be very useful. (Solve the equation for x2, and you get a cubic equation you can solve algebraically.)
For lighting (ray tracing), you'll probably need to parametrize the surface equation, converting it into form
x = function1(u, v)so that you can compute the normal vector using the cross product of the partial derivatives of the coordinate functions. That is,
y = function2(u, v)
z = function3(u, v)
xu(u,v) = ∂function1(u, v) / ∂uwhere vectors
xv(u, v) = ∂function1(u, v) / ∂v
yu(u, v) = ∂function2(u, v) / ∂u
yv(u, v) = ∂function2(u, v) / ∂v
zu(u, v) = ∂function3(u, v) / ∂u
zv(u, v) = ∂function3(u, v) / ∂v
are tangential to the surface; therefore
tu(u, v) = <xu(u,v) yu(u,v) zu(u,v)>
tv(u, v) = <xv(u,v) yv(u,v) zv(u,v)>
p(u, v) = tu(u,v) × tv(u,v)gives a vector perpendicular to the tangent, i.e. normal to the surface.
normal(u, v) = p(u, v) / || p(u, v) ||
The most important formula is the inequality that defines which part of space is inside the heart. This is given by the inequality
(x2 + 9/4 y2 + z2 - 1)3 - x2 y3 - 9/80 y3 z3 < 0
For visualization (rendering), you will absolutely need a line-heart intersection test. You can optimize the test by realizing that any line (ray) that comes closer than 0.61 of the center of the heart will intersect the heart, and only those lines that come closer than 1.1 of the center of the heart may intersect it. (The point of intersection(s) are those that satisfy the line equation and the equation for the surface of the heart at the same coordinates x, y, z.)
For lighting, you'll also need the surface normal at those intersection points; I already explained the common/typical way to find the normal, above.
Depending on the BRL-CAD innards (the kind of processing it supports on analyzing the composite objects modelled), you may also need more complex intersections, probably between the heart and each of the primitive solids supported by the program. These are solved the same way you solve the heart-line intersection, but the solution is a surface in 3D (usually parametrized using u,v).
- Constructive solid geometry at Wikipedia
- Line-sphere intersection at Wikipedia
- Surface normal at Wikipedia
- Normal vector at Wolfram MathWorld
- 3D point-line distance at Wolfram MathWorld (for line-sphere intersections!)
- My user page at Wikipedia, describing line-cylinder intersection, with the line passing through origin. (I did that page in 2010, when I needed efficient solutions for line-sphere and line-cylinder intersections for ray-tracing ball-and-stick molecular models with millions of atoms. The trick with rays passing through origin (at optical focal point) turns out to make everything much simpler and faster to calculate.)
When you have the above math roughly solved, and written them as sufficiently efficient C code (to see there are no precision/numeric issues), you can start adding the primitives to BRL-CAD. Note that unless you can do all the math that BRL-CAD needs for the heart, none of it is useful; it's an all-or-nothing deal. Depending on the codebase, you might not need the algebraic solutions for all, numeric ones may suffice. If you look at BRL-CAD source (I have not!), you should find the code that handles the primitives. If it is well commented, you should see which equations you need to implement for a new primitive. And, you'll also need to add the support for the heart parameters (orientation, scaling) to the CAD language.
All in all, I suspect this is much more work than you originally envisioned. That is because the primitives in solid constructive geometry are very fundamental objects, and adding a new one -- especially a complicated one -- is not going to be easy.
I hope this helps you. Good luck with your efforts!
P.S. Did you know that ♥ originally depicted two hearts joined together?