first commit
This commit is contained in:
123
CS4451/proj1/proj1.c
Normal file
123
CS4451/proj1/proj1.c
Normal file
@@ -0,0 +1,123 @@
|
||||
|
||||
/*
|
||||
put your name here, just in case ****
|
||||
Project 1: Ray Tracing
|
||||
CS4451A, Spring 2005
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <fstream.h>
|
||||
#include <iostream.h>
|
||||
#include <stdlib.h>
|
||||
#include <vector.h>
|
||||
#include "defs.h"
|
||||
#include "functions.h"
|
||||
|
||||
/* ------------- Main ------------ */
|
||||
|
||||
int main ( )
|
||||
{
|
||||
|
||||
/* First, get the necessary data */
|
||||
int m, n; // specify the output image size, assuming m x n
|
||||
Point e, l; // viewpoint e, lower left corner l
|
||||
Vector h, v; // vectors vertical and horizontal edges
|
||||
Light light; // Light source
|
||||
float ambience; // Ambient light intensity
|
||||
int numPrimitives; // Number of Primitives
|
||||
vector<Primitive> primitives;
|
||||
|
||||
|
||||
/* ------------ Scan Input ---------------- */
|
||||
|
||||
/* Begin scanning the input assuming 80 column lines */
|
||||
char* input = (char*)malloc(sizeof(char) * 81);
|
||||
char* pEnd;
|
||||
|
||||
//Get m and n
|
||||
cin.getline(input, 81);
|
||||
m = strtol(input, &pEnd, 10);
|
||||
n = strtol(pEnd,NULL,10);
|
||||
#ifdef bDebug
|
||||
printObject(m);
|
||||
printObject(n);
|
||||
#endif
|
||||
|
||||
//Get e
|
||||
scanInput(e,input);
|
||||
#ifdef bDebug
|
||||
printObject(e);
|
||||
#endif
|
||||
|
||||
//Get l
|
||||
scanInput(l,input);
|
||||
#ifdef bDebug
|
||||
printObject(l);
|
||||
#endif
|
||||
|
||||
//Get h
|
||||
scanInput(h,input);
|
||||
#ifdef bDebug
|
||||
printObject(h);
|
||||
#endif
|
||||
|
||||
//Get v
|
||||
scanInput(v,input);
|
||||
#ifdef bDebug
|
||||
printObject(v);
|
||||
#endif
|
||||
|
||||
//Get Light
|
||||
scanInput(light,input);
|
||||
#ifdef bDebug
|
||||
printObject(light);
|
||||
#endif
|
||||
|
||||
//Get ambient light level
|
||||
cin.getline(input,81);
|
||||
ambience = strtof(input, NULL);
|
||||
#ifdef bDebug
|
||||
printObject(ambience);
|
||||
#endif
|
||||
|
||||
//Get Primitive count
|
||||
cin.getline(input,81);
|
||||
numPrimitives = strtol(input,NULL,10);
|
||||
primitives.resize(numPrimitives);
|
||||
#ifdef bDebug
|
||||
printObject(numPrimitives);
|
||||
#endif
|
||||
|
||||
scanInput(primitives,numPrimitives, input);
|
||||
|
||||
/* ------------ Do the actual raytracing ---------------- */
|
||||
|
||||
|
||||
#if 0
|
||||
int x,y;
|
||||
|
||||
/* create a little example.... */
|
||||
|
||||
image img(256,256);
|
||||
for ( x=0; x<256; x++ ) {
|
||||
for ( y=0; y<256; y++ )
|
||||
{
|
||||
RGB &pix = img.pixel(x,y);
|
||||
|
||||
/* call your raytracer here, then assign the rgb values
|
||||
it returns to the pixel */
|
||||
|
||||
pix.r = x/255.0;
|
||||
pix.g = y/255.0;
|
||||
pix.b = (2-(x/255.0+y/255.0))/2;
|
||||
}
|
||||
}
|
||||
|
||||
/* dump the image to standard output */
|
||||
cout << img;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user