[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11402] branches/soc-2007-mosani/source/ blender: Adding files for new render API convert code and pass/ result sending functions.
Aaron Moore
two.a.ron at gmail.com
Sat Jul 28 14:26:00 CEST 2007
Revision: 11402
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11402
Author: mosani
Date: 2007-07-28 14:26:00 +0200 (Sat, 28 Jul 2007)
Log Message:
-----------
Adding files for new render API convert code and pass/result sending functions.
Modified Paths:
--------------
branches/soc-2007-mosani/source/blender/blenpluginapi/PLU_types.h
branches/soc-2007-mosani/source/blender/render/intern/include/renderdatabase.h
branches/soc-2007-mosani/source/blender/render/intern/include/renderpipeline.h
branches/soc-2007-mosani/source/blender/render/intern/source/convertblender.c
branches/soc-2007-mosani/source/blender/render/intern/source/pipeline.c
branches/soc-2007-mosani/source/blender/render/intern/source/rendercallbacks.c
branches/soc-2007-mosani/source/blender/render/render_api/include/RND_types.h
branches/soc-2007-mosani/source/blender/render/render_api/include/RenderAPI.h
branches/soc-2007-mosani/source/blender/render/render_api/source/RND_context.c
branches/soc-2007-mosani/source/blender/render/render_api/source/RND_internal.c
branches/soc-2007-mosani/source/blender/render/render_api/source/RND_object.c
Added Paths:
-----------
branches/soc-2007-mosani/source/blender/render/intern/source/RND_converblender.c
branches/soc-2007-mosani/source/blender/render/render_api/source/RND_pass.c
Modified: branches/soc-2007-mosani/source/blender/blenpluginapi/PLU_types.h
===================================================================
--- branches/soc-2007-mosani/source/blender/blenpluginapi/PLU_types.h 2007-07-28 10:44:03 UTC (rev 11401)
+++ branches/soc-2007-mosani/source/blender/blenpluginapi/PLU_types.h 2007-07-28 12:26:00 UTC (rev 11402)
@@ -409,7 +409,6 @@
void (*setup)( RNDScene scene );
void (*render_frame)( RNDScene scene, RNDResult );
void (*finish)();
- void (*abort)();
char axis[3]; /* 0 = right, 1 = forward, 2 = up
ex. axis[0] = 'x', makes right
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-28 10:44:03 UTC (rev 11401)
+++ branches/soc-2007-mosani/source/blender/render/intern/include/renderdatabase.h 2007-07-28 12:26:00 UTC (rev 11402)
@@ -198,10 +198,12 @@
* from a Scene structure
*/
-RenderDatabase *database_from_scene( RNDScene scene );
-void database_free( RenderDatabase *database );
+void database_from_scene( RenderDatabase *db, RNDScene scene );
void database_add_lamp( RenderDatabase *database, RNDObject object );
+void database_insert_polygon_mesh( RenderDatabase *database, RNDObject object );
+struct VlakRen *findOrAddVlak( RenderDatabase *db, int nr );
+struct VertRen *findOrAddVert( RenderDatabase *db, int nr );
#endif /* RENDERDATABASE_H */
Modified: branches/soc-2007-mosani/source/blender/render/intern/include/renderpipeline.h
===================================================================
--- branches/soc-2007-mosani/source/blender/render/intern/include/renderpipeline.h 2007-07-28 10:44:03 UTC (rev 11401)
+++ branches/soc-2007-mosani/source/blender/render/intern/include/renderpipeline.h 2007-07-28 12:26:00 UTC (rev 11402)
@@ -44,7 +44,6 @@
void Setup( struct Render *re, struct Scene *scene );
void Render_Frame( struct Render *re );
void Finish( struct Render *re );
-void Abort( struct Render *re );
#define PASS_VECTOR_MAX 10000.0f
Added: branches/soc-2007-mosani/source/blender/render/intern/source/RND_converblender.c
===================================================================
--- branches/soc-2007-mosani/source/blender/render/intern/source/RND_converblender.c (rev 0)
+++ branches/soc-2007-mosani/source/blender/render/intern/source/RND_converblender.c 2007-07-28 12:26:00 UTC (rev 11402)
@@ -0,0 +1,384 @@
+/*
+ * RND_converblender.c
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2007 Blender Foundation
+ *
+ * Contributor(s): Aaron Moore (mosani)
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+/**
+ * @file RND_converblender.c
+ *
+ * The file uses the render api to fill the RenderDatabase
+ * structure from a blender scene.
+ */
+
+/*
+ * Includes
+ */
+
+/* Copied From convertblender.c
+ * it may be good to weed out the unnecessary
+ * includes from here at some point. */
+#include <math.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+
+#include "blendef.h"
+#include "MTC_matrixops.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_arithb.h"
+#include "BLI_blenlib.h"
+#include "BLI_rand.h"
+#include "BLI_memarena.h"
+#include "BLI_ghash.h"
+
+#include "DNA_armature_types.h"
+#include "DNA_camera_types.h"
+#include "DNA_material_types.h"
+#include "DNA_curve_types.h"
+#include "DNA_effect_types.h"
+#include "DNA_group_types.h"
+#include "DNA_lamp_types.h"
+#include "DNA_image_types.h"
+#include "DNA_lattice_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_meta_types.h"
+#include "DNA_object_types.h"
+#include "DNA_object_force.h"
+#include "DNA_object_fluidsim.h"
+#include "DNA_scene_types.h"
+#include "DNA_texture_types.h"
+#include "DNA_view3d_types.h"
+
+#include "BKE_anim.h"
+#include "BKE_armature.h"
+#include "BKE_action.h"
+#include "BKE_curve.h"
+#include "BKE_customdata.h"
+#include "BKE_constraint.h"
+#include "BKE_displist.h"
+#include "BKE_deform.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_effect.h"
+#include "BKE_global.h"
+#include "BKE_group.h"
+#include "BKE_key.h"
+#include "BKE_ipo.h"
+#include "BKE_image.h"
+#include "BKE_lattice.h"
+#include "BKE_library.h"
+#include "BKE_material.h"
+#include "BKE_main.h"
+#include "BKE_mball.h"
+#include "BKE_mesh.h"
+#include "BKE_node.h"
+#include "BKE_object.h"
+#include "BKE_scene.h"
+#include "BKE_subsurf.h"
+#include "BKE_texture.h"
+#include "BKE_utildefines.h"
+#include "BKE_world.h"
+
+#include "PIL_time.h"
+#include "IMB_imbuf_types.h"
+
+#include "envmap.h"
+#include "multires.h"
+#include "render_types.h"
+#include "rendercore.h"
+#include "renderdatabase.h"
+#include "renderpipeline.h"
+#include "radio.h"
+#include "shadbuf.h"
+#include "shading.h"
+#include "texture.h"
+#include "sss.h"
+#include "zbuf.h"
+
+#ifndef DISABLE_YAFRAY /* disable yafray */
+#include "YafRay_Api.h"
+#endif /* disable yafray */
+/* End Copied From convertblender.c */
+
+#include "renderdatabase.h"
+
+void database_from_scene( RenderDatabase *db, RNDScene scene )
+{
+ /* variables */
+ RNDObject object;
+
+ /* empty database */
+ memset( db, 0, sizeof(RenderDatabase) );
+ db->memArena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE);
+ db->totvlak = db->totvert = db->totlamp = db->tothalo = 0;
+ db->lights.first = db->lights.last = NULL;
+ db->lampren.first = db->lampren.last = NULL;
+
+ /* loop through all objects */
+ object = RND_get_objects( scene, RND_ALL );
+ for( ; RND_object_exists( object ); RND_object_next( object ) )
+ {
+ switch( RND_object_get_type(object) )
+ {
+ case RND_LIGHT:
+ database_add_lamp( db, object );
+ break;
+ case RND_GEOMETRY_POLYGON_MESH:
+ database_insert_polygon_mesh( db, object );
+ break;
+ default: break;
+ }
+ }
+}
+
+void database_add_lamp( RenderDatabase *database, RNDObject object )
+{
+ RNDLight light;
+ LampRen *render_lamp;
+ GroupObject *group_object;
+ float color[3];
+
+
+ /*----------------------------------------
+ Create Lamp Database Structures.
+ ----------------------------------------*/
+
+ render_lamp = MEM_callocN( sizeof(LampRen), "render lamp" );
+
+ /* groups is used to unify support for lightgroups,
+ * this is the global lightgroup,
+ * also,
+ * lamprens are in own list, for freeing */
+ group_object = MEM_callocN( sizeof(GroupObject), "group object" );
+ group_object->lampren = render_lamp;
+
+ BLI_addtail( &database->lights, group_object );
+ BLI_addtail( &database->lampren, render_lamp );
+
+
+ /*----------------------------------------
+ Fill Lamp Database Structures
+ ----------------------------------------*/
+
+ database->totlamp++;
+ light = RND_object_get_light( object );
+
+ /***** transformation information *****/
+ RND_object_get_translation( object, render_lamp->co );
+
+ /***** general light properties *****/
+ render_lamp->energy = RND_light_get_intensity( light );
+
+ render_lamp->dist = RND_light_get_falloff_distance( light );
+ render_lamp->distkw = render_lamp->dist * render_lamp->dist;
+
+ RND_light_get_color( light, color );
+ render_lamp->r = color[0] * render_lamp->energy;
+ render_lamp->g = color[1] * render_lamp->energy;
+ render_lamp->b = color[2] * render_lamp->energy;
+}
+
+void database_insert_polygon_mesh( RenderDatabase *database, RNDObject object )
+{
+ RNDGeometry geometry;
+ RNDVertex vertex;
+ RNDFace face;
+ RNDIndex index;
+ VertRen *render_vertex, **vertren_ptr;
+ VlakRen *render_face;
+ float object_matrix[4][4], normal_length;
+ int i, total_verticies, vertex_offset;
+
+ geometry = RND_object_get_geometry( object );
+ RND_object_get_transformation( object, object_matrix );
+
+ /**** Add Render Verticies ****/
+
+ vertex = RND_geometry_get_vertices( geometry );
+ for( ; RND_vertex_exists( vertex ); RND_vertex_next( vertex ) )
+ {
+ render_vertex = findOrAddVert( database, database->totvert++ );
+ RND_vertex_get_coordinates( vertex, render_vertex->co );
+ MTC_Mat4MulVecfl( object_matrix, render_vertex->co );
+ }
+
+ /*** Add Render Faces ****/
+
+ /* some necessary setup - calculate an offset to help
+ * in assigning VertRens to each VlakRen */
+ total_verticies = RND_vertex_get_count( vertex );
+ vertex_offset = database->totvert - total_verticies;
+
+ face = RND_geometry_get_faces( geometry );
+ for( ; RND_face_exists( face ); RND_face_next( face ) )
+ {
+ render_face = findOrAddVlak( database, database->totvert++ );
+
+ /* assign VertRens */
+ index = RND_face_get_indices( face );
+ for( i = 0; i < 4; i++, RND_index_next( index ) ){
+ switch(i){
+ case 0: vertren_ptr = &render_face->v1; break;
+ case 1: vertren_ptr = &render_face->v2; break;
+ case 2: vertren_ptr = &render_face->v3; break;
+ case 3: vertren_ptr = &render_face->v4; break;
+ }
+ if( RND_index_exists( index ) )
+ *vertren_ptr = findOrAddVert( database, vertex_offset+i );
+ else *vertren_ptr = 0;
+ }
+
+ /* calculate normals */
+ if( RND_face_get_index_count( face ) == 4 )
+ normal_length = CalcNormFloat4( render_face->v4->co,
+ render_face->v3->co,
+ render_face->v2->co,
+ render_face->v1->co,
+ render_face->n );
+ else
+ normal_length = CalcNormFloat( render_face->v3->co,
+ render_face->v2->co,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list