/* Copyright 2004, 2005 Nicholas Bishop * * This file is part of SharpConstruct. * * SharpConstruct 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. * * SharpConstruct 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 SharpConstruct; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "config.h" #include "Render.h" #ifdef HAVE_AQSIS_RI_H #include #include #endif void SharpConstruct::ExternalRender::Render( Mesh& m ) { #ifdef HAVE_AQSIS_RI_H // Temp c strings char* in = new char[ ImageName.length() ]; strcpy( in, ImageName.c_str() ); char* rn = new char[ RIBName.length() ]; strcpy( rn, RIBName.c_str() ); // This code is largely based on the RI2RIB tutorial on the Aqsis website RtFloat fov = 40; RtFloat light1_Int = 0.05; RtFloat light2_Int = 1.5; RtFloat light3_Int = 1; RtPoint light2_From = { 5, 5, 5 }; RtPoint light2_To = { 0, 0, 0 }; RtPoint light3_From = { 5, 5,-5 }; RtPoint light3_To = { 0, 0, 0 }; RtColor colorPlane = { 0.515, 0.509, 0.520 }; RiBegin( rn ); RiDisplay( in, "file", RI_RGBA, RI_NULL ); RiFormat( Width, Height, 1 ); RiProjection( RI_PERSPECTIVE, "fov", &fov, RI_NULL ); RiPixelSamples( 2, 2 ); RiTranslate( 0, 0, 4 ); RiRotate( 180, 1, 0, 0 ); RiRotate( 180, 0, 0, 1 ); RiWorldBegin(); // Lights RiLightSource( "ambientlight","intensity",&light1_Int,RI_NULL); RiLightSource( "distantlight","intensity",&light2_Int,"from",light2_From,"to",light2_To,RI_NULL); RiLightSource( "distantlight","intensity",&light3_Int,"from",light3_From,"to",light3_To,RI_NULL); //RiSurface( "metal", "uniform float thickness", (RtPointer)&shaderVar,RI_NULL ); RiTransformBegin(); RiColor( colorPlane ); //RiScale(4,4,4); //RiTranslate(-0.5,-0.5, 0); for( unsigned i = 0; i < m._triangles.size(); i += 3 ) { RtPoint planePoint[ 3 ] = { m._vertex_locations[ m._triangles[ i ].V[ 0 ] ].X(), m._vertex_locations[ m._triangles[ i ].V[ 0 ] ].Y(), m._vertex_locations[ m._triangles[ i ].V[ 0 ] ].Z(), m._vertex_locations[ m._triangles[ i ].V[ 1 ] ].X(), m._vertex_locations[ m._triangles[ i ].V[ 1 ] ].Y(), m._vertex_locations[ m._triangles[ i ].V[ 1 ] ].Z(), m._vertex_locations[ m._triangles[ i ].V[ 2 ] ].X(), m._vertex_locations[ m._triangles[ i ].V[ 2 ] ].Y(), m._vertex_locations[ m._triangles[ i ].V[ 2 ] ].Z() }; RiPolygon(3, RI_P,(RtPointer)planePoint, RI_NULL); } RiTransformEnd(); RiWorldEnd(); RiEnd(); std::string tmp = "aqsis " + RIBName; system( tmp.c_str() ); #endif }