📄 readme
字号:
C++ code augmenting the article"C++ Vector and Matrix Algebra Routines"by Jean-Francois Doue, h058@frhec1.hec.frin "Graphics Gems IV", Academic Press, 1994This directory contains a very basic ray-tracer, programmed todemonstrate the advantage of using a C++ vector and matrix librarycalled algebra3. The library makes programs easier to write and todebug.This document briefly discusses the class hierarchy of the program andthe format of the description files which must be passed to it. Anappendix lists all the files in this directory and describes thembriefly.CLASS HIERARCHY--------------- |---> Camera |Object3D ----> Primitive ----> Sphere | | | | | ----> Polyhedron ----> LightScene3DThe main program just creates a new Scene3D (a collection ofObject3Ds), parses it from a text description, and invokes theScene3D::rayTrace method. The Scene3D returns an array of 24 bitspixels. It is up to the reader change the code so as to save the imagein a format appropriate to his/her machine (the program can compute theimages, but does not display them).The ray-tracer is voluntarily very basic: it is only capable ofrendering spheres and concave polyhedrons, lit by point lights. It usesPhong's reflection model, but is not recursive, does not do shadows,light attenuation, textures, etc ... What should be of interest aboutthe program is the way it is written, not what it is capable of.FORMAT------3D scenes can be parsed from text representation. The textrepresentation is simply a list (in any order) of 3D objects (camera,sphere, polyhedron and light). The parsing method is very crude anddoes not check the accuracy of the description file thoroughly. Theexact syntax for each possible type of 3D objects is:Camera: ______________________________________________________________| | || text file | comments ||______________________________|_______________________________|| | || camera | - keyword; || | 0.0 0.5 4.0 | | - position of the camera; || | 1.0 0.0 0.0 0.0 | | - orientation of the camera; || | 0.0 1.0 0.0 0.0 | | || | 0.0 0.0 1.0 0.0 | | || | 0.0 0.0 0.0 1.0 | | || | 60.0 60.0 | | - field of view (in degrees); ||______________________________|_______________________________|Sphere: ______________________________________________________________| | || text file | comments ||______________________________|_______________________________|| | || sphere | - keyword; || | 0.0 0.5 4.0 | | - position of the sphere; || | 1.0 0.0 0.0 0.0 | | - orientation of the sphere; || | 0.0 1.0 0.0 0.0 | | || | 0.0 0.0 1.0 0.0 | | || | 0.0 0.0 0.0 1.0 | | || | 0.9 1.0 1.0 | | - color of the sphere; || | 0.1 0.48 0.7 20.0 | | - phong coefficients; || 2.0 | - radius; ||______________________________|_______________________________|Polyhedron: ______________________________________________________________| | || text file | comments ||______________________________|_______________________________|| | || polyhedron | - keyword; || | 0.0 0.5 4.0 | | - position of the polyhedron; || | 1.0 0.0 0.0 0.0 | | - orientation of the || | 0.0 1.0 0.0 0.0 | | polyhedron; || | 0.0 0.0 1.0 0.0 | | || | 0.0 0.0 0.0 1.0 | | || | 0.9 1.0 1.0 | | - color of the polyhedron; || | 0.1 0.48 0.7 20.0 | | - phong coefficients; || 10 | - number of vertices; || | -1.0 -1.0 -1.0 | | - first vertex; || | 1.0 -1.0 -1.0 | | - second vertex; || ....... | || | 0.0 1.8 1.0 | | - last vertex; || 7 | - number of facets; || 5 0 3 8 2 1 | - first facet (number of || | vertices followed by the || | index of each vertex in the || | facet); || 5 4 5 6 9 7 | - second facet; || ....... | || 4 0 4 7 3 | - last facet; ||______________________________|_______________________________|Light: ______________________________________________________________| | || text file | comments ||______________________________|_______________________________|| | || light | - keyword; || | 0.0 0.5 4.0 | | - position of the light; || | 1.0 0.0 0.0 0.0 | | - orientation of the light; || | 0.0 1.0 0.0 0.0 | | || | 0.0 0.0 1.0 0.0 | | || | 0.0 0.0 0.0 1.0 | | || | 0.9 1.0 1.0 | | - color of the light; ||______________________________|_______________________________|Comment lines (starting with the '%' sign) can be inserted in the text(between 3D objects only, not within the description of a 3D object!!!).APPENDIX--------Camera.c // Implementation of the camera classCamera.h // Interface of the camera classLight.c // Implementation of the point light classLight.h // Interface of the point light classMakefile // Unix makefileObject3D.c // Implementation of the 3D object classObject3D.h // Interface of the 3D object classPolyhedron.c // Implementation of the concave polyhedron classPolyhedron.h // Interface of the concave polyhedron classPrimitive.c // Implementation of the primitive classPrimitive.h // Interface of the primitive classREADME // This fileScene3D.c // Implementation of the 3D scene classScene3D.h // Interface of the 3D scene classSphere.c // Implementation of the sphere classSphere.h // Interface of the sphere classalgebra3.c // The vector and matrix libraryalgebra3.h // Include file of the vector and matrix librarymain.c // Main programexample.tiff // A sample picture rendered with the programexample.data // The script to render example.tiffsolver.c // Math utilities by Jochen Schwarze (see Graphics Gems 1 forsolver.h // more details)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -