[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11635] branches/soc-2007-mosani/source/ blender/render/render_api/plugins/aqsis/aqsis_plugin.c: Ok, I' ve finished the rewrite of the aqsis plugin.

Aaron Moore two.a.ron at gmail.com
Fri Aug 17 11:17:00 CEST 2007


Revision: 11635
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11635
Author:   mosani
Date:     2007-08-17 11:16:59 +0200 (Fri, 17 Aug 2007)

Log Message:
-----------
Ok, I've finished the rewrite of the aqsis plugin.
 It now uses the /usr/lib/libaqsis.so library to
 call aqsis directly. And it creates a nice framebuffer
 when you press the render button. However, there is no
 way to close this framebuffer without closing blender,
 I've found.
Since anyone who is testing this branch is compiling the
 plugin anyway, I figure they can change the display from
 "framebuffer" to "file" if they want to cancel this behavior.
 I just thought it would be nice to actually see an image 
 from aqsis in response to hitting the render button, even
 if it screws up your blender session right now.

Modified Paths:
--------------
    branches/soc-2007-mosani/source/blender/render/render_api/plugins/aqsis/aqsis_plugin.c

Modified: branches/soc-2007-mosani/source/blender/render/render_api/plugins/aqsis/aqsis_plugin.c
===================================================================
--- branches/soc-2007-mosani/source/blender/render/render_api/plugins/aqsis/aqsis_plugin.c	2007-08-17 07:15:07 UTC (rev 11634)
+++ branches/soc-2007-mosani/source/blender/render/render_api/plugins/aqsis/aqsis_plugin.c	2007-08-17 09:16:59 UTC (rev 11635)
@@ -4,6 +4,7 @@
 #include "PLU_api.h"
 #include "RenderAPI.h"
 #include "ri.h"
+#include "aqsis_plugin_helpers.h"
 
 PLU_IMPORT_API(register)
 RND_IMPORT_FULL_API
@@ -20,18 +21,73 @@
 
 */
 
+/* helper prototypes */
+static void export_polygons( RNDObject object );
+
 static void setup( RNDScene scene )
 {
-	RiDisplay( "file.jpg", "file", "rgb", RI_NULL );
+	RiBegin( "aqsis.rib" );
+	RiDisplay( "file.jpg", "framebuffer", "rgb", RI_NULL );
+	
 	RiFormat( 
 		RND_get_image_width( scene ),
 		RND_get_image_height( scene ), 1 );
+		
+	if( RND_is_perspective( scene ) ){
+		RtFloat fov = RND_get_lens( scene );
+		RiProjection( RI_PERSPECTIVE, "fov", &fov, RI_NULL );
+	}else
+		RiProjection( RI_ORTHOGRAPHIC, RI_NULL );
+	
+	RiScale( .2, .2, -.2 );
 }
 static void render_frame( RNDScene scene, RNDResult result )
 {
+	static int i = 0;
+	RtFloat light_point[3];
+	RtFloat intensity;
+	RtFloat transformation[4][4];
+	RNDLight light;
+	
+	RiFrameBegin( i );
+	RiWorldBegin();
+	
+	/* Export Lights */
+	RNDObject object = RND->get_objects( scene, RND_LIGHT );
+	for( ; RND_object->exists( object ); RND_object->next( object ) )
+	{
+		if( RND_object->get_type( object ) == RND_LIGHT_POINT )
+		{
+			RND_object->get_translation( object, light_point );
+			light = RND_object->get_light( object );
+			intensity = RND_light->get_intensity( light );
+			RiLightSource( "pointlight",
+				"from", light_point,
+				RI_NULL );
+		}
+	}
+	
+	/* Export Meshes */
+	object = RND->get_objects( scene, RND_GEOMETRY );
+	for( ; RND_object->exists( object ); RND_object->next( object ) )
+	{
+		if( RND_object->get_type( object ) == RND_GEOMETRY_POLYGON_MESH ){
+			RiAttributeBegin();
+			RiSurface("plastic", RI_NULL);
+			RND_object->get_transformation( object, transformation );
+			RiTransform( transformation );
+			export_polygons( object );
+			RiAttributeEnd();
+		}
+	}
+	
+	RiWorldEnd();
+	RiFrameEnd();
+	i++;
 }
 static void finish( RNDScene scene )
 {
+	RiEnd();
 }
 
 plugin_instance_t* init( plugin_control_t *c ){ return NULL; }
@@ -50,3 +106,58 @@
 		init, init, free_renderer,
 		setup, render_frame, finish );
 }
+
+/*****************************************************************************/
+/****************************  helper functions  *****************************/
+/*****************************************************************************/
+
+static void export_polygons( RNDObject object )
+{
+	RNDGeometry geometry = RND_object->get_geometry( object );
+	RNDVertex vertex = RND_geometry->get_vertices( geometry );
+	RNDFace face = RND_geometry->get_faces( geometry );
+	RNDIndex index;
+	int i, j, index_total = 0;
+	float coordinates[3];
+	
+	RtInt *nverts, *verts;
+	RtPoint *points;
+	
+	/* create index count arrays */
+	nverts = malloc( RND_face->get_count( face )*sizeof(RtInt) );
+	for( i = 0; RND_face->exists( face ); i++, RND_face->next( face ) )
+	{
+		nverts[i] = RND_face->get_index_count( face );
+		index_total += nverts[i];
+	}
+	
+	/* create index array */
+	verts = malloc( index_total*sizeof(RtInt) );
+	for( i = 0, RND_face->first( face ); 
+			RND_face->exists( face ); 
+			RND_face->next( face ) )
+	{
+		for( index = RND_face->get_indices( face ); 
+				RND_index->exists( index ); 
+				RND_index->next( index ), i++ )
+		{
+			verts[i] = RND_index->get_value( index );
+		}
+	}
+	
+	/* create vertex array */
+	points = malloc( RND_vertex->get_count( vertex )*sizeof(RtPoint) );
+	for( i = 0; RND_vertex->exists( vertex ); i++, RND_vertex->next( vertex ) )
+	{
+		RND_vertex->get_coordinates( vertex, points[i] );
+	}
+	
+	RiPointsPolygons( RND_face->get_count( face ), nverts, verts,
+		"P", points,
+		RI_NULL );
+	
+	/* free temporary arrays */
+	free( nverts );
+	free( verts );
+	free( points );
+}





More information about the Bf-blender-cvs mailing list