[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11383] branches/soc-2007-mosani/source/ blender/render: Added the preliminary aqsis work.

Aaron Moore two.a.ron at gmail.com
Fri Jul 27 05:59:23 CEST 2007


Revision: 11383
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11383
Author:   mosani
Date:     2007-07-27 05:59:22 +0200 (Fri, 27 Jul 2007)

Log Message:
-----------
Added the preliminary aqsis work. I haven't solved the 
coordinate system differences yet, but it produces RIB
files which, as long as you position everything correctly,
will produce an image.
(This is basically just putting back in the same code I
 had before reverting a bunch of stuff)

Modified Paths:
--------------
    branches/soc-2007-mosani/source/blender/render/intern/include/renderdatabase.h
    branches/soc-2007-mosani/source/blender/render/intern/source/rendercallbacks.c
    branches/soc-2007-mosani/source/blender/render/render_api/aqsis_plugin/aqsis.c
    branches/soc-2007-mosani/source/blender/render/render_api/include/RenderAPI.h
    branches/soc-2007-mosani/source/blender/render/render_api/source/RND_object.c

Added Paths:
-----------
    branches/soc-2007-mosani/source/blender/render/render_api/aqsis_plugin/aqsis_helpers.h

Modified: branches/soc-2007-mosani/source/blender/render/intern/include/renderdatabase.h
===================================================================
--- branches/soc-2007-mosani/source/blender/render/intern/include/renderdatabase.h	2007-07-27 02:06:15 UTC (rev 11382)
+++ branches/soc-2007-mosani/source/blender/render/intern/include/renderdatabase.h	2007-07-27 03:59:22 UTC (rev 11383)
@@ -69,6 +69,83 @@
 	char (*mcol)[32];
 } CustomDataNames;
 
+typedef struct RenderDatabase{
+	struct RenderDatabase *next, *prev;
+	
+	/* state settings */
+	short flag, osa, ok, do_gamma;
+	
+	/* window size, display rect, viewplane */
+	int winx, winy;
+	rcti disprect;			/* part within winx winy */
+	rctf viewplane;			/* mapped on winx winy */
+	float viewdx, viewdy;	/* size of 1 pixel */
+	float clipcrop;			/* 2 pixel boundary to prevent clip when filter used */
+	
+	/* final picture width and height (within disprect) */
+	int rectx, recty;
+	
+	/* real maximum amount of xparts/yparts after correction for minimum */
+	int xparts, yparts;
+	/* real maximum size of parts after correction for minimum 
+	   partx*xparts can be larger than rectx, in that case last part is smaller */
+	int partx, party;
+	
+	/* values for viewing */
+	float lens, ycor, viewfac;
+	float panophi, panosi, panoco, panodxp, panodxv;
+	
+	/* Matrices */
+	float grvec[3];			/* for world */
+	float imat[3][3];		/* copy of viewinv */
+	float viewmat[4][4], viewinv[4][4];
+	float winmat[4][4];
+	
+	/* clippping */
+	float clipsta;
+	float clipend;
+	
+	/* samples */
+	SampleTables *samples;
+	float jit[32][2];
+	
+	ListBase parts;
+	
+	/* octree tables and variables for raytrace */
+	Octree oc;
+	
+	/* use this instead of R.r.cfra */
+	float cfra;	
+	
+	/* render database */
+	int totvlak, totvert, tothalo, totlamp;
+	ListBase lights;	/* GroupObject pointers */
+	ListBase lampren;	/* storage, for free */
+	
+	int vertnodeslen;
+	struct VertTableNode *vertnodes;
+	int vlaknodeslen;
+	struct VlakTableNode *vlaknodes;
+	int blohalen;
+	struct HaloRen **bloha;
+	ListBase objecttable;
+	
+	struct Image *backbuf, *bakebuf;
+	
+	struct GHash *orco_hash;
+
+	struct GHash *sss_hash;
+	ListBase *sss_points;
+	struct Material *sss_mat;
+
+	ListBase customdata_names;
+
+	/* arena for allocating data for use during render, for
+	 * example dynamic TFaces to go in the VlakRen structure.
+	 */
+	struct MemArena *memArena;
+} RenderDatabase;
+
 /* renderdatabase.c */
 void free_renderdata_tables(struct Render *re);
 void free_renderdata_vertnodes(struct VertTableNode *vertnodes);

Modified: branches/soc-2007-mosani/source/blender/render/intern/source/rendercallbacks.c
===================================================================
--- branches/soc-2007-mosani/source/blender/render/intern/source/rendercallbacks.c	2007-07-27 02:06:15 UTC (rev 11382)
+++ branches/soc-2007-mosani/source/blender/render/intern/source/rendercallbacks.c	2007-07-27 03:59:22 UTC (rev 11383)
@@ -95,8 +95,13 @@
 #include "RenderAPI_internal.h"
 */
 
