[Bf-committers] Preliminary Design (render api)
Ton Roosendaal
ton at blender.org
Wed Jun 27 15:40:18 CEST 2007
Hi,
> What I'm currently thinking, actually, is that instead of a scene
> hierarchy, the scene traversal will happen using various get functions
> that return handlers or lists of handlers to datablocks. It seems to
> me that this is flexible and suited to the task of exporting. For
> example, one could use a single handler for each of objects, polygon
> meshes, nurbs, curves, and simply assign new data to the handler in
> loops. Also, comparing handlers might be a natural way to determine if
> two datablocks are instances of the same one.
One thing to be aware of; Objects are not a linear list in a Scene, but
instead more like a tree (an object can be a vertex-duplicator of
groups which has objects etc).
Such instancing (duplicators, groups) happen with single commands in
Blender now. You cannot get-next or get-prev this.
I would look starting with a call that makes a list of all
render-objects (instanciation, groups, duplicators). This is
blender-specific, and exporters then don't have to worry about our
weird features. Instancing information you can store at this stage too.
(Note; this only for objects, not render geometry)
> At any rate here is my WIP. I have prioritized the most basic
> functionality. All the void*s are so that multiple kinds of handlers
> can be returned from a single function. Also, it has a bit of a
> renderman slant, because that's the system I know the best.
The WIP is very very basic and premilinary. I would really like to see
more design, especially answering all questions related to Blender
itself.
> Also, keep in mind that I've written this from an exporter's point of
> view. The interface needs to be independent of the implementation.
Maybe, but the exporter is firstmost a Blender exporter, and this same
API should be used for the internal render too!
> // returns transformations from local coordinates to
> // whatever coordinates we are currently in
> void get_location( void *object, location[3], bool invert )
> void get_rotation( void *object, rotation[3], bool invert )
> void get_size( void *object, size[3], bool invert )
Why you think this works? Blender won't work this way.
You need to work exclusively with 4x4 matrix transforms.
> // returns a list of verticies, edges, faces
> void *get_verticies( void* geometry )
> void *get_edges( void* geometry )
> void *get_face( void* geometry )
This is also a bit strange un-blenderish...
Check how the code works. It might be much more efficient to follow
conventions for how we've designed derivedmesh for example.
-Ton-
>
>
> ===================
>
> Render API
>
> ===================
>
> ---------------
> Callbacks
> ---------------
>
> These will be placed in the appropriate places within
> render pipeline.
>
> // at beginning of whole render
> setup
>
> // for each frame
> render_frame
>
> // at end of render
> finish
>
> // when the render needs to be canceled for any reason
> abort
>
> ---------------
> API Functions
> ---------------
>
>
>
>>>> SETTINGS
>
> typedef enum COORDINATE_SYSTEM{
> LOCAL,
> GLOBAL,
> VIEW,
> SCREEN,
> RASTER
> } COORDINATE_SYSTEM;
>
> // get or set the current coordinate system from which
> // all transformations are measured.
> COORDINATE_SYSTEM get_coordinate_system()
> void set_coordinate_system( COORDINATE_SYSTEM new )
>
> int get_image_width()
> int get_image_height()
>
>>>> CAMERA
>
> typedef enum CAMERA_TYPE{
> PERSPECTIVE,
> ORTHAGONAL
> }
>
> CAMERA_TYPE get_camera_type()
> float get_lens()
> float get_clip_start()
> float get_clip_end()
>
>
>>>> ALL SCENE DATA
>
>
> // from is a pointer which specifies a
> // structure to perform this operation on. so
> // you don't have to perform the operation on the
> // whole scene hierarchy, you can instead perform
> // it on a small part.
> // from could be:
> // - the scene
> // - a group
> // - a list already retrieved
> // - a struct describing a bounding box in space
>
> // returns a list of all data which is instanced multiple times within
> from
> void *get_instanced_data( void *from )
>
> // returns a list of data that uses used data within from.
> // for example, if used was a material, you could return
> // all objects which use that material. This is useful if that
> // material has a lightgroup, for example.
> // If recursive, it travels up to the top of every data-chain,
> // else it only returns data that directly uses used.
> void *get_data_using( void *used, void *from, bool recursive )
>
> // for traversing lists, returns false when list ends
> // these allow further hiding of implementation details
> bool get_next( void *data )
> bool get_prev( void *data )
>
>
>
>>>> OBJECT
>
> // If invert is true, return the reverse transformation.
>
> // returns transformation matrix from local coordinates to
> // whatever coordinates we are currently in
> void get_transformation( void *object, transform[][4], bool invert )
>
> // returns transformations from local coordinates to
> // whatever coordinates we are currently in
> void get_location( void *object, location[3], bool invert )
> void get_rotation( void *object, rotation[3], bool invert )
> void get_size( void *object, size[3], bool invert )
>
> // returns the light or geometry data
> void *get_data( void *object )
>
>
>
>>>> LIGHTS
>
> // returns a list of all light objects within from
> void *get_lights( void *from )
>
>
> float get_intensity( void *light )
> float get_falloff_distance( void *light )
>
>
>
>>>> GEOMETRY
>
> // returns all geometry objects within from
> void *get_geometry( void *from )
>
> typedef enum GEOMETRY_TYPE{
> POLYGON_MESH,
> SUBDIVISION_SURFACE,
> NURB_SURFACE,
> METABALL,
> CURVE,
> PARTICAL_SYSTEM
> } GEOMETRY_TYPE;
>
> // returns a list of type geometry handlers within from
> void *get_geometry_by_type( GEOMETRY_TYPE type, void *from )
>
>
>
>>>> POLYGON MESH
>>>> SUBDIVISION SURFACE
>
> // returns a list of verticies, edges, faces
> void *get_verticies( void* geometry )
> void *get_edges( void* geometry )
> void *get_face( void* geometry )
>
> // returns the coordinates of the vertex
> void get_coordinates( void *vertex, float coordinates[3] )
> // data is either an edge or a face. indicies of verticies which
> define the edge or face.
> void *get_indices( void *data )
>
> int get_index( void *index )
>
>
> --- Aaron
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>
>
------------------------------------------------------------------------
--
Ton Roosendaal Blender Foundation ton at blender.org
http://www.blender.org
More information about the Bf-committers
mailing list