首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
讲解CPSC 4050编程、辅导C++语言程序、C++留学生编程调试 讲解留学生Processing|解析C/C++编程
项目预算:
开发周期:
发布时间:
要求地区:
CPSC 4050/6050 Spring 2021
Project 1
due date: February 26 upload to handin
Summary
For this project you will write, compile, and execute C++ code to raytrace a
simple 3D scene and write the image to a simple ascii image file. The output
image will be in ppm format. You will put all of the code and the output image
in a folder, zip it into a single zip file, and upload it to . Your submission will be
compiled and executed on School of Computing linux computers. Compilation
will be accomplished via make. It is very much in your interest to make sure
your code compiles and runs in that computing environment.
1 Description for All Students
As we discussed in class, ray tracing a simple scene requires the following elements:
• A camera
• An Image Plane (a collection of pixels in a rectangular arrangement)
• A Ray (for each pixel of the image plane)
• One or more 3D objects (plane and sphere), with material properties (e.g.
color)
• A Scene, which is a container of 3D objects, such as planes and spheres.
• A raytracing function
CPSC 6050 students will also need:
• One or more lights
To create your ray tracer, you must create a separate C++ class for each of
the following concepts:
1
Class Class Data Class Methods
Camera
• position
• view direction
• up direction
• field-of-view
• aspect ratio
Vector view(float x, float y) const;
ImagePlane
• Nx, N y
• Color* data
• Color get(int i, int j) const;
• void set(int i, int j, const Color& C );
Ray
• position
• direction
• const Vector& get position() const;
• const Vector get direction() const;
Sphere
• position
• radius
• float intersection(const Ray& r) const;
• const Color get color() const;
Plane
• position
• normal direction
• float intersection(const Ray& r) const;
• const Color get color() const;
The ray tracing function is not a class:
Color Trace( const Ray& r, const Scene& s );
This function tests the intersections of the input Ray with each object in the
Scene container. If any of the objects are intersected by the ray, the Trace
function returns the color of the object with the closest intersection. If no
objects are intersected, it returns black.
A ray-trace renderer performs the following 4 steps for each pixel of the
image plane:
1. Call the camera’s view(x,y) method with the x,y for the given pixel,
returning the pixel direction vector.
2. Initialize a ray with the position of the camera and the pixel direction.
3. Call the Trace function, which returns a color following the outcome of
its intersection tests (as described above).
4. Set the color of the pixel to be the color returned by Trace.
You must write C++ code for each of the classes in the above table. The
classes may have more data and/or methods beyond what is listed in the table,
2
but those data and methods must be in the declaration and implementation of
each of the classes. You must create separate header and implementation files for
each class, i.e. you will have at least 5 header files and at least 5 implementation
files, with names Camera.h, Camera.cpp, ImagePlane.h, ImagePlane.cpp, etc.
You are free to use the header file Vector.h provided on the course webpage if
you wish. The file Vector.h has a sufficient implementation of a linear algebra
3D vector class, and a struct called Color. Note that the specification of classes
and methods here makes use of const and object references. Make sure you stick
to using those. Though you may not have used them in the past very much, it
is a very good habit to use them.
For the sphere and plane classes, the method float intersection(const
Ray& r) const computes the closest point of intersection of the object with
the ray. If there is no intersection, a negative value is returned. If there is an
intersection, the return value is the distance from the start of the ray to the
point of intersection.
The Scene object is a container that can hold planes and spheres in some
way that lets the Trace function get to each object to determine whether the
ray intersects that object, and if so, what color the object is. There are many
options for setting up such a container, all valid. You will have to select one.
You are free to create additional C++ classes, methods, etc. that have not
been explicitly called for here. In fact, you will probably need to. Using std
containters (e.g. vector, map, queue, etc.) is recommended whereever you see
the opportunity.
You will have to create a C++ implementation file called raytrace.cpp that
houses the main() function. You must also create a Makefile to compile and
link all of the code into an executable called raytrace.
When executed, raytrace will perform the ray trace render of the required
scene and write the data into an ascii ppm file. An example ppm file is provided
for you to examine. It can be viewed in any text editor to see its format, and
in any image viewer to see how its format translates into an image.
Description for 4050 Students
Using the ray tracer described above, the scene you must render consists of one
infinite plane and one sphere as follows:
• The plane has the point (0, 2, 0),the normal vector (0, 1, 0), and the color
(0, 0.5, 1).
• The sphere has the center (1, 2, 15), radius 3, and the color (0.5, 1, 0).
• The Camera has the position (0, 0, 0), view direction (0, 0, 1), up direction
(0, 1, 0), horizontal field of view 90 degrees (note that trigonometry
functions take radians as input), and aspect ratio 1.3333
• The image plane has 1024 pixels horizontally (Nx) and 768 pixels vertically
(Ny).
3
Description for 6050 Students
You will implement the ray tracing code as described above, with the addition
of a point light and lambertian shading at the intersections. One way to do this
is to modify the 3D objects to give them access to the light(s) and the shading
algorithm, so that the get color signature and algorithm can be modified to
perform the needed shading calculation.
The point light will be implemented as its own header file and implementation
file. The minimum content of the PointLight class is:
Class Class Data Class Methods
PointLight
• position
• color
• const Vector& get position() const;
• const Color get color() const;
Using the ray tracer described above, the scene you must render consists of
five infinite planes and one sphere as follows:
• The plane0 has the point (0, 2, 0),the normal vector (0, −1, 0), and the
color (1, 1, 1).
• The plane1 has the point (0, −2, 0),the normal vector (0, 1, 0), and the
color (1, 1, 1).
• The plane2 has the point (−2, 0, 0),the normal vector (1, 0, 0), and the
color (1, 0, 0).
• The plane3 has the point (2, 0, 0),the normal vector (−1, 0, 0), and the
color (0, 1, 0).
• The plane4 has the point (0, 0, 10),the normal vector (0, 0, −1), and the
color (1, 1, 1).
• The sphere has the center (1.1, 1.25, 7), radius 1, and the color (0.5, 0.5, 1).
• The Camera has the position (0, 0, 0), view direction (0, 0, 1), up direction
(0, 1, 0), horizontal field of view 90 degrees (note that trigonometry
functions take radians as input), and aspect ratio 1.3333
• The image plane has 1024 pixels horizontally (Nx) and 768 pixels vertically
(Ny).
• The point light is at position (−1, −1, 7) and has color (2, 2, 2).
All of the planes and sphere have Lambertian reflectivity.
4
Upload to handin
Create a folder called
. Put all of the following files into that folder.
There should be no subfolders.
Makefile
Vector.h
Camera.h
ImagePlane.h
Ray.h
Trace.h
Sphere.h
Plane.h
Camera.cpp
ImagePlane.cpp
Ray.cpp
Trace.cpp
Sphere.cpp
Plane.cpp
raytrace.cpp
output.ppm
(any other files you need to include)
If you are in 6050, you will also need to include:
PointLight.h
PointLight.cpp
Zip compress the folder into a single zip file, named
.zip. Upload
this file to the handin system. The course webpage has more guideance
and caveats if you need them.
5
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
urba6006代写、java/c++编程语...
2024-12-26
代做program、代写python编程语...
2024-12-26
代写dts207tc、sql编程语言代做
2024-12-25
cs209a代做、java程序设计代写
2024-12-25
cs305程序代做、代写python程序...
2024-12-25
代写csc1001、代做python设计程...
2024-12-24
代写practice test preparatio...
2024-12-24
代写bre2031 – environmental...
2024-12-24
代写ece5550: applied kalman ...
2024-12-24
代做conmgnt 7049 – measurem...
2024-12-24
代写ece3700j introduction to...
2024-12-24
代做adad9311 designing the e...
2024-12-24
代做comp5618 - applied cyber...
2024-12-24
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!