+/* internal */
+#include "render_types.h"
+#include "renderdatabase.h"
 #include "rendercallbacks.h"
 
+
+
 void blender_internal_setup( RNDScene scene )
 {
 	

Modified: branches/soc-2007-mosani/source/blender/render/render_api/aqsis_plugin/aqsis.c
===================================================================
--- branches/soc-2007-mosani/source/blender/render/render_api/aqsis_plugin/aqsis.c	2007-07-27 02:06:15 UTC (rev 11382)
+++ branches/soc-2007-mosani/source/blender/render/render_api/aqsis_plugin/aqsis.c	2007-07-27 03:59:22 UTC (rev 11383)
@@ -3,17 +3,75 @@
 
 #include <stdio.h>
 #include "plugin.h"
+#include "RenderAPI.h"
+#include "aqsis_helpers.h"
 
-static void setup( RNDScene scene ){}
+static void setup( RNDScene scene )
+{
+	FILE *aqsis_rib = fopen( "aqsis.rib", "w" );
+	fprintf( aqsis_rib, "# Generated by Aqsis Plugin - Aaron Moore\n\n" );
+	fprintf( aqsis_rib, "Display \"aqsis.jpg\" \"framebuffer\" \"rgb\"\n\n" );
+	fprintf( aqsis_rib, "Format 400 300 1\n" );
+	fprintf( aqsis_rib, "Projection \"perspective\" \"fov\" 35\n" );
+	fclose( aqsis_rib );
+}
 static void render_frame( RNDScene scene, RNDResult result )
 {
-	/* Aqsis RIB Export */
-	/* FILE *aqsis_rib = fopen( "aqsis.rib", "w" ); */
+	float light_coord[3];
+	RNDLight light;
+	
+	FILE *aqsis_rib = fopen( "aqsis.rib", "a" );
+	fprintf( aqsis_rib, "FrameBegin 1\n" );
+	fprintf( aqsis_rib, "WorldBegin\n\n" );
+	
+	/*
+	fprintf( aqsis_rib, "\t# translate world origin away from camera\n\n" );
+	
+	fprintf( aqsis_rib, "\tRotate -30 .3 0 0\n" );
+	fprintf( aqsis_rib, "\tRotate -45 0 1 0\n" );
+	fprintf( aqsis_rib, "\tTranslate 6 -5 6\n" );
+	*/
+	
+	/* Export Lights */
 	RNDObject object = RND_get_objects( scene, RND_LIGHT );
-	fprintf( stderr, "%s\n", object->current->holder->name );
-	/* fclose( aqsis_rib ); */
+	for( ; RND_object_exists( object ); RND_object_next( object ) )
+	{
+		if( RND_object_get_type( object ) == RND_LIGHT_POINT ){
+			fprintf( aqsis_rib, "\tLightSource \"pointlight\" 1 " );
+			RND_object_get_translation( object, light_coord );
+			fprintf( aqsis_rib, "\"from\" [%f %f %f] ",
+				light_coord[0],
+				light_coord[1],
+				light_coord[2] );
+			light = RND_object_get_light( object );
+			fprintf( aqsis_rib, "\"intensity\" %f\n", 
+				RND_light_get_intensity( light ) );
+		}
+	}
+	
+	/* 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 ){
+			fprintf( aqsis_rib, "\tAttributeBegin\n" );
+			fprintf( aqsis_rib, "\t\tSurface \"plastic\"\n" );
+			fprintf( aqsis_rib, "\t\tSides 2\n" );
+			transform_object( object, aqsis_rib );
+			export_polygons( object, aqsis_rib );
+			fprintf( aqsis_rib, "\tAttributeEnd\n" );
+		}
+	}
+	
+	fprintf( aqsis_rib, "WorldEnd\n" );
+	fprintf( aqsis_rib, "FrameEnd\n" );
+	fclose( aqsis_rib );
 }
-static void finish(){}
+static void finish()
+{
+	/* FILE *aqsis_rib = fopen( "aqsis.rib", "a" );
+	fclose( aqsis_rib ); */
+}
 static void abort_callback(){}
 
 plugin_instance_t* init( plugin_control_t *c ){ return NULL; }
@@ -21,14 +79,16 @@
 
 void plugin_query()
 {
-	RendererRegistration registration;
+	plugin_interface_render_output_t registration;
+	/* callbacks */
 	registration.setup = setup;
 	registration.render_frame = render_frame;
 	registration.finish = finish;
 	registration.abort = abort_callback;
+	/* axis */
 	registration.axis[0] = 'x';
-	registration.axis[1] = 'z';
-	registration.axis[2] = 'y';
+	registration.axis[1] = 'y';
+	registration.axis[2] = 'z';
 	
 	plugin_register_render_output(
 		"Aqsis Plugin",

Added: branches/soc-2007-mosani/source/blender/render/render_api/aqsis_plugin/aqsis_helpers.h
===================================================================
--- branches/soc-2007-mosani/source/blender/render/render_api/aqsis_plugin/aqsis_helpers.h	                        (rev 0)
+++ branches/soc-2007-mosani/source/blender/render/render_api/aqsis_plugin/aqsis_helpers.h	2007-07-27 03:59:22 UTC (rev 11383)
@@ -0,0 +1,60 @@
+
+void transform_object( RNDObject object, FILE *aqsis_rib )
+{
+	float transformation[4][4];
+	int i, j;
+	RND_object_get_transformation( object, transformation );
+	fprintf( aqsis_rib, "\t\tTransform [" );
+	
+	for( i = 0; i < 4; i++ ){
+		fprintf( aqsis_rib, "\n\t\t");
+		for( j = 0; j < 4; j++ )
+			fprintf( aqsis_rib, " %f", transformation[i][j] );
+	}
+	
+	fprintf( aqsis_rib, " ]\n" );
+}
+
+void export_polygons( RNDObject object, FILE *aqsis_rib )
+{
+	/* handlers */
+	RNDGeometry geometry = RND_object_get_geometry( object );
+	RNDVertex vertex = RND_geometry_get_vertices( geometry );
+	RNDFace face = RND_geometry_get_faces( geometry );
+	RNDIndex index;
+
+	/* counts */
+	float coordinates[3];
+	
+	fprintf( aqsis_rib, "\t\tPointsPolygons [" );
+	
+	/* export face counts */
+	for( ; RND_face_exists( face ); RND_face_next( face ) )
+	{
+		fprintf( aqsis_rib, " %d", RND_face_get_index_count( face ) );
+	}
+	fprintf( aqsis_rib, " ]\n" );
+	
+	/* export faces */
+	fprintf( aqsis_rib, "\t\t[" );
+	for( RND_face_first( face ); RND_face_exists( face ); RND_face_next( face ) )
+	{
+		index = RND_face_get_indices( face );
+		fprintf( aqsis_rib, "\n\t\t" );
+		for( ; RND_index_exists( index ); RND_index_next( index ) )
+			fprintf( aqsis_rib, " %d", RND_index_get_value( index ) );
+	}
+	fprintf( aqsis_rib, " ]\n" );
+	
+	/* export vertices */
+	fprintf( aqsis_rib, "\t\t \"P\" [" );
+	for( ; RND_vertex_exists( vertex ); RND_vertex_next( vertex ) )
+	{
+		RND_vertex_get_coordinates( vertex, coordinates );
+		fprintf( aqsis_rib, "\n\t\t%f %f %f",
+			coordinates[0],
+			coordinates[1],
+			coordinates[2] );
+	}
+	fprintf( aqsis_rib, " ]\n" );
+}

Modified: branches/soc-2007-mosani/source/blender/render/render_api/include/RenderAPI.h
===================================================================
--- branches/soc-2007-mosani/source/blender/render/render_api/include/RenderAPI.h	2007-07-27 02:06:15 UTC (rev 11382)
+++ branches/soc-2007-mosani/source/blender/render/render_api/include/RenderAPI.h	2007-07-27 03:59:22 UTC (rev 11383)
@@ -182,10 +182,10 @@
     of the x, y, and z components.
 */
 
-LIBEXPORT void RND_object_traslation( RNDObject object, float translation[] );
-LIBEXPORT void RND_object_rotation( RNDObject object, float rotation[] );
-LIBEXPORT void RND_object_scale( RNDObject object, float scale[] );
-LIBEXPORT void RND_object_shear( RNDObject object, float shear[] );
+LIBEXPORT void RND_object_get_translation( RNDObject object, float translation[] );
+LIBEXPORT void RND_object_get_rotation( RNDObject object, float rotation[] );
+LIBEXPORT void RND_object_get_scale( RNDObject object, float scale[] );
+LIBEXPORT void RND_object_get_shear( RNDObject object, float shear[] );
 
 /** Standard object functions */
 

Modified: branches/soc-2007-mosani/source/blender/render/render_api/source/RND_object.c
===================================================================
--- branches/soc-2007-mosani/source/blender/render/render_api/source/RND_object.c	2007-07-27 02:06:15 UTC (rev 11382)
+++ branches/soc-2007-mosani/source/blender/render/render_api/source/RND_object.c	2007-07-27 03:59:22 UTC (rev 11383)
@@ -111,15 +111,22 @@
 }
 
 LIBEXPORT void RND_object_get_transformation( RNDObject object, 
-	float transformation[][4] ){}
+	float transformation[][4] )
+{
+	Mat4CpyMat4( transformation, object->current->holder->transformation );
+}
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list