Difference between revisions of "FieldTrip"
m (→FieldTrip meets Reactive: making the torus animation) 
(moved torusPair example) 

Line 3:  Line 3:  
== Abstract == 
== Abstract == 

⚫  
⚫  
'''FieldTrip''' is a library for functional 3D graphics, intended for building static, animated, and interactive 3D geometry, efficient enough for realtime synthesis and display. 
'''FieldTrip''' is a library for functional 3D graphics, intended for building static, animated, and interactive 3D geometry, efficient enough for realtime synthesis and display. 

Our first renderer uses OpenGL, with the usual visual limitations. 
Our first renderer uses OpenGL, with the usual visual limitations. 

Line 17:  Line 17:  
* Report bugs and request features on [http://trac.haskell.org/fieldtrip/ the tracker]. 
* Report bugs and request features on [http://trac.haskell.org/fieldtrip/ the tracker]. 

* Examine the [[FieldTrip/Versions version history]]. 
* Examine the [[FieldTrip/Versions version history]]. 

+  
== Basic types == 
== Basic types == 

Line 34:  Line 35:  
: A primitive placeholder for functional imagery in the spirit of [http://conal.net/Pan Pan]. The intention is to use this type or something like it for texture mapping. Much design and implementation work to be done. 
: A primitive placeholder for functional imagery in the spirit of [http://conal.net/Pan Pan]. The intention is to use this type or something like it for texture mapping. Much design and implementation work to be done. 

−  == FieldTrip meets Reactive == 

+  == Example == 

−  
−  FieldTrip contains no support for animation, because we intend it to be used with the [[Reactive]] functional reactive programming ([[FRP]]) library (and possibly other animation frameworks). 

−  By design, FieldTrip is completely orthogonal to any formulation or implementation of FRP. 

−  The [[reactivefieldtrip]] project connects [[Reactive]] and FieldTrip. 

⚫  
−  To picture above comes from an animation in [[reactivefieldtrip]]. 

−  Load src/Test.hs into ghci, and type 

−  <haskell> 

−  anim3 (spinningG torusPair) 

−  </haskell> 

−  
⚫  
<haskell> 
<haskell> 

torusPair :: Geometry3 
torusPair :: Geometry3 

Line 55:  Line 46:  
f col dx = plasmat col (move3X dx tor) 
f col dx = plasmat col (move3X dx tor) 

</haskell> 
</haskell> 

−  where <hask>pivot3X</hask> and <hask>move3X</hask> are simple helper functions for 3D transformation, and <hask>plasmat</hask> applies a color with a plastic look (defined in <code>Test.hs</code>. 
+  where <hask>pivot3X</hask> and <hask>move3X</hask> are simple helper functions for 3D transformation, and <hask>plasmat</hask> applies a color with a plastic look (defined in <code>Test.hs</code>). 
+  
+  ''[fill in more examples]'' 

+  
+  == FieldTrip meets Reactive == 

+  
+  FieldTrip contains no support for animation, because we intend it to be used with the [[Reactive]] functional reactive programming ([[FRP]]) library (and possibly other animation frameworks). 

+  By design, FieldTrip is completely orthogonal to any formulation or implementation of FRP. 

+  
+  The [[reactivefieldtrip]] project connects [[Reactive]] and FieldTrip. 

+  
+  The picture above comes from an animation in [[reactivefieldtrip]]. 

+  Load <code>src/Test.hs</code> into ghci, and type 

+  <haskell> 

+  anim3 (spinningG torusPair) 

+  </haskell> 
Revision as of 19:54, 10 November 2008
Abstract
FieldTrip is a library for functional 3D graphics, intended for building static, animated, and interactive 3D geometry, efficient enough for realtime synthesis and display. Our first renderer uses OpenGL, with the usual visual limitations. Since FieldTrip is functional, it is about being rather than doing. One describes what models are, not how to render them.
Besides this wiki page, here are more ways to find out about and get involved with FieldTrip:
 Join the FieldTrip mailing list.
 Peruse the library documentation.
 Install from Hackage.
 Download the code repository: darcs get http://code.haskell.org/FieldTrip. Patches welcome.
 Report bugs and request features on the tracker.
 Examine the version history.
Basic types
The basic purpose of the core FieldTrip library is to allow a user build 3D geometry, from individual simple shapes to full 3D scenes. The principal types are as follows.

Geometry3
 3D geometry. These values can be spatially transformed in space (affinely: scale, rotate, translate) and combined (union).

Surf a = (a,a) > (a,a,a)
 Parametric surfaces, i.e., mappings from 2D to 3D. Normals are constructed automatically and exactly via derivatives, thanks to the vectorspace library. These normals are used for shading. For simplicity and composability, surfaces are curved, not faceted. Surface rendering tessellates adaptively, caching tessellations in an efficient, infinite data structure for reuse. The mechanism for choosing tessellation is a very primitive placeholder. FieldTrip provides some basic shapes of surfaces (spheres, torus, cubes, etc) and many functions for manipulating surfaces, colors, etc.

Geometry2
 2D geometry. There's a function (
flatG
) to embed 2D into 3D.

Image o = (R,R) > o
 A primitive placeholder for functional imagery in the spirit of Pan. The intention is to use this type or something like it for texture mapping. Much design and implementation work to be done.
Example
The code for the static torus pair shown above:
torusPair :: Geometry3
torusPair = f red (1/2) `mappend` pivot3X (f green (1/2))
where
tor = torus 1 (2/5)
f :: Col > R > Geometry3
f col dx = plasmat col (move3X dx tor)
where pivot3X
and move3X
are simple helper functions for 3D transformation, and plasmat
applies a color with a plastic look (defined in Test.hs
).
[fill in more examples]
FieldTrip meets Reactive
FieldTrip contains no support for animation, because we intend it to be used with the Reactive functional reactive programming (FRP) library (and possibly other animation frameworks). By design, FieldTrip is completely orthogonal to any formulation or implementation of FRP.
The reactivefieldtrip project connects Reactive and FieldTrip.
The picture above comes from an animation in reactivefieldtrip.
Load src/Test.hs
into ghci, and type
anim3 (spinningG torusPair)