Generation of RIB files with C.
Generate RenderMan Bytestream Interface files with C.
Date Created:Sunday April 22nd, 2007 07:57 PM
Date Modified:Sunday August 03rd, 2008 12:28 PM
/*
* Author: Dan Lynch
*/
#include <stdio.h>
#include "render.h"
int main()
{
r_display("dan",0);
r_format(640, 480, 1);
r_shadrate(1);
r_translate(0,0,5);
r_rotate(-90,1,0,0);
r_scale(1,1,-1);
r_worldBegin();
r_reverse();
r_light(1,35,1,4,1,0,0,0);
r_attributeBegin();
//r_surface("d_surf");
//r_displace("d_rip",1);
//r_scaleAttr(4,4,1);
//r_plane();
//r_sphere();
r_translate(-2,0,0);
r_rotate(-90,1,0,0);
r_curve();
r_attributeEnd();
r_worldEnd();
return 0;
}
/*
*
* Header File
* Author: Dan Lynch
*
*/
void r_display(char* name,int type)
{
if (type == 0) printf("Display \"%s\" \"framebuffer\" \"rgb\"\n",name);
else if (type == 1) printf("Display \"%s.rib\" \"idisplay\" \"rgba\"\n",name);
else printf("Display \"%s.tiff\" \"tiff\" \"rgba\"\n",name);
}
void r_format(int w, int h, int a)
{
printf("Format %d %d %d\n",w,h,a);
printf("Projection \"perspective\" \"fov\" 40\n");
}
void r_shadrate(int n)
{
printf("ShadingRate %d\n", n);
}
void r_translate(int x, int y, int z)
{
printf("Translate %d %d %d\n",x,y,z);
}
void r_rotate(int deg, int x, int y, int z)
{
printf("Rotate %d %d %d %d\n",deg, x, y, z);
}
void r_scale(int x, int y, int z)
{
printf("Scale %d %d %d\n",x,y,z);
}
void r_worldBegin()
{
printf("WorldBegin\n");
}
void r_reverse()
{
printf("\tReverseOrientation\n");
}
void r_light(int type, int intensity, int x, int y, int z, int x2, int y2, int z2)
{
printf("\tLightSource \"pointlight\" 1 \"intensity\" %d \"from\" [%d %d %d]\n",intensity, x, y, z);
}
void r_attributeBegin()
{
printf("\tAttributeBegin\n");
}
void r_surface(char* name)
{
printf("\t\tSurface \"%s\"\n",name);
}
void r_displace(char* name, int bound)
{
printf("\t\tDisplacement \"%s\"\n",name);
printf("\t\tAttribute \"displacementbound\" \"float sphere\" [ %d ]\n",bound);
}
void r_scaleAttr(int x, int y, int z)
{
printf("\t\tScale %d %d %d\n",x,y,z);
}
void r_curve()
{
printf("\t\tAttribute \"identifier\" \"name\" [\"curve\"]\n");
printf("\t\tConcatTransform [1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1]");
printf("\t\tShadingInterpolation \"smooth\"\n");
printf("Basis \"b-spline\" 1 \"b-spline\" 1");
printf("Curves \"cubic\" [9] \"nonperiodic\" \"P\" [0 0 0 0 0 0 0 0 0 1 1 0 2 -1 0 3 1 0 4 -1 0 4 -1 0 4 -1 0] \"constantwidth\" [0.01]");
}
void r_readArchive(char* name)
{
printf("ReadArchive \"%s\"\n",name);
void r_sphere()
{
printf("\t\tSphere 0.5 -0.5 0.5 360\n");
}
void r_plane()
{
printf("\t\tPolygon \"P\" [-0.5 0 -1 0.5 0 -1 0.5 0 1 -0.5 0 1]");
printf("\n\t\t\"st\" [0 0 1 0 1 1 0 1]\n");
}
void r_attributeEnd()
{
printf("\tAttributeEnd\n");
}
void r_worldEnd()
{
printf("WorldEnd\n");
}
Downloads:
Download: createplane.c 528 B
Download: render.h 2 KB
Please login or Click Here to register for downloads
Create RIB Files by Dan Lynch
is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
Based on a work at www.3daet.com
Permissions beyond the scope of this license may be available at http://www.3daet.com
