![]() Carlos Calzada Grau �@��²���G �p�����Ǭ�s�͡A�p����ϧΰg�C�Q�����ߩ� Linux �M�����o�i���ǤΤ@�� �P�L�n�L��������ƪ��C�P�p����L������L�R�n�O�ִ��M�i���C �ؿ��G |
�K�n�GAbstract
�o�O Renderman �t�C���ĤT�g�峹 ( Renderman I Renderman II ), �{�b�ڭ̱N�Q�׳̥D�n�����D�G�ϥΡ�C���Ρ�C++���y�� �إҫ��M���ͤ@�ӳ������i��ʡC
�q�e��g�峹���i�ܲM���a�ݥX�A�����q�L��J�@�Ӥ�r�ɮ� �y�z�@�ӳ����O�i��A���o�����ӳ�եF���C ��p�A�Ҽ{�g�@�ӡ�.rib�����Ӵy�z�@�Ӹ��D���y���B�ʡI ��e���@�ǡA�ڭ̥i�H�Ѽg�إ߳����ҫ��M�ʵe����C�y�����Ρ�C++�y���� ���ε{���A�çQ�ζǰe��.rib����зǿ�X���Τ�۩w�q�禡�C UNIX ���D���\�ڭ̪����ǰe�ͦ��� Renderman �R�O���L�{�� �]�prendrib�Arendribv�Argl�^�A �Ϊ̭��w�V�졧.rib�����C
�ڭ̥H�e�w�˪��Ť�G�ۦ�u��]Blue Moon Rendering Tools�^ �إߨ�ӦW�� lib �M include ���s�ؿ��A �]�t�|�Ӥ��A�ڭ̥u�A�Ψ�䤤����ӡGri.h ���Y�� (Include file) �M libribout.a �禡�w (Library) �C���Y�����ӫ����� /use/local/include �ؿ��A libribout.a ������ /use/local/lib �ؿ��]���g�窺Ū�̥i�H ��ܦw�˨��L��m�^�C�w�˧���A�ڭ̶}�l�dzƲĤ@�ӨҤl�{���C
�ڭ̪��Ĥ@�ӨҤl�t�ܤQ���� Renderman �s�{�C������ C �N�X�@�ˡA �ڭ̨ϥΨ禡�w���e�����]�t���������Y�ɡA�o�̴N�Ori.h�C ���~�A�ڭ̥����N�{���M�禡�w�o�˳s���G
gcc myprogram.c -o myprogram -lribout -lm
�U���O�@�ӱN�O�s�b����x�W��J���ɶ����Ҥl Makefile
LIBS = -lm -lribout PROGNAME = primero all: $(PROGNAME) $(PROGNAME).o: $(PROGNAME).c gcc -c $(PROGNAME).c $(PROGNAME): $(PROGNAME).o gcc -o $(PROGNAME) $(PROGNAME).o $(LIBS) |
�ڭ̪��Ĥ@�ӨҤl�N�b�����إߤ@�ǧ��жb�A�@�Ӳy��A���W�� primero.c�A�H�U�O���N�X�G
1 #include <stdio.h> 2 #include <math.h> 3 #include <ri.h> 4 5 void main(void) 6 { 7 int i; 8 int x,y,z; 9 int nf; 10 float slopex,slopey,slopez; 11 12 RtColor Rojo={1,0,0}; 13 RtColor Verde={0,1,0}; 14 RtColor Azul={0,0,1}; 15 RtColor Blanco={1,1,1}; 16 17 RtPoint p1={30,0,10}; /* Posicicion inicial de la pelota */ 18 RtPoint p2={0,20,10}; /* Posicion final de la pelota */ 19 20 RtPoint from={0,100,100}; /* Direccion de la luz */ 21 RtPoint to={0,0,0}; 22 23 char name[]="primero.tif"; 24 RtFloat fov=45; 25 RtFloat intensity1=0.1; 26 RtFloat intensity2=1.5; 27 RtInt init=0,end=1; 28 29 RiBegin(RI_NULL); 30 RiFormat(320,240,1); 31 RiPixelSamples(2,2); 32 RiShutter(0,1); 33 RiFrameBegin(1); 34 RiDisplay(name,"file","rgb",RI_NULL); 35 name[7]++; 36 RiProjection("perspective","fov",&fov,RI_NULL); 37 RiTranslate(0,-5,60); 38 RiRotate(-120,1,0,0); 39 RiRotate(25,0,0,1); 40 RiWorldBegin(); 41 RiLightSource("ambientlight","intensity",&intensity1,RI_NULL); 42 RiLightSource("distantlight","intensity",&intensity2,"from",from,"to",to,RI_NULL); 43 RiColor(Azul); 44 RiTransformBegin(); 45 RiCylinder(1,0,20,360,RI_NULL); 46 RiTranslate(0,0,20); 47 RiCone(2,2,360,RI_NULL); 48 RiTransformEnd(); 49 RiColor(Verde); 50 RiTransformBegin(); 51 RiRotate(-90,1,0,0); 52 RiCylinder(1,0,20,360,RI_NULL); 53 RiTranslate(0,0,20); 54 RiCone(2,2,360,RI_NULL); 55 RiTransformEnd(); 56 RiColor(Rojo); 57 RiTransformBegin(); 58 RiRotate(90,0,1,0); 59 RiCylinder(1,0,20,360,RI_NULL); 60 RiTranslate(0,0,20); 61 RiCone(2,2,360,RI_NULL); 62 RiTransformEnd(); 63 RiColor(Blanco); 64 RiSphere(5,-5,5,360,RI_NULL); 65 RiWorldEnd(); 66 RiFrameEnd(); 67 RiEnd(); 68 }; |
�e�T��O�����Y�ɡA�䤤ri.h�ORenderman�禡�w���Y�w�q�C �C�� Renderman �եΦb ri.h ������۹����� C �y���եΡA�Ҧp TransformBegin�ŦX��禡RiTransformBegin()�����C �� make �إߥi���檺primero�C�ڭ̪��Ҥl ����ɥi�H�q�L���w�V�]primero > primero.rib�^�� �����ǰe��X���L�{�ǡ]primero | rendrib�^�ӫإ߿�J���C �b��@�ر��p���Arendrib�t�d�ͦ��@�ӵۦ�᪺���primero.tif�C
�q�禡�w�̽եΪ��禡�����B��RiBegin(RI_NULL)�MRiEnd()�եΤ����C �ǻ���RiBegin���ѼƳq�`�ORI_NULL�C ���F����RIB��X��зǿ�X�A�ڭ̥i�H�ǻ���X���W * �]"myfile.rib"�^�A �Ʀܤ@�ӵ{�ǦW�]�prendrib�^�A��������N�ǰeRenderman�R�O���ۦ�� �ӵL���إߤ@�Ӥ���RIB���C
�ڭ̲Ĥ@�ӨҤl�����N�X�]�t�嫬��C���O�A�[�WRenderman���f�T���������M�禡�Q ����RtColor�O�t�T�ӹ�Ƴ������V�q�A���O�N������B���M�Ŧ� �]�S���0.0 ��1.0 �^�A����RtPoint�O�s�Ŷ���m�ARtFloat �MRtInt���O�O��ƩM��������C
��29��]�t�@�Ө�RiBegin(RI_NULL)���եΡA�����ڭ̥��e�y�z�� �ORenderman���f����l�ƽեΡC�q�o�̶}�l�b�q�`���R�O�禡��A ���ӿ�J�@�Ө嫬��RIB���C�յ۹B��N�X�A�}�N��X���w�V��@�Ӥ�� �]./primero > primero.rib�^�A��X���G���ӳo�ˡG
##RenderMan RIB-Structure 1.0 version 3.03 Format 320 240 1 PixelSamples 2 2 Shutter 0 1 FrameBegin 1 Display "camara.tif" "file" "rgb" Projection "perspective" "fov" [45 ] Translate 0 -5 60 Rotate -120 1 0 0 Rotate 25 0 0 1 WorldBegin LightSource "ambientlight" 1 "intensity" [0.1 ] LightSource "distantlight" 2 "intensity" [1.5 ] "from" [0 100 100] "to" [0 0 0] Color [0 0 1] TransformBegin Cylinder 1 0 20 360 Translate 0 0 20 Cone 2 2 360 TransformEnd Color [0 1 0] TransformBegin Rotate -90 1 0 0 Cylinder 1 0 20 360 Translate 0 0 20 Cone 2 2 360 TransformEnd Color [1 0 0] TransformBegin Rotate 90 0 1 0 Cylinder 1 0 20 360 Translate 0 0 20 Cone 2 2 360 TransformEnd Color [1 1 1] Sphere 5 -5 5 360 WorldEnd FrameEnd |
�ڭ̪��Ĥ@�ӨҤl�}���Q�����ΡC���F�ͦ��t�@�ӳ����A�ڭ̥����g�@�� �s���{���A�����������ާ@�C�禡�w���ʯ�u����{�b�ʵe���ͦ��W�C �Ĥ@�ӨҤl���u���@�T�e���ͦ��A���U�ӡA�ڭ̭n�ϲy�鲾�ʡC
�ĤG�ӨҤl���A�ڭ̪��������O�ѤT�ӧ��жb�M�@�Ӳy��զ��A ���y��N�ѧ��С]20�A0�A10�^���ʨ�]0�A20�A10�^�A�Y �q�p����̹����k�ݲ��ʨ쥪�ݡC��m�ϥ�RtPoint���c�w�q�]18�B19��^�C �ʵe���e���ιϹ����ƶq�w�q�b�ܶqnf���C �ϥγo�ӼơB��l�M�פ��m�A�i�H�p��X�C�ӵe���T�Ӥ�V�W���B�� �]slopex�Aslopey��slopez�^�C�o�ǴN�O���e�� �ƪ��禡�ӭק�y���m�һݪ��Ҧ��H���C�b��75��78�椧���A TransformBegin/TransformEnd�t�d�w�q�y�骺��m�C �C�@�B�s����m�N�b��76�椤�i��²��a�p��C
1 #include <stdio.h> 2 #include <math.h> 3 #include <ri.h> 4 #include "filename.h" 5 6 void main(void) 7 { 8 int i; 9 int x,y,z; 10 int nf; 11 float slopex,slopey,slopez; 12 13 RtColor Rojo={1,0,0}; 14 RtColor Verde={0,1,0}; 15 RtColor Azul={0,0,1}; 16 RtColor Blanco={1,1,1}; 17 18 RtPoint p1={30,0,10}; /* Posicicion inicial de la pelota */ 19 RtPoint p2={0,20,10}; /* Posicion final de la pelota */ 20 21 RtPoint from={0,100,100}; /* Direccion de la luz */ 22 RtPoint to={0,0,0}; 23 24 char base[]="camara_"; 25 char ext[]="tif"; 26 char name[50]; 27 RtFloat fov=45; 28 RtFloat intensity1=0.1; 29 RtFloat intensity2=1.5; 30 RtInt init=0,end=1; 31 32 nf=100; /* Numero de frames */ 33 slopex=(p2[0]-p1[0])/nf; 34 slopey=(p2[1]-p1[1])/nf; 35 slopez=(p2[2]-p1[2])/nf; 36 37 RiBegin(RI_NULL); 38 RiFormat(320,240,1); 39 RiPixelSamples(2,2); 40 RiShutter(0,1); 41 for (i=1;i <= nf;i++) 42 { 43 RiFrameBegin(i); 44 filename(base,ext,sizeof(base)+4,i-1,name); 45 RiDisplay(name,"file","rgb",RI_NULL); 46 name[7]++; 47 RiProjection("perspective","fov",&fov,RI_NULL); 48 RiTranslate(0,-5,60); 49 RiRotate(-120,1,0,0); 50 RiRotate(25,0,0,1); 51 RiWorldBegin(); 52 RiLightSource("ambientlight","intensity",&intensity1,RI_NULL); 53 RiLightSource("distantlight","intensity",&intensity2,"from",from,"to",to,RI_NULL); 54 RiColor(Azul); 55 RiTransformBegin(); 56 RiCylinder(1,0,20,360,RI_NULL); 57 RiTranslate(0,0,20); 58 RiCone(2,2,360,RI_NULL); 59 RiTransformEnd(); 60 RiColor(Verde); 61 RiTransformBegin(); 62 RiRotate(-90,1,0,0); 63 RiCylinder(1,0,20,360,RI_NULL); 64 RiTranslate(0,0,20); 65 RiCone(2,2,360,RI_NULL); 66 RiTransformEnd(); 67 RiColor(Rojo); 68 RiTransformBegin(); 69 RiRotate(90,0,1,0); 70 RiCylinder(1,0,20,360,RI_NULL); 71 RiTranslate(0,0,20); 72 RiCone(2,2,360,RI_NULL); 73 RiTransformEnd(); 74 RiColor(Blanco); 75 RiTransformBegin(); 76 RiTranslate(p1[0]+slopex*(i-1),p1[1]+slopey*(i-1),p1[2]+slopez*(i-1)); 77 RiSphere(5,-5,5,360,RI_NULL); 78 RiTransformEnd(); 79 RiWorldEnd(); 80 RiFrameEnd(); 81 } 82 RiEnd(); 83 }; |
���U�ӡA���ڭ̹��H�e�@�˸���ĤG�ӨҤl�G�sĶ�}����A�@���Ҥl ���w�V��X��rendribv�C�o�O�H�ڭ̥i�������t�v�ֳt �w���ڭ̪��ʵe���@��²����k�C���ˬdrib��X���A�ǰe�зǿ�X��@�ӷs���C �p�o�i�H�o�{�ͦ������O�Q���e�j�� (segundo.rib�e70kb) �A�o�O�]���P�@�ӳ����w�q�F100���]�C���e���@���^
�U�����Ϩҵ��X�F�@�ǰʵe�������e���G
���M�A�i�H�ϧڭ̧Ʊ檺����ƪ��ʰ_�ӡG���骺��m�A �j�p�A���j�סA�ṳ���A�Ϫ��驿������K�K
�b�̫�@�ӨҤl���A���ڭ̨Ӭݬݦp��ϲy��q�a�W�ϼu�_�ӡC �ڭ̭����w�q�禡rebote()�]�ϼu���N��^�A���T�ӰѼơG ���e�e�����ƶq�A�C���ϼu���e���ơA�y���F�쪺�̤j���סC �H�U�O���{�G
float rebote (int i, int nframes, int max) { float min, z; while (i > nframes) i-=nframes; min=sqrt(max); z=i-((float)nframes/2.0); z=(z*min)/((float)nframes/2.0); z=(float)max - (z*z); return(z); } |
�Q�Τ@��²�檺�p��A�i�H�M�g�嫬���ߪ����u(y=x^2)�� �e���ƩM�Ʊ檺�̤j���סC�U�����Ϩҵ��X�@�ǥѵ{���ͦ��� �C���ϼu�������Ϲ��C tercero.c:
�ڴ��Ѥ@�ǰʵeGIF���ӧζH��ܰʵe�L�{�A���M�L�̹B��w�C �]�ܤ֦bNetscape�U�O�o�ˡ^�A���q�Lxanim�A���ӯ�� ���`�a�ݨ�C
�x�νu�ʹB�ʡGsegundo_anim.gif
�ߪ��u�B�ʡG tercero_anim.gif
�o�˧ڭ�����Renderman��C�y�����f��¦���z�νs�{�i�@�q���C �̰��šB�̧��[���s�{�D�D�O���v(shaders)�C �����ѤF�����̲ۦ⪺�ڥ�����A�]�����\�ڭ̱���z�A�ө������C
½Ķ�GMiguel A Sepulveda
������LinuxFocus�s��պ��@
© Carlos Calzada Grau LinuxFocus 1999 |