├── world
├── test.scn
├── .DS_Store
└── chunks
│ └── .DS_Store
├── input
├── debug.scn
├── dirt.png
├── sand.png
├── tree.png
├── .DS_Store
├── branch.png
├── checker.bmp
├── grass.png
├── halfgrass.png
├── obsidian.png
├── e14400terrain.png
├── distributed-left.off
├── distributed-right.off
├── box3.scn
├── distributed-box.off
├── distributed-ceilinglight.off
├── tetra.off
├── texture.scn
├── cone1.scn
├── cube.off
├── ico.scn
├── teapot.scn
├── tri.scn
├── cylinder1.scn
├── octa.off
├── sphere.scn
├── lines.scn
├── dirlight1.scn
├── pointlight1.scn
├── spotlight1.scn
├── box1.scn
├── dirlight2.scn
├── pointlight2.scn
├── ico.off
├── spotlight2.scn
├── hardshadow.scn
├── shininess.scn
├── diffuse.scn
├── specular.scn
├── cone2.scn
├── spotlight.scn
├── cylinder2.scn
├── fourspheres.scn
├── transmission.scn
├── refraction.scn
├── box2.scn
├── softshadow.scn
├── mixedprimitives1.scn
├── dodeca.off
├── sixtriangles.scn
├── lights.scn
├── stilllife.scn
├── distributed-slow.scn
├── distributed.scn
├── stack.scn
├── mixedprimitives3.scn
├── transform.scn
└── mixedprimitives2.scn
├── .DS_Store
├── src
├── .DS_Store
├── raypro.suo
├── minecraft.ilk
├── minecraft.pdb
├── minecraft.suo
├── jpeg
│ ├── libjpeg.lib
│ ├── makvms.opt
│ ├── jversion.h
│ ├── jconfig.h
│ ├── jconfig.vms
│ ├── jconfig.wat
│ ├── jconfig.dj
│ ├── jconfig.sas
│ ├── jconfig.cfg
│ ├── jconfig.mac
│ ├── jconfig.manx
│ ├── rdgif.c
│ ├── maktjpeg.st
│ ├── jconfig.st
│ ├── jconfig.vc
│ ├── jconfig.bcc
│ ├── ansi2knr.1
│ ├── jchuff.h
│ ├── rdjpgcom.1
│ ├── jconfig.mc6
│ ├── makcjpeg.st
│ ├── makdjpeg.st
│ ├── jcinit.c
│ ├── wrjpgcom.1
│ ├── jmemnobs.c
│ ├── jinclude.h
│ ├── jcomapi.c
│ └── makljpeg.st
├── GLUT.windows
│ ├── glut32.dll
│ ├── glut32.lib
│ └── glut.def
├── minecraft.vcxproj.user
├── R3
│ ├── R3Item.cpp
│ ├── R3Character.cpp
│ ├── R3Character.h
│ ├── R3Item.h
│ ├── R3Creature.h
│ ├── Makefile
│ ├── R3.h
│ ├── R3Block.h
│ ├── R3Sphere.h
│ ├── R3Cone.h
│ ├── R3Cylinder.h
│ ├── R3Ray.cpp
│ ├── R3Line.cpp
│ ├── R3Sphere.cpp
│ ├── R3Cone.cpp
│ ├── R3Cylinder.cpp
│ ├── R3Line.h
│ ├── R3Creature.cpp
│ ├── R3Block.cpp
│ ├── R3Plane.h
│ ├── R3Segment.h
│ ├── R3Ray.h
│ └── R3Plane.cpp
├── draw.h
├── R2
│ ├── Makefile
│ ├── R2Pixel.cpp
│ ├── R2.h
│ ├── R2Distance.h
│ ├── R2Distance.cpp
│ ├── R2Segment.cpp
│ ├── R2Line.h
│ ├── R2Line.cpp
│ ├── R2Point.h
│ └── R2Segment.h
├── ui.h
├── cos426_opengl.h
├── materials.h
├── raypro.sln
├── minecraft.sln
├── raytrace.h
├── utils.h
├── strings.h
├── Makefile
├── R3Scene.h
├── R3Chunk.h
├── utils.cpp
├── minecraft.h
└── raypro.cpp
├── sounds
└── ninth.wav
├── textures
├── cow.jpg
├── deer.jpg
├── dirt.jpg
├── gold.jpg
├── leaf.jpg
├── logo.jpg
├── sand.jpg
├── wood.jpg
├── .DS_Store
├── branch.jpg
├── grass.jpg
├── stone.jpg
├── alldirt.jpg
├── bedrock.jpg
├── default.jpg
├── dirt_icon.jpg
├── obsidian.jpg
├── sand_icon.jpg
├── suicide.jpg
├── wood_icon.jpg
├── stone_icon.jpg
└── obsidian_icon.jpg
├── screenshots
├── UI1.gif
├── UI2.gif
├── UI3.gif
├── both.gif
├── lod1.gif
├── lod2.gif
├── lod3.gif
├── logo.jpg
├── model1.gif
├── frustum.gif
├── billboard3.gif
├── collision3.gif
├── computer1.gif
├── computer2.gif
├── noculling.gif
├── occlusion.gif
├── 3Dperspective1.gif
├── 3Dperspective2.gif
└── 3Dperspective3.gif
└── README.txt
/world/test.scn:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/input/debug.scn:
--------------------------------------------------------------------------------
1 | include lines.scn
2 | include sphere.scn
--------------------------------------------------------------------------------
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/.DS_Store
--------------------------------------------------------------------------------
/input/dirt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/input/dirt.png
--------------------------------------------------------------------------------
/input/sand.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/input/sand.png
--------------------------------------------------------------------------------
/input/tree.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/input/tree.png
--------------------------------------------------------------------------------
/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/src/.DS_Store
--------------------------------------------------------------------------------
/src/raypro.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/src/raypro.suo
--------------------------------------------------------------------------------
/input/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/input/.DS_Store
--------------------------------------------------------------------------------
/input/branch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/input/branch.png
--------------------------------------------------------------------------------
/input/checker.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/input/checker.bmp
--------------------------------------------------------------------------------
/input/grass.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/input/grass.png
--------------------------------------------------------------------------------
/sounds/ninth.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/sounds/ninth.wav
--------------------------------------------------------------------------------
/src/minecraft.ilk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/src/minecraft.ilk
--------------------------------------------------------------------------------
/src/minecraft.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/src/minecraft.pdb
--------------------------------------------------------------------------------
/src/minecraft.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/src/minecraft.suo
--------------------------------------------------------------------------------
/textures/cow.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/cow.jpg
--------------------------------------------------------------------------------
/textures/deer.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/deer.jpg
--------------------------------------------------------------------------------
/textures/dirt.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/dirt.jpg
--------------------------------------------------------------------------------
/textures/gold.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/gold.jpg
--------------------------------------------------------------------------------
/textures/leaf.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/leaf.jpg
--------------------------------------------------------------------------------
/textures/logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/logo.jpg
--------------------------------------------------------------------------------
/textures/sand.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/sand.jpg
--------------------------------------------------------------------------------
/textures/wood.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/wood.jpg
--------------------------------------------------------------------------------
/world/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/world/.DS_Store
--------------------------------------------------------------------------------
/input/halfgrass.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/input/halfgrass.png
--------------------------------------------------------------------------------
/input/obsidian.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/input/obsidian.png
--------------------------------------------------------------------------------
/screenshots/UI1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/screenshots/UI1.gif
--------------------------------------------------------------------------------
/screenshots/UI2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/screenshots/UI2.gif
--------------------------------------------------------------------------------
/screenshots/UI3.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/screenshots/UI3.gif
--------------------------------------------------------------------------------
/textures/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/.DS_Store
--------------------------------------------------------------------------------
/textures/branch.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/branch.jpg
--------------------------------------------------------------------------------
/textures/grass.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/grass.jpg
--------------------------------------------------------------------------------
/textures/stone.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/stone.jpg
--------------------------------------------------------------------------------
/screenshots/both.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/screenshots/both.gif
--------------------------------------------------------------------------------
/screenshots/lod1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/screenshots/lod1.gif
--------------------------------------------------------------------------------
/screenshots/lod2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/screenshots/lod2.gif
--------------------------------------------------------------------------------
/screenshots/lod3.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/screenshots/lod3.gif
--------------------------------------------------------------------------------
/screenshots/logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/screenshots/logo.jpg
--------------------------------------------------------------------------------
/screenshots/model1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/screenshots/model1.gif
--------------------------------------------------------------------------------
/src/jpeg/libjpeg.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/src/jpeg/libjpeg.lib
--------------------------------------------------------------------------------
/textures/alldirt.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/alldirt.jpg
--------------------------------------------------------------------------------
/textures/bedrock.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/bedrock.jpg
--------------------------------------------------------------------------------
/textures/default.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/default.jpg
--------------------------------------------------------------------------------
/textures/dirt_icon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/dirt_icon.jpg
--------------------------------------------------------------------------------
/textures/obsidian.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/obsidian.jpg
--------------------------------------------------------------------------------
/textures/sand_icon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/sand_icon.jpg
--------------------------------------------------------------------------------
/textures/suicide.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/suicide.jpg
--------------------------------------------------------------------------------
/textures/wood_icon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/wood_icon.jpg
--------------------------------------------------------------------------------
/world/chunks/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/world/chunks/.DS_Store
--------------------------------------------------------------------------------
/input/e14400terrain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/input/e14400terrain.png
--------------------------------------------------------------------------------
/screenshots/frustum.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/screenshots/frustum.gif
--------------------------------------------------------------------------------
/textures/stone_icon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/stone_icon.jpg
--------------------------------------------------------------------------------
/screenshots/billboard3.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/screenshots/billboard3.gif
--------------------------------------------------------------------------------
/screenshots/collision3.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/screenshots/collision3.gif
--------------------------------------------------------------------------------
/screenshots/computer1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/screenshots/computer1.gif
--------------------------------------------------------------------------------
/screenshots/computer2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/screenshots/computer2.gif
--------------------------------------------------------------------------------
/screenshots/noculling.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/screenshots/noculling.gif
--------------------------------------------------------------------------------
/screenshots/occlusion.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/screenshots/occlusion.gif
--------------------------------------------------------------------------------
/src/GLUT.windows/glut32.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/src/GLUT.windows/glut32.dll
--------------------------------------------------------------------------------
/src/GLUT.windows/glut32.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/src/GLUT.windows/glut32.lib
--------------------------------------------------------------------------------
/textures/obsidian_icon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/textures/obsidian_icon.jpg
--------------------------------------------------------------------------------
/screenshots/3Dperspective1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/screenshots/3Dperspective1.gif
--------------------------------------------------------------------------------
/screenshots/3Dperspective2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/screenshots/3Dperspective2.gif
--------------------------------------------------------------------------------
/screenshots/3Dperspective3.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrupac/minecraft-opengl/HEAD/screenshots/3Dperspective3.gif
--------------------------------------------------------------------------------
/input/distributed-left.off:
--------------------------------------------------------------------------------
1 | OFF
2 | 8 1 0
3 | -4 4 4
4 | 4 4 4
5 | 4 0 4
6 | -4 0 4
7 | -4 4 -4
8 | 4 4 -4
9 | 4 0 -4
10 | -4 0 -4
11 | 4 4 7 3 0
12 |
--------------------------------------------------------------------------------
/input/distributed-right.off:
--------------------------------------------------------------------------------
1 | OFF
2 | 8 1 0
3 | -4 4 4
4 | 4 4 4
5 | 4 0 4
6 | -4 0 4
7 | -4 4 -4
8 | 4 4 -4
9 | 4 0 -4
10 | -4 0 -4
11 | 4 1 2 6 5
12 |
13 |
--------------------------------------------------------------------------------
/src/minecraft.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/input/box3.scn:
--------------------------------------------------------------------------------
1 | # Basic sample Minecraft scene
2 |
3 | material 0 0 0 0.5 0.5 0.5 0.5 0.5 0.5 0 0 0 0 0 0 10 1 test.jpg
4 |
5 | box 0 0 -1 0 water
6 | box 0 2 -1 0 grass
--------------------------------------------------------------------------------
/input/distributed-box.off:
--------------------------------------------------------------------------------
1 | OFF
2 | 8 3 0
3 | -4 4 4
4 | 4 4 4
5 | 4 0 4
6 | -4 0 4
7 | -4 4 -4
8 | 4 4 -4
9 | 4 0 -4
10 | -4 0 -4
11 | 4 1 5 4 0
12 | 4 5 6 7 4
13 | 4 6 2 3 7
14 |
--------------------------------------------------------------------------------
/input/distributed-ceilinglight.off:
--------------------------------------------------------------------------------
1 | OFF
2 | 8 1 0
3 | -2 3.995 2
4 | 2 3.995 2
5 | 2 3.99 2
6 | -2 3.99 2
7 | -2 3.995 -2
8 | 2 3.995 -2
9 | 2 3.99 -2
10 | -2 3.99 -2
11 | 4 1 5 4 0
12 |
--------------------------------------------------------------------------------
/input/tetra.off:
--------------------------------------------------------------------------------
1 | OFF
2 | 4 4 0
3 | 0.000 0.000 1.000
4 | 0.943 0.000 -0.333
5 | -0.471 0.816 -0.333
6 | -0.471 -0.816 -0.333
7 | 3 0 1 2
8 | 3 0 2 3
9 | 3 0 3 1
10 | 3 1 3 2
11 |
--------------------------------------------------------------------------------
/src/R3/R3Item.cpp:
--------------------------------------------------------------------------------
1 | #include "R3.h"
2 |
3 | R3Item::
4 | R3Item(void)
5 | {
6 | }
7 |
8 |
9 | R3Item::
10 | R3Item(R3ItemType itemtype)
11 | : itemtype(itemtype)
12 | {
13 | }
14 |
--------------------------------------------------------------------------------
/input/texture.scn:
--------------------------------------------------------------------------------
1 | # This scene has a textured sphere
2 |
3 | # A gray surface material with a checkerboard texture
4 | material 0 0 0 0.5 0.5 0.5 0.5 0.5 0.5 0 0 0 0 0 0 10 1 checker.bmp
5 |
6 | # A sphere
7 | sphere 0 0 0 0 1
8 |
--------------------------------------------------------------------------------
/src/jpeg/makvms.opt:
--------------------------------------------------------------------------------
1 | ! A pointer to the VAX/VMS C Run-Time Shareable Library.
2 | ! This file is needed by makefile.mms and makefile.vms,
3 | ! but only for the older VAX C compiler. DEC C does not need it.
4 | Sys$Library:VAXCRTL.EXE /Share
5 |
--------------------------------------------------------------------------------
/input/cone1.scn:
--------------------------------------------------------------------------------
1 | # This scene shows one cone
2 | # with default camera, materials, and lighting.
3 | # It is useful to test ray-cone intersection.
4 |
5 | # A cone with default material (-1) centered at (0,0,0) with radius 1 and height 1
6 | cone -1 0 0 0 1 1
7 |
--------------------------------------------------------------------------------
/input/cube.off:
--------------------------------------------------------------------------------
1 | OFF
2 | 8 6 0
3 | -0.5 -0.5 0.5
4 | 0.5 -0.5 0.5
5 | -0.5 0.5 0.5
6 | 0.5 0.5 0.5
7 | -0.5 0.5 -0.5
8 | 0.5 0.5 -0.5
9 | -0.5 -0.5 -0.5
10 | 0.5 -0.5 -0.5
11 | 4 0 1 3 2
12 | 4 2 3 5 4
13 | 4 4 5 7 6
14 | 4 6 7 1 0
15 | 4 1 7 5 3
16 | 4 6 0 2 4
17 |
--------------------------------------------------------------------------------
/input/ico.scn:
--------------------------------------------------------------------------------
1 | # This scene shows a close-up view of a icosahedron mesh
2 | # with default camera, materials, and lighting.
3 | # It is useful for testing ray-mesh intersection.
4 |
5 | # A mesh with default material (-1) read from ico.off
6 | mesh -1 ico.off
7 |
--------------------------------------------------------------------------------
/input/teapot.scn:
--------------------------------------------------------------------------------
1 | # This scene shows a close-up view of a teapot mesh
2 | # with default camera, materials, and lighting.
3 | # It is useful for testing ray-mesh intersection.
4 |
5 | # A mesh with default material (-1) read from teapot.off
6 | mesh -1 teapot.off
7 |
--------------------------------------------------------------------------------
/input/tri.scn:
--------------------------------------------------------------------------------
1 | # This scene shows a close-up view of one triangle.
2 | # It is useful for testing ray-triangle intersection.
3 |
4 | # A triangle with default material (-1) and
5 | # with corners (-1,-1,0), (1,-1,0), and (0,1,0)
6 | tri -1 -1 -1 0 1 -1 0 0 1 0
7 |
--------------------------------------------------------------------------------
/input/cylinder1.scn:
--------------------------------------------------------------------------------
1 | # This scene shows one cylinder from the side
2 | # with default camera, materials, and lighting.
3 | # It is useful to test ray-cylinder intersection.
4 |
5 | # A cylinder with default material (-1) centered at (0,0,0) with radius 1 and height 1
6 | cylinder -1 0 0 0 1 1
7 |
--------------------------------------------------------------------------------
/src/draw.h:
--------------------------------------------------------------------------------
1 | #ifndef __DRAW_H__
2 | #define __DRAW_H__
3 |
4 | #include "minecraft.h"
5 |
6 | void DrawSceneFullOptimization(R3Scene *scene);
7 |
8 | void DrawSceneViewFrustrumOnly(R3Scene *scene);
9 |
10 | void DrawSceneOcclusionOnly(R3Scene *scene);
11 |
12 | void DrawSceneNone(R3Scene *scene);
13 |
14 | #endif
15 |
--------------------------------------------------------------------------------
/input/octa.off:
--------------------------------------------------------------------------------
1 | OFF
2 | 6 8 0
3 | 1.000000 0.000000 0.000000
4 | 0.000000 1.000000 0.000000
5 | 0.000000 0.000000 1.000000
6 | -1.000000 0.000000 0.000000
7 | 0.000000 -1.000000 0.000000
8 | 0.000000 0.000000 -1.000000
9 | 3 1 2 0
10 | 3 0 5 1
11 | 3 0 2 4
12 | 3 3 2 1
13 | 3 4 5 0
14 | 3 1 5 3
15 | 3 4 2 3
16 | 3 3 5 4
17 |
18 |
--------------------------------------------------------------------------------
/input/sphere.scn:
--------------------------------------------------------------------------------
1 | # This scene shows one sphere
2 | # with default camera, materials, and lighting.
3 | # It is useful to test ray-sphere intersection.
4 |
5 | dir_light 1 1 1 -3 -4 -5
6 | dir_light 0.5 0.5 0.5 3 2 3
7 |
8 | # A sphere with default material (-1) centered at (0,0,0) with radius 1
9 | sphere -1 0 0 0 1
10 |
--------------------------------------------------------------------------------
/src/R3/R3Character.cpp:
--------------------------------------------------------------------------------
1 | #include "R3.h"
2 |
3 | R3Character::
4 | R3Character(void)
5 | {
6 | //TODO: FIX BACK
7 | Health = 1;
8 | MaxHealth = 8;
9 | velocity = R3Vector(0, 0, 0);
10 | position = R3Point(0, 0, 0);
11 | item = R3BLOCK_AIR;
12 | number_gold = 0;
13 |
14 | // Clear all items
15 | for (int i = 0; i < 8; i++)
16 | number_items[i] = 0;
17 | }
18 |
19 |
20 |
--------------------------------------------------------------------------------
/input/lines.scn:
--------------------------------------------------------------------------------
1 | line -1 -1 -1 -1 1 -1 -1
2 | line -1 -1 -1 -1 -1 1 -1
3 | line -1 -1 -1 -1 -1 -1 1
4 | line -1 1 1 1 -1 1 1
5 | line -1 1 1 1 1 -1 1
6 | line -1 1 1 1 1 1 -1
7 | line -1 1 -1 -1 1 1 -1
8 | line -1 1 -1 -1 1 -1 1
9 | line -1 -1 1 -1 1 1 -1
10 | line -1 -1 1 -1 -1 1 1
11 | line -1 -1 -1 1 1 -1 1
12 | line -1 -1 -1 1 -1 1 1
13 |
--------------------------------------------------------------------------------
/src/jpeg/jversion.h:
--------------------------------------------------------------------------------
1 | /*
2 | * jversion.h
3 | *
4 | * Copyright (C) 1991-1998, Thomas G. Lane.
5 | * This file is part of the Independent JPEG Group's software.
6 | * For conditions of distribution and use, see the accompanying README file.
7 | *
8 | * This file contains software version identification.
9 | */
10 |
11 |
12 | #define JVERSION "6b 27-Mar-1998"
13 |
14 | #define JCOPYRIGHT "Copyright (C) 1998, Thomas G. Lane"
15 |
--------------------------------------------------------------------------------
/src/R3/R3Character.h:
--------------------------------------------------------------------------------
1 | #ifndef __R3CHARACTER_H__
2 | #define __R3CHARACTER_H__
3 |
4 | class R3Character {
5 | public:
6 | R3Character(void);
7 |
8 | public:
9 | int Health;
10 | int MaxHealth;
11 | int item;
12 | R3Box helditem;
13 | R3Vector velocity;
14 | R3Point position;
15 | int number_items[8];
16 | R3ItemType belt[8];
17 | int number_gold;
18 |
19 | };
20 |
21 | #endif
22 |
--------------------------------------------------------------------------------
/src/R3/R3Item.h:
--------------------------------------------------------------------------------
1 | #ifndef __R3ITEM_H__
2 | #define __R3ITEM_H__
3 |
4 | typedef enum {
5 | R3BLOCK_DIRT,
6 | R3BLOCK_STONE,
7 | R3BLOCK_WOOD,
8 | R3BLOCK_SAND,
9 | R3BLOCK_OBSIDIAN,
10 | R3HATCHET,
11 | R3FOOD,
12 | R3BLOCK_AIR
13 | } R3ItemType;
14 |
15 |
16 | class R3Item {
17 | public:
18 | R3Item(void);
19 | R3Item(R3ItemType itemtype);
20 |
21 | public:
22 | R3ItemType itemtype;
23 | };
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/src/R2/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile for R2 library.
3 | #
4 |
5 | CXX=g++
6 | CXXFLAGS=-Wall -I. -g -DUSE_JPEG
7 |
8 | ifneq (,$(findstring Darwin,$(shell uname)))
9 | AR=libtool -static -o
10 | else
11 | AR=ar -rcs
12 | endif
13 |
14 | libR2.a: R2Image.o R2Distance.o R2Line.o R2Point.o R2Segment.o R2Vector.o
15 | rm -f $@
16 | $(AR) $@ $^
17 |
18 | R2Image.o R2Distance.o R2Line.o R2Point.o R2Segment.o R2Vector.o: R2.h
19 |
20 | clean:
21 | rm -f *.o libR2.a
22 |
23 |
--------------------------------------------------------------------------------
/input/dirlight1.scn:
--------------------------------------------------------------------------------
1 | # This scene has three dir lights
2 | # It is good for testing illuminaton with dir lights.
3 |
4 | # A camera
5 | camera 0 2 0 0 -1 0 0 0 1 0.25 0.01 100
6 |
7 | # One directional light
8 | dir_light 0 0 1 0.710 -.580 -0.410
9 |
10 | # A mostly diffuse material
11 | material 0 0 0 1 1 1 0.2 0.2 0.2 0.0 0.0 0.0 0.0 0.0 0.0 10 1 0
12 |
13 | # A sphere on a box
14 | sphere 0 0.0 0.2 0.0 0.2
15 | box 0 -2 -1 -2 2 0 2
16 |
17 |
18 |
--------------------------------------------------------------------------------
/input/pointlight1.scn:
--------------------------------------------------------------------------------
1 | # This scene has three point lights
2 | # It is good for testing illuminaton with point lights.
3 |
4 | # A camera
5 | camera 0 2 0 0 -1 0 0 0 1 0.25 0.01 100
6 |
7 | # One point light
8 | point_light 0 0 1 -0.866 1.0 0.5 0 0 1
9 |
10 | # A mostly diffuse material
11 | material 0 0 0 1 1 1 0.2 0.2 0.2 0.0 0.0 0.0 0.0 0.0 0.0 10 1 0
12 |
13 | # A sphere on a box
14 | sphere 0 0.0 0.2 0.0 0.2
15 | box 0 -2 -1 -2 2 0 2
16 |
17 |
18 |
--------------------------------------------------------------------------------
/input/spotlight1.scn:
--------------------------------------------------------------------------------
1 | # This scene has three spot lights
2 | # It is good for testing illuminaton with spot lights.
3 |
4 | # A camera
5 | camera 0 2 0 0 -1 0 0 0 1 0.25 0.01 100
6 |
7 | # One spot light
8 | spot_light 0 0 1 -0.866 1.0 0.5 0.710 -.580 -0.410 0 0 1 0.331 100
9 |
10 | # A mostly diffuse material
11 | material 0 0 0 1 1 1 0.2 0.2 0.2 0.0 0.0 0.0 0.0 0.0 0.0 10 1 0
12 |
13 | # A sphere on a box
14 | sphere 0 0.0 0.2 0.0 0.2
15 | box 0 -2 -1 -2 2 0 2
16 |
--------------------------------------------------------------------------------
/src/ui.h:
--------------------------------------------------------------------------------
1 | #ifndef __UI_H__
2 | #define __UI_H__
3 |
4 | #include "minecraft.h"
5 | #include "materials.h"
6 | #include "R3/R3.h"
7 | #include "utils.h"
8 |
9 | void DrawHUD(R3Character *mainCharacter, bool dead, int FPS);
10 |
11 | void DrawHUD_Hearts(R3Character *mainCharacter);
12 |
13 | void DrawHUD_Inventory(R3Character *mainCharacter);
14 |
15 | void DisplayStartMenu();
16 |
17 | void DisplayDeathMenu();
18 |
19 | void DisplayWonMenu();
20 |
21 | void DisplayControls();
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/src/jpeg/jconfig.h:
--------------------------------------------------------------------------------
1 | /* jconfig.h. Generated automatically by configure. */
2 | /* jconfig.cfg --- source file edited by configure script */
3 | /* see jconfig.doc for explanations */
4 |
5 | #define HAVE_PROTOTYPES
6 | #define HAVE_UNSIGNED_CHAR
7 | #define HAVE_UNSIGNED_SHORT
8 | #undef void
9 | #undef const
10 | #undef CHAR_IS_UNSIGNED
11 | #define HAVE_STDDEF_H
12 | #define HAVE_STDLIB_H
13 | #undef NEED_BSD_STRINGS
14 | #undef NEED_SYS_TYPES_H
15 | #undef NEED_FAR_POINTERS
16 | #undef NEED_SHORT_EXTERNAL_NAMES
17 | #undef INCOMPLETE_TYPES_BROKEN
18 |
19 |
--------------------------------------------------------------------------------
/input/box1.scn:
--------------------------------------------------------------------------------
1 | # Basic sample Minecraft scene
2 |
3 | box -1 0 -1 0 water
4 | box -1 0 -1 -2 water
5 | box -1 0 -1 -4 water
6 | box -1 0 -1 -6 water
7 | box -1 0 -1 -8 water
8 | box -1 0 -1 -10 water
9 | box -1 -2 -1 0 water
10 | box -1 -2 -1 -2 water
11 | box -1 -2 -1 -4 water
12 | box -1 -2 -1 -6 water
13 | box -1 -2 -1 -8 water
14 | box -1 -2 -1 -10 water
15 | box -1 2 -1 0 water
16 | box -1 2 -1 -2 water
17 | box -1 2 -1 -4 water
18 | box -1 2 -1 -6 water
19 | box -1 2 -1 -8 water
20 | box -1 2 -1 -10 water
21 |
--------------------------------------------------------------------------------
/input/dirlight2.scn:
--------------------------------------------------------------------------------
1 | # This scene has three dir lights
2 | # It is good for testing illuminaton with dir lights.
3 |
4 | # A camera
5 | camera 0 2 0 0 -1 0 0 0 1 0.25 0.01 100
6 |
7 | # Three directional lights
8 | dir_light 1 0 0 0.0 -.7071 0.7071
9 | dir_light 0 1 0 -0.710 -.580 -0.410
10 | dir_light 0 0 1 0.710 -.580 -0.410
11 |
12 | # A mostly diffuse material
13 | material 0 0 0 1 1 1 0.2 0.2 0.2 0.0 0.0 0.0 0.0 0.0 0.0 10 1 0
14 |
15 | # A sphere on a box
16 | sphere 0 0.0 0.2 0.0 0.2
17 | box 0 -2 -1 -2 2 0 2
18 |
19 |
20 |
--------------------------------------------------------------------------------
/input/pointlight2.scn:
--------------------------------------------------------------------------------
1 | # This scene has three point lights
2 | # It is good for testing illuminaton with point lights.
3 |
4 | # A camera
5 | camera 0 2 0 0 -1 0 0 0 1 0.25 0.01 100
6 |
7 | # Three point lights
8 | point_light 1 0 0 0.0 1.0 -1.0 0 0 1
9 | point_light 0 1 0 0.866 1.0 .5 0 0 1
10 | point_light 0 0 1 -0.866 1.0 0.5 0 0 1
11 |
12 | # A mostly diffuse material
13 | material 0 0 0 1 1 1 0.2 0.2 0.2 0.0 0.0 0.0 0.0 0.0 0.0 10 1 0
14 |
15 | # A sphere on a box
16 | sphere 0 0.0 0.2 0.0 0.2
17 | box 0 -2 -1 -2 2 0 2
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/cos426_opengl.h:
--------------------------------------------------------------------------------
1 | // Include the appropriate OpenGL and GLUT headers
2 |
3 | /* Windows */
4 | #if defined(_WIN32) || defined(__CYGWIN__)
5 | #ifndef USE_OPENGL32
6 | # define USE_OPENGL32
7 | #endif
8 |
9 | #ifndef NOMINMAX
10 | # define NOMINMAX
11 | # endif
12 |
13 | #include
14 | #include
15 |
16 | /* Mac OS */
17 | #elif defined(__APPLE__)
18 | #include
19 | #include
20 |
21 | /* Linux */
22 | #else
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #endif
29 |
30 |
--------------------------------------------------------------------------------
/src/R2/R2Pixel.cpp:
--------------------------------------------------------------------------------
1 | // Source file for the R2Pixel class
2 |
3 |
4 |
5 | // Include files
6 |
7 | #include "R2.h"
8 |
9 |
10 |
11 | // Public variables
12 |
13 | R2Pixel R2null_pixel(0.0, 0.0, 0.0, 1.0);
14 | R2Pixel R2black_pixel(0.0, 0.0, 0.0, 1.0);
15 | R2Pixel R2red_pixel(1.0, 0.0, 0.0, 1.0);
16 | R2Pixel R2green_pixel(0.0, 1.0, 0.0, 1.0);
17 | R2Pixel R2blue_pixel(0.0, 0.0, 1.0, 1.0);
18 | R2Pixel R2yellow_pixel(1.0, 1.0, 0.0, 1.0);
19 | R2Pixel R2cyan_pixel(0.0, 1.0, 1.0, 1.0);
20 | R2Pixel R2magenta_pixel(1.0, 0.0, 1.0, 1.0);
21 | R2Pixel R2white_pixel(1.0, 1.0, 1.0, 1.0);
22 |
23 |
--------------------------------------------------------------------------------
/src/materials.h:
--------------------------------------------------------------------------------
1 | #ifndef __MATERIALS_H__
2 | #define __MATERIALS_H__
3 |
4 | typedef enum
5 | {
6 | DEFAULT,
7 | DIRT,
8 | ALLDIRT,
9 | GRASS,
10 | LEAF,
11 | STONE,
12 | WOOD,
13 | SAND,
14 | BEDROCK,
15 | OBSIDIAN,
16 | GOLD,
17 | COW,
18 | DEER,
19 | SUICIDE,
20 | DIRT_ICON,
21 | STONE_ICON,
22 | WOOD_ICON,
23 | SAND_ICON,
24 | OBSIDIAN_ICON,
25 | LOGO
26 | } R3Texture;
27 |
28 | #include "strings.h"
29 | #include "R3Chunk.h"
30 |
31 | extern R3Material **materials;
32 |
33 | void MakeMaterials(R3Material **materials);
34 |
35 | void LoadMaterial(R3Material *material);
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/input/ico.off:
--------------------------------------------------------------------------------
1 | OFF
2 | 12 20 0
3 | 0 -0.5257311 0.8506508
4 | 0 0.5257311 0.8506508
5 | 0 -0.5257311 -0.8506508
6 | 0 0.5257311 -0.8506508
7 | 0.8506508 0 0.5257311
8 | 0.8506508 0 -0.5257311
9 | -0.8506508 0 0.5257311
10 | -0.8506508 0 -0.5257311
11 | 0.5257311 0.8506508 0
12 | 0.5257311 -0.8506508 0
13 | -0.5257311 0.8506508 0
14 | -0.5257311 -0.8506508 0
15 | 3 0 4 1
16 | 3 0 9 4
17 | 3 9 5 4
18 | 3 4 5 8
19 | 3 4 8 1
20 | 3 8 10 1
21 | 3 8 3 10
22 | 3 5 3 8
23 | 3 5 2 3
24 | 3 2 7 3
25 | 3 7 10 3
26 | 3 7 6 10
27 | 3 7 11 6
28 | 3 11 0 6
29 | 3 0 1 6
30 | 3 6 1 10
31 | 3 9 0 11
32 | 3 9 11 2
33 | 3 9 2 5
34 | 3 7 2 11
35 |
--------------------------------------------------------------------------------
/input/spotlight2.scn:
--------------------------------------------------------------------------------
1 | # This scene has three spot lights
2 | # It is good for testing illuminaton with spot lights.
3 |
4 | # A camera
5 | camera 0 2 0 0 -1 0 0 0 1 0.25 0.01 100
6 |
7 | # Three spot lights
8 | spot_light 1 0 0 0.0 1.0 -1.0 0.0 -.7071 0.7071 0 0 1 0.331 100
9 | spot_light 0 1 0 0.866 1.0 .5 -0.710 -.580 -0.410 0 0 1 0.331 100
10 | spot_light 0 0 1 -0.866 1.0 0.5 0.710 -.580 -0.410 0 0 1 0.331 100
11 |
12 | # A mostly diffuse material
13 | material 0 0 0 1 1 1 0.2 0.2 0.2 0.0 0.0 0.0 0.0 0.0 0.0 10 1 0
14 |
15 | # A sphere on a box
16 | sphere 0 0.0 0.2 0.0 0.2
17 | box 0 -2 -1 -2 2 0 2
18 |
--------------------------------------------------------------------------------
/README.txt:
--------------------------------------------------------------------------------
1 | INTRODUCTION
2 | ===========
3 |
4 | This is a tribute to Minecraft written in OpenGL and C++. As of right now,
5 | it is still very much a work in progress. Some optimizations are in place,
6 | but the performance may not be great on all machines. This has been actively
7 | developed on Linux but it should correctly work under Windows and Mac OS as
8 | well (except for audio at the moment..).
9 |
10 | COMPILATION
11 | ===========
12 |
13 | In Linux:
14 |
15 | $ cd src/
16 | $ make
17 |
18 | EXECUTION
19 | =========
20 |
21 | In Linux:
22 |
23 | $ src/minecraft path/to/world/data [default: world/test.scn]
24 |
25 |
--------------------------------------------------------------------------------
/input/hardshadow.scn:
--------------------------------------------------------------------------------
1 | # A camera
2 | camera -0.469 10.273 10.643 0.033 -0.701 -0.713 -0.012 0.713 -0.701 0.25 0.01 100
3 |
4 | # An point light source with color (1,1,1) at (0,3,0),
5 | # The last three numbers indicate no attenuation with distance.
6 | point_light 1 1 1 0 3 0 1.0 0.0 0.0
7 |
8 | # Three materials
9 | material 0 0 0 1 0 0 1 1 1 0 0 0 0 0 0 10 1 0
10 | material 0 0 0 0 1 0 1 1 1 0 0 0 0 0 0 10 1 0
11 | material 0 0 0 0.2 0.2 0.2 1 1 1 0 0 0 0 0 0 10 1 0
12 |
13 | # A triangle with material 0 with corners (-1,-1,0), (1,-1,0), and (0,1,0)
14 | sphere 0 -1 1 0 1
15 | sphere 1 1 1 0 1
16 | box 2 -4 -1 -4 4 0 4
17 |
--------------------------------------------------------------------------------
/input/shininess.scn:
--------------------------------------------------------------------------------
1 | # This is a scene that has four shiny spheres .
2 | # Each of the spheres has the same reflectance properties, except the shininess
3 | # It is useful for testing illumination and specular reflections.
4 |
5 | # Four materials for spheres with different shininess values
6 | material 0 0 0 1 0 0 1 1 1 0 0 0 0 0 0 1 1 0
7 | material 0 0 0 1 0 0 1 1 1 0 0 0 0 0 0 10 1 0
8 | material 0 0 0 1 0 0 1 1 1 0 0 0 0 0 0 100 1 0
9 | material 0 0 0 1 0 0 1 1 1 0 0 0 0 0 0 1000 1 0
10 |
11 | # Four spheres touching one another
12 | sphere 0 -1 -1 0 1
13 | sphere 1 -1 1 0 1
14 | sphere 2 1 -1 0 1
15 | sphere 3 1 1 0 1
16 |
--------------------------------------------------------------------------------
/input/diffuse.scn:
--------------------------------------------------------------------------------
1 | # This is a scene that has four diffuse spheres .
2 | # Each of the spheres has the same reflectance properties,
3 | # except the diffuse reflectance coefficients.
4 | # It is useful for testing illumination.
5 |
6 | # Four materials for spheres with different diffuse reflectance values
7 | material 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0
8 | material 0 0 0 0.5 0 0 0 0 0 0 0 0 0 0 0 0 1 0
9 | material 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0
10 | material 0 0 0 1 0.5 0.25 0 0 0 0 0 0 0 0 0 0 1 0
11 |
12 | # Four spheres touching one another
13 | sphere 0 -1 -1 0 1
14 | sphere 1 -1 1 0 1
15 | sphere 2 1 -1 0 1
16 | sphere 3 1 1 0 1
17 |
--------------------------------------------------------------------------------
/input/specular.scn:
--------------------------------------------------------------------------------
1 | # This is a scene that has two shiny spheres on top of a shiny box.
2 | # It is useful for testing specular reflections.
3 |
4 | # A camera
5 | camera 0.5 3 8 -0.053 -0.316 -0.947 0.003 0.949 -0.316 0.25 0.01 100
6 |
7 | # Two lights
8 | point_light 1 1 1 0.5 1 2 0 0 1
9 | dir_light 0.2 0.2 0.2 0 -1 0
10 |
11 | # Three shiny materials (red, green, gray)
12 | material 0 0 0 1 0 0 1 1 1 0 0 0 0 0 0 10 1 0
13 | material 0 0 0 0 1 0 1 1 1 0 0 0 0 0 0 10 1 0
14 | material 0 0 0 0.2 0.2 0.2 1 1 1 0 0 0 0 0 0 10 1 0
15 |
16 | # Two spheres touching one another on a box
17 | sphere 0 -1 1 0 1
18 | sphere 1 1 1 0 1
19 | box 2 -4 -1 -4 4 0 4
20 |
--------------------------------------------------------------------------------
/input/cone2.scn:
--------------------------------------------------------------------------------
1 | # This scene shows one cone
2 | # with default camera, materials, and lighting.
3 | # It is useful to test ray-cone intersection.
4 |
5 | # Camera looking at cone from corner angle
6 | # It's eye point is (-3.912 -1.232 1.004 ).
7 | # It's view direction (towards vector) is (0.941 0.213 -0.263).
8 | # It's up vector is (0.046 0.691 0.722).
9 | # The xfov is 0.25, while the yfov will be computed to match the aspect ratio of the image
10 | # The near and far distances are 0.01 and 1000, which conservatively contain the scene
11 | camera -3.912 -1.232 1.004 0.941 0.213 -0.263 0.046 0.691 0.722 0.25 0.01 1000
12 |
13 | # A cone
14 | # with default material (-1)
15 | # centered at (0,0,0)
16 | # with radius 1 and height 1
17 | cone -1 0 0 0 1 1
18 |
--------------------------------------------------------------------------------
/input/spotlight.scn:
--------------------------------------------------------------------------------
1 | # This scene has three spot lights
2 | # It is good for testing illuminaton with spot lights.
3 |
4 | # A camera
5 | camera 0 2 0 0 -1 0 0 0 1 0.25 0.01 100
6 |
7 | # Three spot lights
8 | spot_light 1.0 0.0 0.0 0.0 1.0 -1.0 0.0 -.7071 0.7071 1.0 0.0 0.0 0.331 100
9 | spot_light 0.0 1.0 0.0 0.866 1.0 .5 -0.710 -.580 -0.410 1.0 0.0 0.0 0.331 100
10 | spot_light 0.0 0.0 1.0 -0.866 1.0 0.5 0.710 -.580 -0.410 1.0 0.0 0.0 0.331 100
11 |
12 | # Two mostly diffuse materials
13 | material 0 0 0 1 1 1 0.2 0.2 0.2 0.0 0.0 0.0 0.0 0.0 0.0 10 1 0
14 | material 0 0 0 1 1 1 0.2 0.2 0.2 0.0 0.0 0.0 0.0 0.0 0.0 10 1 0
15 |
16 | # A sphere on a box
17 | sphere 0 0.0 0.155 0.0 .2
18 | box 0 -2 -1 -2 2 0 2
19 |
20 |
--------------------------------------------------------------------------------
/src/R3/R3Creature.h:
--------------------------------------------------------------------------------
1 | #ifndef __R3CREATURE_H__
2 | #define __R3CREATURE_H__
3 |
4 | #include "R3.h"
5 | #include "R3Character.h"
6 |
7 | typedef enum {
8 | R3COW_CREATURE,
9 | R3DEER_CREATURE,
10 | R3SUICIDE_CREATURE
11 | } R3CreatureType;
12 |
13 | class R3Creature
14 | {
15 | public:
16 | R3Creature(void);
17 | R3Creature(R3Point init, R3CreatureType creaturetype);
18 | R3Vector UpdateCreature(R3Character *character);
19 | void UpdateCreatureFall(R3Character *character);
20 | void Creature_Attack(R3Character *character, R3Vector translated);
21 |
22 | public:
23 | int Health;
24 | int MaxHealth;
25 | R3Point position;
26 | R3Box box;
27 | R3CreatureType creaturetype;
28 | };
29 |
30 | #endif
31 |
--------------------------------------------------------------------------------
/input/cylinder2.scn:
--------------------------------------------------------------------------------
1 | # This scene shows one cylinder from the side
2 | # with default camera, materials, and lighting.
3 | # It is useful to test ray-cylinder intersection.
4 |
5 | # Camera looking at cone from corner angle
6 | # It's eye point is (-4.772 -1.572 1.158).
7 | # It's view direction (towards vector) is (0.922 0.317 -0.223).
8 | # It's up vector is (-0.048 0.664 0.746).
9 | # The xfov is 0.25, while the yfov will be computed to match the aspect ratio of the image
10 | # The near and far distances are 0.01 and 1000, which conservatively contain the scene
11 | camera -4.772 -1.572 1.158 0.922 0.317 -0.223 -0.048 0.664 0.746 0.25 0.01 1000
12 |
13 | # A cylinder with default material (-1) centered at (0,0,0) with radius 1 and height 1
14 | cylinder -1 0 0 0 1 1
15 |
--------------------------------------------------------------------------------
/input/fourspheres.scn:
--------------------------------------------------------------------------------
1 | # This scene shows four colored spheres
2 | # It is useful for testing ray-scene intersections and materials
3 |
4 | # A camera
5 | camera 0 0 6 0 0 -1 0 1 0 0.25 0.01 100
6 |
7 | # Two directional lights
8 | dir_light 1 1 1 -3 -4 -5
9 | dir_light 0.5 0.5 0.5 3 2 3
10 |
11 | # Four shiny materials (red, green, blue, gray)
12 | material 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 10 1 0
13 | material 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 10 1 0
14 | material 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 10 1 0
15 | material 0 0 0 0.5 0.5 0.5 0.8 0.8 0.8 0 0 0 0 0 0 10 1 0
16 |
17 | # Four spheres touching one another
18 | sphere 0 -0.5 -0.5 0 0.5
19 | sphere 1 0.5 -0.5 0 0.5
20 | sphere 2 -0.5 0.5 0 0.5
21 | sphere 3 0.5 0.5 0 0.5
22 |
--------------------------------------------------------------------------------
/input/transmission.scn:
--------------------------------------------------------------------------------
1 | # This is a scene that has four transparent spheres in front of another
2 | # Each of the spheres has the same reflectance properties,
3 | # except the index of refraction.
4 |
5 | # Four materials for spheres with different shininess values
6 | material 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0
7 | material 0 0 0 0.2 0.2 0.2 0 0 0 0.8 0.8 0.8 0 0 0 0 1 0
8 | material 0 0 0 0.2 0.2 0.2 0 0 0 0.8 0.2 0.2 0 0 0 0 1 0
9 | material 0 0 0 0.2 0.2 0.2 0 0 0 0.2 0.2 0.8 0 0 0 0 1 0
10 | material 0 0 0 0.2 0.2 0.2 0 0 0 0.2 0.8 0.2 0 0 0 0 1 0
11 |
12 | # Four spheres touching one another
13 | sphere 0 0 0 -2 2
14 | sphere 1 -1 -1 0 1
15 | sphere 2 -1 1 0 1
16 | sphere 3 1 -1 0 1
17 | sphere 4 1 1 0 1
18 |
--------------------------------------------------------------------------------
/input/refraction.scn:
--------------------------------------------------------------------------------
1 | # This is a scene that has four transparent spheres in front of another
2 | # Each of the spheres has the same reflectance properties,
3 | # except the index of refraction.
4 |
5 | # Four materials for spheres with different shininess values
6 | material 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0
7 | material 0 0 0 0.2 0.2 0.2 0 0 0 0.8 0.8 0.8 0 0 0 0 1 0
8 | material 0 0 0 0.2 0.2 0.2 0 0 0 0.8 0.8 0.8 0 0 0 0 1.1 0
9 | material 0 0 0 0.2 0.2 0.2 0 0 0 0.8 0.8 0.8 0 0 0 0 1.2 0
10 | material 0 0 0 0.2 0.2 0.2 0 0 0 0.8 0.8 0.8 0 0 0 0 1.3 0
11 |
12 | # Four spheres touching one another
13 | sphere 0 0 0 -2 2
14 | sphere 1 -1 -1 0 1
15 | sphere 2 -1 1 0 1
16 | sphere 3 1 -1 0 1
17 | sphere 4 1 1 0 1
18 |
--------------------------------------------------------------------------------
/input/box2.scn:
--------------------------------------------------------------------------------
1 | # This scene shows a close-up view of one face of a box
2 | # with default camera, materials, and lighting.
3 | # It is useful for testing ray-box intersection.
4 |
5 | # Camera looking at box from corner angle
6 | # It's eye point is (-2.227 -6.085 1.989).
7 | # It's view direction (towards vector) is (0.343 0.892 -0.295).
8 | # It's up vector is (-0.262 0.392 0.882).
9 | # The xfov is 0.25, while the yfov will be computed to match the aspect ratio of the image
10 | # The near and far distances are 0.01 and 1000, which conservatively contain the scene
11 | camera -2.227 -6.085 1.989 0.343 0.892 -0.295 -0.262 0.392 0.882 0.25 0.01 1000
12 |
13 | # An axis-aligned box with default material (-1) and
14 | # with lower corner (-1,-1,-1) and upper corner (1,1,1)
15 | box -1 -1 -1 -1 1 1 1
16 |
--------------------------------------------------------------------------------
/input/softshadow.scn:
--------------------------------------------------------------------------------
1 | # This scene has an area light source.
2 | # It is good for testing soft shadows.
3 |
4 | # A camera
5 | camera -0.469 10.273 10.643 0.033 -0.701 -0.713 -0.012 0.713 -0.701 0.25 0.01 100
6 |
7 | # A circular area light source with color (1,1,1) centered at (0,3,0),
8 | # on the plane with normal (0,-1,0) and radius 0.5. The last three numbers
9 | # indicate no attenuation with distance.
10 | area_light 1 1 1 0 3 0 0 -1 0 0.5 1.0 0.0 0.0
11 |
12 | # Three materials
13 | material 0 0 0 1 0 0 1 1 1 0 0 0 0 0 0 10 1 0
14 | material 0 0 0 0 1 0 1 1 1 0 0 0 0 0 0 10 1 0
15 | material 0 0 0 0.2 0.2 0.2 1 1 1 0 0 0 0 0 0 10 1 0
16 |
17 | # A triangle with material 0 with corners (-1,-1,0), (1,-1,0), and (0,1,0)
18 | sphere 0 -1 1 0 1
19 | sphere 1 1 1 0 1
20 | box 2 -4 -1 -4 4 0 4
21 |
--------------------------------------------------------------------------------
/src/R3/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Linux makefile for assignment libR3.a
3 | #
4 |
5 |
6 |
7 | #
8 | # List of files
9 | #
10 |
11 | CCSRCS=R3Distance.cpp R3Matrix.cpp R3Mesh.cpp R3Sphere.cpp R3Cone.cpp R3Cylinder.cpp R3Box.cpp R3Plane.cpp R3Segment.cpp R3Ray.cpp R3Line.cpp R3Vector.cpp R3Point.cpp R3Block.cpp R3Item.cpp R3Character.cpp R3Creature.cpp
12 | OBJS=$(CCSRCS:.cpp=.o)
13 | INCS=$(HSRCS) $(CCSRCS:.cpp=.h)
14 |
15 |
16 |
17 | #
18 | # Options
19 | #
20 |
21 | CC=g++
22 | CPPFLAGS=-Wall -I. -I.. -g
23 | LDFLAGS=-g
24 |
25 |
26 |
27 | #
28 | # Output library name
29 | #
30 |
31 | LIB=./libR3.a
32 |
33 |
34 |
35 | #
36 | # Make targets
37 | #
38 |
39 | $(LIB): $(OBJS)
40 | - rm -f $(LIB)
41 | ar ur $(LIB) $(OBJS) $(USER_OBJS)
42 |
43 | clean:
44 | - rm -f *~ *.o *.obj *.pdb $(LIB)
45 |
46 |
--------------------------------------------------------------------------------
/input/mixedprimitives1.scn:
--------------------------------------------------------------------------------
1 | # This scene shows a mixture of primitives with different colors
2 | # It is useful for testing ray-scene intersections and materials
3 |
4 | # A camera
5 | camera 0 0 15 0 0 -1 0 1 0 0.25 0.01 100
6 |
7 | # Two directional lights
8 | dir_light 1 1 1 -3 -4 -5
9 | dir_light 0.5 0.5 0.5 3 2 3
10 |
11 | # Five shiny materials (yellow, cyan, magenta, red, green)
12 | material 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 10 1 0
13 | material 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 10 1 0
14 | material 0 0 0 1 0 1 1 0 1 0 0 0 0 0 0 10 1 0
15 | material 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 10 1 0
16 | material 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 10 1 0
17 |
18 | # Three primitives
19 | sphere 0 -2 -2 0 1
20 | box 1 1 1 -1 3 3 1
21 | mesh 2 ico.off
22 | sphere 3 -2 2 0 1
23 | box 4 1 -1 -1 3 -3 1
24 |
--------------------------------------------------------------------------------
/input/dodeca.off:
--------------------------------------------------------------------------------
1 | OFF
2 | 20 12 0
3 | 0.381966 0.000000 1.000000
4 | -0.381966 0.000000 1.000000
5 | 1.000000 0.381966 0.000000
6 | 1.000000 -0.381966 0.000000
7 | -1.000000 0.381966 0.000000
8 | -1.000000 -0.381966 0.000000
9 | 0.000000 1.000000 0.381966
10 | 0.000000 1.000000 -0.381966
11 | 0.000000 -1.000000 0.381966
12 | 0.000000 -1.000000 -0.381966
13 | 0.381966 0.000000 -1.000000
14 | -0.381966 0.000000 -1.000000
15 | 0.618034 0.618034 0.618034
16 | 0.618034 -0.618034 0.618034
17 | -0.618034 0.618034 0.618034
18 | -0.618034 -0.618034 0.618034
19 | 0.618034 0.618034 -0.618034
20 | 0.618034 -0.618034 -0.618034
21 | -0.618034 0.618034 -0.618034
22 | -0.618034 -0.618034 -0.618034
23 | 5 0 12 6 14 1
24 | 5 1 15 8 13 0
25 | 5 6 12 2 16 7
26 | 5 7 18 4 14 6
27 | 5 9 17 3 13 8
28 | 5 8 15 5 19 9
29 | 5 2 12 0 13 3
30 | 5 3 17 10 16 2
31 | 5 5 15 1 14 4
32 | 5 4 18 11 19 5
33 | 5 11 18 7 16 10
34 | 5 10 17 9 19 11
35 |
--------------------------------------------------------------------------------
/src/raypro.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "raypro", "raypro.vcxproj", "{97451871-161B-4C75-9EDE-C15518F67476}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Win32 = Debug|Win32
9 | Release|Win32 = Release|Win32
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {97451871-161B-4C75-9EDE-C15518F67476}.Debug|Win32.ActiveCfg = Debug|Win32
13 | {97451871-161B-4C75-9EDE-C15518F67476}.Debug|Win32.Build.0 = Debug|Win32
14 | {97451871-161B-4C75-9EDE-C15518F67476}.Release|Win32.ActiveCfg = Release|Win32
15 | {97451871-161B-4C75-9EDE-C15518F67476}.Release|Win32.Build.0 = Release|Win32
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/src/minecraft.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minecraft", "minecraft.vcxproj", "{97451871-161B-4C75-9EDE-C15518F67476}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Win32 = Debug|Win32
9 | Release|Win32 = Release|Win32
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {97451871-161B-4C75-9EDE-C15518F67476}.Debug|Win32.ActiveCfg = Debug|Win32
13 | {97451871-161B-4C75-9EDE-C15518F67476}.Debug|Win32.Build.0 = Debug|Win32
14 | {97451871-161B-4C75-9EDE-C15518F67476}.Release|Win32.ActiveCfg = Release|Win32
15 | {97451871-161B-4C75-9EDE-C15518F67476}.Release|Win32.Build.0 = Release|Win32
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/input/sixtriangles.scn:
--------------------------------------------------------------------------------
1 | # This scene shows six triangles
2 | # It is useful for testing ray-scene intersections and materials
3 |
4 | # A camera
5 | camera 0 0 6 0 0 -1 0 1 0 0.25 0.01 100
6 |
7 | # One point light
8 | point_light 1 1 1 0 0 0 0 0 1
9 |
10 | # Six shiny materials (red, green, blue, yellow, cyan, magenta)
11 | material 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 10 1 0
12 | material 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 10 1 0
13 | material 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 10 1 0
14 | material 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 10 1 0
15 | material 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 10 1 0
16 | material 0 0 0 1 0 1 1 0 1 0 0 0 0 0 0 10 1 0
17 |
18 | # Six triangles touching one another
19 | tri 0 0 0 -1 1 0 0 0.7 0.7 0
20 | tri 1 0 0 -1 0.7 0.7 0 -0.7 0.7 0
21 | tri 2 0 0 -1 -0.7 0.7 0 -1 0 0
22 | tri 3 0 0 -1 -1 0 0 -0.7 -0.7 0
23 | tri 4 0 0 -1 -0.7 -0.7 0 0.7 -0.7 0
24 | tri 5 0 0 -1 0.7 -0.7 0 1 0 0
25 |
--------------------------------------------------------------------------------
/src/R2/R2.h:
--------------------------------------------------------------------------------
1 | // Include files for R2 package
2 | #ifndef R2_INCLUDED
3 | #define R2_INCLUDED
4 |
5 |
6 | // Standard dependency include files
7 |
8 | #if defined(_MSC_VER)
9 | # pragma warning(disable:4996)
10 | #endif
11 | #ifdef _WIN32
12 | # define NOMINMAX
13 | # include
14 | #endif
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | using namespace std;
25 |
26 |
27 |
28 | // Class declarations
29 |
30 | class R2Point;
31 | class R2Vector;
32 | class R2Line;
33 | class R2Segment;
34 |
35 |
36 |
37 | // Geometry include files
38 |
39 | #include "R2Point.h"
40 | #include "R2Vector.h"
41 | #include "R2Line.h"
42 | #include "R2Segment.h"
43 |
44 | // Image include files
45 |
46 | #include "R2Pixel.h"
47 | #include "R2Image.h"
48 |
49 |
50 | // Utility include files
51 |
52 | #include "R2Distance.h"
53 |
54 |
55 |
56 | #endif
57 |
--------------------------------------------------------------------------------
/input/lights.scn:
--------------------------------------------------------------------------------
1 | # This scene shows has 8 spheres with the same material,
2 | # lit by three different lights. It is useful for testing
3 | # illumination code.
4 |
5 | # A camera
6 | camera 0 0 50 0 0 -1 0 1 0 0.25 0.01 100
7 |
8 | # A white (1,1,1) point light in the middle of the spheres (0,0,0)
9 | # with no attenuation with distance
10 | point_light 1 1 1 0 0 0 1 0 0
11 |
12 | # A bright red (10,0,0) point light to the right of the spheres (10,0,0)
13 | # with linear attenuation with distance
14 | point_light 10 0 0 10 0 0 0 1 0
15 |
16 | # A bright blue (0,0,100) spot light to the left of the spheres (-10,0,0)
17 | # pointing up and right (1,1,0) with quadradic attenuation with distance
18 | spot_light 0 0 100 -10 0 0 1 1 0 0 0 1 1.57 1
19 |
20 | # Material
21 | material 0 0 0 1 1 1 0.5 0.5 0.5 0 0 0 0 0 0 10 1 0
22 |
23 | # Spheres
24 | sphere 0 -5 -5 -5 1
25 | sphere 0 5 -5 -5 1
26 | sphere 0 -5 5 -5 1
27 | sphere 0 -5 -5 5 1
28 | sphere 0 5 5 -5 1
29 | sphere 0 -5 5 5 1
30 | sphere 0 5 -5 5 1
31 | sphere 0 5 5 5 1
32 |
--------------------------------------------------------------------------------
/src/jpeg/jconfig.vms:
--------------------------------------------------------------------------------
1 | /* jconfig.vms --- jconfig.h for use on Digital VMS. */
2 | /* see jconfig.doc for explanations */
3 |
4 | #define HAVE_PROTOTYPES
5 | #define HAVE_UNSIGNED_CHAR
6 | #define HAVE_UNSIGNED_SHORT
7 | /* #define void char */
8 | /* #define const */
9 | #undef CHAR_IS_UNSIGNED
10 | #define HAVE_STDDEF_H
11 | #define HAVE_STDLIB_H
12 | #undef NEED_BSD_STRINGS
13 | #undef NEED_SYS_TYPES_H
14 | #undef NEED_FAR_POINTERS
15 | #undef NEED_SHORT_EXTERNAL_NAMES
16 | #undef INCOMPLETE_TYPES_BROKEN
17 |
18 | #ifdef JPEG_INTERNALS
19 |
20 | #undef RIGHT_SHIFT_IS_UNSIGNED
21 |
22 | #endif /* JPEG_INTERNALS */
23 |
24 | #ifdef JPEG_CJPEG_DJPEG
25 |
26 | #define BMP_SUPPORTED /* BMP image file format */
27 | #define GIF_SUPPORTED /* GIF image file format */
28 | #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
29 | #undef RLE_SUPPORTED /* Utah RLE image file format */
30 | #define TARGA_SUPPORTED /* Targa image file format */
31 |
32 | #define TWO_FILE_COMMANDLINE /* Needed on VMS */
33 | #undef NEED_SIGNAL_CATCHER
34 | #undef DONT_USE_B_MODE
35 | #undef PROGRESS_REPORT /* optional */
36 |
37 | #endif /* JPEG_CJPEG_DJPEG */
38 |
--------------------------------------------------------------------------------
/src/raytrace.h:
--------------------------------------------------------------------------------
1 | // Include file for ray tracing code
2 |
3 | #include
4 | #include
5 | #include "R2/R2.h"
6 | #include "R3/R3.h"
7 |
8 | // Basic comparison macros
9 | #define MIN(a,b) ((a) <= (b) ? (a) : (b))
10 | #define MAX(a,b) ((a) > (b) ? (a) : (b))
11 |
12 | struct R3Intersection
13 | {
14 | bool hit;
15 | R3Node *node;
16 | R3Point position;
17 | R3Vector normal;
18 | double t;
19 | };
20 |
21 | R2Image *RenderImage(R3Scene *scene, int width, int height, int max_depth,
22 | int num_primary_rays_per_pixel, int num_distributed_rays_per_intersection);
23 |
24 | void RayCast(R3Scene *scene, R2Image *image, int width, int height);
25 |
26 | R3Intersection IntersectSphere(R3Ray ray, R3Sphere sphere);
27 |
28 | R3Intersection IntersectBox(R3Ray ray, R3Box box);
29 |
30 | R3Intersection IntersectMesh(R3Ray ray, R3Mesh mesh);
31 |
32 | R3Intersection IntersectCylinder(R3Ray ray, R3Cylinder cylinder);
33 |
34 | R3Intersection IntersectCone(R3Ray ray, R3Cone cone);
35 |
36 | R3Intersection IntersectScene(R3Ray ray, R3Scene *scene, R3Node *node);
37 |
38 | R3Rgb ComputeRadiance(R3Scene *scene, R3Ray ray, R3Intersection intersect, int depth);
39 |
40 |
--------------------------------------------------------------------------------
/src/jpeg/jconfig.wat:
--------------------------------------------------------------------------------
1 | /* jconfig.wat --- jconfig.h for Watcom C/C++ on MS-DOS or OS/2. */
2 | /* see jconfig.doc for explanations */
3 |
4 | #define HAVE_PROTOTYPES
5 | #define HAVE_UNSIGNED_CHAR
6 | #define HAVE_UNSIGNED_SHORT
7 | /* #define void char */
8 | /* #define const */
9 | #define CHAR_IS_UNSIGNED
10 | #define HAVE_STDDEF_H
11 | #define HAVE_STDLIB_H
12 | #undef NEED_BSD_STRINGS
13 | #undef NEED_SYS_TYPES_H
14 | #undef NEED_FAR_POINTERS /* Watcom uses flat 32-bit addressing */
15 | #undef NEED_SHORT_EXTERNAL_NAMES
16 | #undef INCOMPLETE_TYPES_BROKEN
17 |
18 | #ifdef JPEG_INTERNALS
19 |
20 | #undef RIGHT_SHIFT_IS_UNSIGNED
21 |
22 | #endif /* JPEG_INTERNALS */
23 |
24 | #ifdef JPEG_CJPEG_DJPEG
25 |
26 | #define BMP_SUPPORTED /* BMP image file format */
27 | #define GIF_SUPPORTED /* GIF image file format */
28 | #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
29 | #undef RLE_SUPPORTED /* Utah RLE image file format */
30 | #define TARGA_SUPPORTED /* Targa image file format */
31 |
32 | #undef TWO_FILE_COMMANDLINE /* optional */
33 | #define USE_SETMODE /* Needed to make one-file style work in Watcom */
34 | #undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */
35 | #undef DONT_USE_B_MODE
36 | #undef PROGRESS_REPORT /* optional */
37 |
38 | #endif /* JPEG_CJPEG_DJPEG */
39 |
--------------------------------------------------------------------------------
/src/utils.h:
--------------------------------------------------------------------------------
1 | #ifndef __UTILS_H__
2 | #define __UTILS_H__
3 |
4 | #include "cos426_opengl.h"
5 | #include "minecraft.h"
6 |
7 | #define M_2PI (2. * M_PI)
8 | #define RAD2DEG (180. / M_PI)
9 |
10 | // Fudge factor
11 | #define EPS 1e-4
12 |
13 | // Return square of x
14 | #define SQ(x) ((x) * (x))
15 | // Return sign of x, with 0 as even
16 | #define SIGN(x) ((x) >= 0 ? 1 : -1)
17 | // Return the absolute value of the given number
18 | #define ABS(x) ((x) * SIGN(x))
19 | // Clamp x to [low, high]
20 | #define CLAMP(x, low, high) MIN(MAX((x), (low)), (high))
21 | // Wrap x around so it's between [low, high]
22 | #define WRAP(x, low, high) (((x) > (high)) ? (x) - (high) : \
23 | ((x) < (low)) ? (x) - (low) : (x))
24 | // Proper rounding of a number
25 | #define ROUND(x) (((x) < 0) ? (int)((x) - .5) : (int)((x) + .5))
26 | // Debugging function to print any vector
27 | #define PRINT_VECTOR(x) printf("%lf %lf %lf\n", (x).X(), (x).Y(), (x).Z());
28 |
29 | extern int GLUTwindow;
30 | extern int GLUTwindow_height;
31 | extern int GLUTwindow_width;
32 | extern double GLUTaspect;
33 |
34 | double RandomNumber();
35 |
36 | double GetTime();
37 |
38 | void LoadMatrix(R3Matrix *matrix);
39 |
40 | void GLUTDrawText(const R3Point& p, const char *s);
41 |
42 | void GLUTDrawTitle(const R3Point& p, const char *s);
43 |
44 | #endif
45 |
--------------------------------------------------------------------------------
/src/jpeg/jconfig.dj:
--------------------------------------------------------------------------------
1 | /* jconfig.dj --- jconfig.h for DJGPP (Delorie's GNU C port) on MS-DOS. */
2 | /* see jconfig.doc for explanations */
3 |
4 | #define HAVE_PROTOTYPES
5 | #define HAVE_UNSIGNED_CHAR
6 | #define HAVE_UNSIGNED_SHORT
7 | /* #define void char */
8 | /* #define const */
9 | #undef CHAR_IS_UNSIGNED
10 | #define HAVE_STDDEF_H
11 | #define HAVE_STDLIB_H
12 | #undef NEED_BSD_STRINGS
13 | #undef NEED_SYS_TYPES_H
14 | #undef NEED_FAR_POINTERS /* DJGPP uses flat 32-bit addressing */
15 | #undef NEED_SHORT_EXTERNAL_NAMES
16 | #undef INCOMPLETE_TYPES_BROKEN
17 |
18 | #ifdef JPEG_INTERNALS
19 |
20 | #undef RIGHT_SHIFT_IS_UNSIGNED
21 |
22 | #endif /* JPEG_INTERNALS */
23 |
24 | #ifdef JPEG_CJPEG_DJPEG
25 |
26 | #define BMP_SUPPORTED /* BMP image file format */
27 | #define GIF_SUPPORTED /* GIF image file format */
28 | #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
29 | #undef RLE_SUPPORTED /* Utah RLE image file format */
30 | #define TARGA_SUPPORTED /* Targa image file format */
31 |
32 | #undef TWO_FILE_COMMANDLINE /* optional */
33 | #define USE_SETMODE /* Needed to make one-file style work in DJGPP */
34 | #undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */
35 | #undef DONT_USE_B_MODE
36 | #undef PROGRESS_REPORT /* optional */
37 |
38 | #endif /* JPEG_CJPEG_DJPEG */
39 |
--------------------------------------------------------------------------------
/src/jpeg/jconfig.sas:
--------------------------------------------------------------------------------
1 | /* jconfig.sas --- jconfig.h for Amiga systems using SAS C 6.0 and up. */
2 | /* see jconfig.doc for explanations */
3 |
4 | #define HAVE_PROTOTYPES
5 | #define HAVE_UNSIGNED_CHAR
6 | #define HAVE_UNSIGNED_SHORT
7 | /* #define void char */
8 | /* #define const */
9 | #undef CHAR_IS_UNSIGNED
10 | #define HAVE_STDDEF_H
11 | #define HAVE_STDLIB_H
12 | #undef NEED_BSD_STRINGS
13 | #undef NEED_SYS_TYPES_H
14 | #undef NEED_FAR_POINTERS
15 | #undef NEED_SHORT_EXTERNAL_NAMES
16 | #undef INCOMPLETE_TYPES_BROKEN
17 |
18 | #ifdef JPEG_INTERNALS
19 |
20 | #undef RIGHT_SHIFT_IS_UNSIGNED
21 |
22 | #define TEMP_DIRECTORY "JPEGTMP:" /* recommended setting for Amiga */
23 |
24 | #define NO_MKTEMP /* SAS C doesn't have mktemp() */
25 |
26 | #define SHORTxSHORT_32 /* produces better DCT code with SAS C */
27 |
28 | #endif /* JPEG_INTERNALS */
29 |
30 | #ifdef JPEG_CJPEG_DJPEG
31 |
32 | #define BMP_SUPPORTED /* BMP image file format */
33 | #define GIF_SUPPORTED /* GIF image file format */
34 | #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
35 | #undef RLE_SUPPORTED /* Utah RLE image file format */
36 | #define TARGA_SUPPORTED /* Targa image file format */
37 |
38 | #define TWO_FILE_COMMANDLINE
39 | #define NEED_SIGNAL_CATCHER
40 | #undef DONT_USE_B_MODE
41 | #undef PROGRESS_REPORT /* optional */
42 |
43 | #endif /* JPEG_CJPEG_DJPEG */
44 |
--------------------------------------------------------------------------------
/src/jpeg/jconfig.cfg:
--------------------------------------------------------------------------------
1 | /* jconfig.cfg --- source file edited by configure script */
2 | /* see jconfig.doc for explanations */
3 |
4 | #undef HAVE_PROTOTYPES
5 | #undef HAVE_UNSIGNED_CHAR
6 | #undef HAVE_UNSIGNED_SHORT
7 | #undef void
8 | #undef const
9 | #undef CHAR_IS_UNSIGNED
10 | #undef HAVE_STDDEF_H
11 | #undef HAVE_STDLIB_H
12 | #undef NEED_BSD_STRINGS
13 | #undef NEED_SYS_TYPES_H
14 | #undef NEED_FAR_POINTERS
15 | #undef NEED_SHORT_EXTERNAL_NAMES
16 | /* Define this if you get warnings about undefined structures. */
17 | #undef INCOMPLETE_TYPES_BROKEN
18 |
19 | #ifdef JPEG_INTERNALS
20 |
21 | #undef RIGHT_SHIFT_IS_UNSIGNED
22 | #undef INLINE
23 | /* These are for configuring the JPEG memory manager. */
24 | #undef DEFAULT_MAX_MEM
25 | #undef NO_MKTEMP
26 |
27 | #endif /* JPEG_INTERNALS */
28 |
29 | #ifdef JPEG_CJPEG_DJPEG
30 |
31 | #define BMP_SUPPORTED /* BMP image file format */
32 | #define GIF_SUPPORTED /* GIF image file format */
33 | #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
34 | #undef RLE_SUPPORTED /* Utah RLE image file format */
35 | #define TARGA_SUPPORTED /* Targa image file format */
36 |
37 | #undef TWO_FILE_COMMANDLINE
38 | #undef NEED_SIGNAL_CATCHER
39 | #undef DONT_USE_B_MODE
40 |
41 | /* Define this if you want percent-done progress reports from cjpeg/djpeg. */
42 | #undef PROGRESS_REPORT
43 |
44 | #endif /* JPEG_CJPEG_DJPEG */
45 |
--------------------------------------------------------------------------------
/src/jpeg/jconfig.mac:
--------------------------------------------------------------------------------
1 | /* jconfig.mac --- jconfig.h for CodeWarrior on Apple Macintosh */
2 | /* see jconfig.doc for explanations */
3 |
4 | #define HAVE_PROTOTYPES
5 | #define HAVE_UNSIGNED_CHAR
6 | #define HAVE_UNSIGNED_SHORT
7 | /* #define void char */
8 | /* #define const */
9 | #undef CHAR_IS_UNSIGNED
10 | #define HAVE_STDDEF_H
11 | #define HAVE_STDLIB_H
12 | #undef NEED_BSD_STRINGS
13 | #undef NEED_SYS_TYPES_H
14 | #undef NEED_FAR_POINTERS
15 | #undef NEED_SHORT_EXTERNAL_NAMES
16 | #undef INCOMPLETE_TYPES_BROKEN
17 |
18 | #ifdef JPEG_INTERNALS
19 |
20 | #undef RIGHT_SHIFT_IS_UNSIGNED
21 |
22 | #define USE_MAC_MEMMGR /* Define this if you use jmemmac.c */
23 |
24 | #define ALIGN_TYPE long /* Needed for 680x0 Macs */
25 |
26 | #endif /* JPEG_INTERNALS */
27 |
28 | #ifdef JPEG_CJPEG_DJPEG
29 |
30 | #define BMP_SUPPORTED /* BMP image file format */
31 | #define GIF_SUPPORTED /* GIF image file format */
32 | #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
33 | #undef RLE_SUPPORTED /* Utah RLE image file format */
34 | #define TARGA_SUPPORTED /* Targa image file format */
35 |
36 | #define USE_CCOMMAND /* Command line reader for Macintosh */
37 | #define TWO_FILE_COMMANDLINE /* Binary I/O thru stdin/stdout doesn't work */
38 |
39 | #undef NEED_SIGNAL_CATCHER
40 | #undef DONT_USE_B_MODE
41 | #undef PROGRESS_REPORT /* optional */
42 |
43 | #endif /* JPEG_CJPEG_DJPEG */
44 |
--------------------------------------------------------------------------------
/src/jpeg/jconfig.manx:
--------------------------------------------------------------------------------
1 | /* jconfig.manx --- jconfig.h for Amiga systems using Manx Aztec C ver 5.x. */
2 | /* see jconfig.doc for explanations */
3 |
4 | #define HAVE_PROTOTYPES
5 | #define HAVE_UNSIGNED_CHAR
6 | #define HAVE_UNSIGNED_SHORT
7 | /* #define void char */
8 | /* #define const */
9 | #undef CHAR_IS_UNSIGNED
10 | #define HAVE_STDDEF_H
11 | #define HAVE_STDLIB_H
12 | #undef NEED_BSD_STRINGS
13 | #undef NEED_SYS_TYPES_H
14 | #undef NEED_FAR_POINTERS
15 | #undef NEED_SHORT_EXTERNAL_NAMES
16 | #undef INCOMPLETE_TYPES_BROKEN
17 |
18 | #ifdef JPEG_INTERNALS
19 |
20 | #undef RIGHT_SHIFT_IS_UNSIGNED
21 |
22 | #define TEMP_DIRECTORY "JPEGTMP:" /* recommended setting for Amiga */
23 |
24 | #define SHORTxSHORT_32 /* produces better DCT code with Aztec C */
25 |
26 | #endif /* JPEG_INTERNALS */
27 |
28 | #ifdef JPEG_CJPEG_DJPEG
29 |
30 | #define BMP_SUPPORTED /* BMP image file format */
31 | #define GIF_SUPPORTED /* GIF image file format */
32 | #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
33 | #undef RLE_SUPPORTED /* Utah RLE image file format */
34 | #define TARGA_SUPPORTED /* Targa image file format */
35 |
36 | #define TWO_FILE_COMMANDLINE
37 | #define NEED_SIGNAL_CATCHER
38 | #undef DONT_USE_B_MODE
39 | #undef PROGRESS_REPORT /* optional */
40 |
41 | #define signal_catcher _abort /* hack for Aztec C naming requirements */
42 |
43 | #endif /* JPEG_CJPEG_DJPEG */
44 |
--------------------------------------------------------------------------------
/src/R3/R3.h:
--------------------------------------------------------------------------------
1 | // Include files for R3 package
2 | #ifndef R3_INCLUDED
3 | #define R3_INCLUDED
4 |
5 |
6 |
7 | // Include files
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include "R2/R2.h"
15 | #ifdef _WIN32
16 | # include
17 | #pragma warning(disable:4996)
18 | #define M_PI 3.1415925
19 | #endif
20 |
21 |
22 |
23 | // Constant declarations
24 |
25 | #define R3_X 0
26 | #define R3_Y 1
27 | #define R3_Z 2
28 |
29 |
30 |
31 | // Class declarations
32 |
33 | class R3Point;
34 | class R3Vector;
35 | class R3Line;
36 | class R3Ray;
37 | class R3Segment;
38 | class R3Plane;
39 | class R3Box;
40 | class R3Cylinder;
41 | class R3Cone;
42 | class R3Sphere;
43 | class R3Matrix;
44 | class R3Block;
45 |
46 |
47 |
48 | // Class include files
49 |
50 | #include "R3Point.h"
51 | #include "R3Vector.h"
52 | #include "R3Line.h"
53 | #include "R3Ray.h"
54 | #include "R3Segment.h"
55 | #include "R3Plane.h"
56 | #include "R3Box.h"
57 | #include "R3Cylinder.h"
58 | #include "R3Cone.h"
59 | #include "R3Sphere.h"
60 | #include "R3Mesh.h"
61 | #include "R3Matrix.h"
62 | #include "R3Block.h"
63 | #include "R3Item.h"
64 | #include "R3Creature.h"
65 | #include "R3Character.h"
66 |
67 |
68 |
69 | // Utility include files
70 |
71 | #include "R3Distance.h"
72 |
73 |
74 |
75 | #endif
76 |
--------------------------------------------------------------------------------
/src/jpeg/rdgif.c:
--------------------------------------------------------------------------------
1 | /*
2 | * rdgif.c
3 | *
4 | * Copyright (C) 1991-1997, Thomas G. Lane.
5 | * This file is part of the Independent JPEG Group's software.
6 | * For conditions of distribution and use, see the accompanying README file.
7 | *
8 | * This file contains routines to read input images in GIF format.
9 | *
10 | *****************************************************************************
11 | * NOTE: to avoid entanglements with Unisys' patent on LZW compression, *
12 | * the ability to read GIF files has been removed from the IJG distribution. *
13 | * Sorry about that. *
14 | *****************************************************************************
15 | *
16 | * We are required to state that
17 | * "The Graphics Interchange Format(c) is the Copyright property of
18 | * CompuServe Incorporated. GIF(sm) is a Service Mark property of
19 | * CompuServe Incorporated."
20 | */
21 |
22 | #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
23 |
24 | #ifdef GIF_SUPPORTED
25 |
26 | /*
27 | * The module selection routine for GIF format input.
28 | */
29 |
30 | GLOBAL(cjpeg_source_ptr)
31 | jinit_read_gif (j_compress_ptr cinfo)
32 | {
33 | fprintf(stderr, "GIF input is unsupported for legal reasons. Sorry.\n");
34 | exit(EXIT_FAILURE);
35 | return NULL; /* keep compiler happy */
36 | }
37 |
38 | #endif /* GIF_SUPPORTED */
39 |
--------------------------------------------------------------------------------
/src/strings.h:
--------------------------------------------------------------------------------
1 | #ifndef __STRINGS_H__
2 | #define __STRINGS_H__
3 |
4 | const char s_Version[] = "MINECRAFT v.0.0.1";
5 | const char s_WAVFile[] = "sounds/ninth.wav";
6 | const char s_TexLogo[] = "textures/logo.jpg";
7 | const char s_TexDefault[] = "textures/default.jpg";
8 | const char s_TexAllDirt[] = "textures/alldirt.jpg";
9 | const char s_TexDirt[] = "textures/dirt.jpg";
10 | const char s_TexWood[] = "textures/wood.jpg";
11 | const char s_TexGrass[] = "textures/grass.jpg";
12 | const char s_TexLeaf[] = "textures/leaf.jpg";
13 | const char s_TexStone[] = "textures/stone.jpg";
14 | const char s_TexSand[] = "textures/sand.jpg";
15 | const char s_TexBedrock[] = "textures/bedrock.jpg";
16 | const char s_TexObsidian[] = "textures/obsidian.jpg";
17 | const char s_TexGold[] = "textures/gold.jpg";
18 | const char s_TexDirtIcon[] = "textures/dirt_icon.jpg";
19 | const char s_TexStoneIcon[] = "textures/stone_icon.jpg";
20 | const char s_TexWoodIcon[] = "textures/wood_icon.jpg";
21 | const char s_TexSandIcon[] = "textures/sand_icon.jpg";
22 | const char s_TexObsidianIcon[] = "textures/obsidian_icon.jpg";
23 | const char s_TexCow[] = "textures/cow.jpg";
24 | const char s_TexDeer[] = "textures/deer.jpg";
25 | const char s_TexSuicide[] = "textures/suicide.jpg";
26 | const char s_World[] = "world/chunks/chunk";
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/src/jpeg/maktjpeg.st:
--------------------------------------------------------------------------------
1 | ; Project file for Independent JPEG Group's software
2 | ;
3 | ; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C.
4 | ; Thanks to Frank Moehle (Frank.Moehle@arbi.informatik.uni-oldenburg.de),
5 | ; Dr. B. Setzepfandt (bernd@gina.uni-muenster.de),
6 | ; and Guido Vollbeding (guivol@esc.de).
7 | ;
8 | ; To use this file, rename it to jpegtran.prj.
9 | ; If you are using Turbo C, change filenames beginning with "pc..." to "tc..."
10 | ; Read installation instructions before trying to make the program!
11 | ;
12 | ;
13 | ; * * * Output file * * *
14 | jpegtran.ttp
15 | ;
16 | ; * * * COMPILER OPTIONS * * *
17 | .C[-P] ; absolute calls
18 | .C[-M] ; and no string merging, folks
19 | .C[-w-cln] ; no "constant is long" warnings
20 | .C[-w-par] ; no "parameter xxxx unused"
21 | .C[-w-rch] ; no "unreachable code"
22 | .C[-wsig] ; warn if significant digits may be lost
23 | =
24 | ; * * * * List of modules * * * *
25 | pcstart.o
26 | jpegtran.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,transupp.h,jversion.h)
27 | cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h)
28 | rdswitch.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h)
29 | transupp.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,transupp.h)
30 | libjpeg.lib ; built by libjpeg.prj
31 | pcstdlib.lib ; standard library
32 | pcextlib.lib ; extended library
33 |
--------------------------------------------------------------------------------
/input/stilllife.scn:
--------------------------------------------------------------------------------
1 | # This scene has the five platonic solids arranged on a box
2 | # It is good for testing combinations of ray-mesh interesections,
3 | # transformations, and illumination
4 |
5 | # A camera
6 | camera 0.640 9.446 5.606 -0.055 -0.851 -0.522 -0.005 0.523 -0.853 0.25 0.01 100
7 |
8 | # Two colored point lights and directional light
9 | point_light 1 1 0 -2 1 3 0 0 1
10 | point_light 0 1 1 2 1 3 0 0 1
11 | dir_light 0.2 0.2 0.2 0 -1 0
12 |
13 | # Shiny materials
14 | material 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 100 1 0
15 | material 0 0 0 1 1 0 1 1 1 0 0 0 0 0 0 100 1 0
16 | material 0 0 0 1 0 1 1 1 1 0 0 0 0 0 0 100 1 0
17 | material 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 100 1 0
18 | material 0 0 0 1 0 0 1 1 1 0 0 0 0 0 0 100 1 0
19 |
20 | # Box for "table top"
21 | box 1 -3 -1 -3 3 0 3
22 |
23 | # Platonic solids "sitting" on table
24 | begin -1
25 | 1 0 0 0
26 | 0 1 0 2
27 | 0 0 1 0
28 | 0 0 0 1
29 | mesh 0 tetra.off
30 | end
31 | begin -1
32 | 1 0 0 -1
33 | 0 1 0 1
34 | 0 0 1 -1
35 | 0 0 0 1
36 | mesh 1 octa.off
37 | end
38 | begin -1
39 | 1 0 0 1
40 | 0 1 0 1
41 | 0 0 1 -1
42 | 0 0 0 1
43 | mesh 2 cube.off
44 | end
45 | begin -1
46 | 1 0 0 -1
47 | 0 1 0 1
48 | 0 0 1 1
49 | 0 0 0 1
50 | mesh 3 dodeca.off
51 | end
52 | begin -1
53 | 1 0 0 1
54 | 0 1 0 1
55 | 0 0 1 1
56 | 0 0 0 1
57 | mesh 4 ico.off
58 | end
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/input/distributed-slow.scn:
--------------------------------------------------------------------------------
1 | # spheres inside a box.
2 |
3 | # A camera
4 | camera 0.0 2 8 0 0 -1 0.000 1 0 0.78 0.01 100
5 |
6 | # One light, black, to suppress automatic generation of light sources.
7 | point_light 0 0 0 0 3.5 1 0 0 1
8 |
9 | # Three diffuse materials (red, green, gray)
10 | material 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 10 1 0
11 | material 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 10 1 0
12 | material 0 0 0 0.8 0.8 0.8 0 0 0 0 0 0 0 0 0 10 1 0
13 |
14 | # one mirroring material
15 | material 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 100 1 0
16 |
17 | # one glass material, blue tint
18 | material .1 .1 .1 0 0 0 0.25 0.25 0.25 .5 .5 .75 0 0 0 20 2 0
19 |
20 | # emissive ceiling light
21 | material 0 0 0 0 0 0 0.0 0 0 0 0 0 4 4 4 1 1 0
22 |
23 | # box
24 |
25 | # floor
26 | box 2 -4 -1 -4 4 0 5
27 | # roof
28 | box 2 -4 4 -4 4 5 5
29 | # back wall
30 | box 2 -4 0 -4 4 5 -3
31 | # front wall
32 | # box 2 -4 0 9 4 5 5
33 | # left wall
34 | box 0 -5 -1 -4 -4 5 5
35 | # right wall
36 | box 1 4 -1 -4 5 5 5
37 |
38 | # emissive ceiling light
39 | box 5 -2 3.9 -2 2 4 2
40 |
41 |
42 | # diffuse sphere sitting to the left in the box
43 | sphere 2 -2 1 1 1
44 | # mirroring sphere sitting in the center of the box
45 | sphere 3 0 1 1 1
46 | # glass sphere sitting to the right (lower than the other spheres so that its caustic hopefully becomes visible)
47 | sphere 4 2 1 1 1
48 |
--------------------------------------------------------------------------------
/src/jpeg/jconfig.st:
--------------------------------------------------------------------------------
1 | /* jconfig.st --- jconfig.h for Atari ST/STE/TT using Pure C or Turbo C. */
2 | /* see jconfig.doc for explanations */
3 |
4 | #define HAVE_PROTOTYPES
5 | #define HAVE_UNSIGNED_CHAR
6 | #define HAVE_UNSIGNED_SHORT
7 | /* #define void char */
8 | /* #define const */
9 | #undef CHAR_IS_UNSIGNED
10 | #define HAVE_STDDEF_H
11 | #define HAVE_STDLIB_H
12 | #undef NEED_BSD_STRINGS
13 | #undef NEED_SYS_TYPES_H
14 | #undef NEED_FAR_POINTERS
15 | #undef NEED_SHORT_EXTERNAL_NAMES
16 | #define INCOMPLETE_TYPES_BROKEN /* suppress undefined-structure warnings */
17 |
18 | #ifdef JPEG_INTERNALS
19 |
20 | #undef RIGHT_SHIFT_IS_UNSIGNED
21 |
22 | #define ALIGN_TYPE long /* apparently double is a weird size? */
23 |
24 | #endif /* JPEG_INTERNALS */
25 |
26 | #ifdef JPEG_CJPEG_DJPEG
27 |
28 | #define BMP_SUPPORTED /* BMP image file format */
29 | #define GIF_SUPPORTED /* GIF image file format */
30 | #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
31 | #undef RLE_SUPPORTED /* Utah RLE image file format */
32 | #define TARGA_SUPPORTED /* Targa image file format */
33 |
34 | #define TWO_FILE_COMMANDLINE /* optional -- undef if you like Unix style */
35 | /* Note: if you undef TWO_FILE_COMMANDLINE, you may need to define
36 | * USE_SETMODE. Some Atari compilers require it, some do not.
37 | */
38 | #define NEED_SIGNAL_CATCHER /* needed if you use jmemname.c */
39 | #undef DONT_USE_B_MODE
40 | #undef PROGRESS_REPORT /* optional */
41 |
42 | #endif /* JPEG_CJPEG_DJPEG */
43 |
--------------------------------------------------------------------------------
/src/jpeg/jconfig.vc:
--------------------------------------------------------------------------------
1 | /* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */
2 | /* see jconfig.doc for explanations */
3 |
4 | #define HAVE_PROTOTYPES
5 | #define HAVE_UNSIGNED_CHAR
6 | #define HAVE_UNSIGNED_SHORT
7 | /* #define void char */
8 | /* #define const */
9 | #undef CHAR_IS_UNSIGNED
10 | #define HAVE_STDDEF_H
11 | #define HAVE_STDLIB_H
12 | #undef NEED_BSD_STRINGS
13 | #undef NEED_SYS_TYPES_H
14 | #undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */
15 | #undef NEED_SHORT_EXTERNAL_NAMES
16 | #undef INCOMPLETE_TYPES_BROKEN
17 |
18 | /* Define "boolean" as unsigned char, not int, per Windows custom */
19 | #ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
20 | typedef unsigned char boolean;
21 | #endif
22 | #define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
23 |
24 |
25 | #ifdef JPEG_INTERNALS
26 |
27 | #undef RIGHT_SHIFT_IS_UNSIGNED
28 |
29 | #endif /* JPEG_INTERNALS */
30 |
31 | #ifdef JPEG_CJPEG_DJPEG
32 |
33 | #define BMP_SUPPORTED /* BMP image file format */
34 | #define GIF_SUPPORTED /* GIF image file format */
35 | #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
36 | #undef RLE_SUPPORTED /* Utah RLE image file format */
37 | #define TARGA_SUPPORTED /* Targa image file format */
38 |
39 | #define TWO_FILE_COMMANDLINE /* optional */
40 | #define USE_SETMODE /* Microsoft has setmode() */
41 | #undef NEED_SIGNAL_CATCHER
42 | #undef DONT_USE_B_MODE
43 | #undef PROGRESS_REPORT /* optional */
44 |
45 | #endif /* JPEG_CJPEG_DJPEG */
46 |
--------------------------------------------------------------------------------
/src/R3/R3Block.h:
--------------------------------------------------------------------------------
1 | #ifndef __BLOCK_H_
2 | #define __BLOCK_H_
3 |
4 | #include "R3.h"
5 |
6 | typedef enum
7 | {
8 | DIRT_BLOCK, //0
9 | AIR_BLOCK, //1
10 | LEAF_BLOCK, //2
11 | WOOD_BLOCK, //3
12 | STONE_BLOCK, //4
13 | SAND_BLOCK, //5
14 | OBSIDIAN_BLOCK, //6
15 | GOLD_BLOCK //7
16 | } R3BlockType;
17 |
18 | #define DIRT_HEALTH 3
19 | #define AIR_HEALTH -1
20 | #define LEAF_HEALTH 1
21 | #define WOOD_HEALTH 2
22 | #define STONE_HEALTH 5
23 | #define SAND_HEALTH 1
24 | #define OBSIDIAN_HEALTH 10
25 | #define GOLD_HEALTH 12
26 |
27 | class R3Block
28 | {
29 | public:
30 | R3Block(const R3Box& box, int type);
31 |
32 | R3Box& getBox();
33 | int getBlockType() const;
34 | int getHealth() const;
35 | void changeBlock(int newType);
36 | R3Block *getUpper() const;
37 | void setUpper(R3Block *up);
38 | void Draw(void) const;
39 | void Draw(int face, bool isSelected) const;
40 |
41 | public:
42 | R3Box box;
43 | int blockType;
44 | int health;
45 | bool walkable;
46 | bool transparent;
47 | bool gravity;
48 | R3Block *upper;
49 | int dx; int dy; int dz;
50 | };
51 |
52 | inline R3Box& R3Block::
53 | getBox (void)
54 | {
55 | // Get the box for this block
56 | return box;
57 | }
58 |
59 | inline int R3Block::
60 | getBlockType (void) const
61 | {
62 | return blockType;
63 | }
64 |
65 | inline int R3Block::
66 | getHealth (void) const
67 | {
68 | return health;
69 | }
70 |
71 | inline R3Block *R3Block::
72 | getUpper (void) const
73 | {
74 | return upper;
75 | }
76 |
77 | inline void R3Block::
78 | setUpper (R3Block *up)
79 | {
80 | upper = up;
81 | }
82 |
83 | #endif
84 |
--------------------------------------------------------------------------------
/src/jpeg/jconfig.bcc:
--------------------------------------------------------------------------------
1 | /* jconfig.bcc --- jconfig.h for Borland C (Turbo C) on MS-DOS or OS/2. */
2 | /* see jconfig.doc for explanations */
3 |
4 | #define HAVE_PROTOTYPES
5 | #define HAVE_UNSIGNED_CHAR
6 | #define HAVE_UNSIGNED_SHORT
7 | /* #define void char */
8 | /* #define const */
9 | #undef CHAR_IS_UNSIGNED
10 | #define HAVE_STDDEF_H
11 | #define HAVE_STDLIB_H
12 | #undef NEED_BSD_STRINGS
13 | #undef NEED_SYS_TYPES_H
14 | #ifdef __MSDOS__
15 | #define NEED_FAR_POINTERS /* for small or medium memory model */
16 | #endif
17 | #undef NEED_SHORT_EXTERNAL_NAMES
18 | #undef INCOMPLETE_TYPES_BROKEN /* this assumes you have -w-stu in CFLAGS */
19 |
20 | #ifdef JPEG_INTERNALS
21 |
22 | #undef RIGHT_SHIFT_IS_UNSIGNED
23 |
24 | #ifdef __MSDOS__
25 | #define USE_MSDOS_MEMMGR /* Define this if you use jmemdos.c */
26 | #define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */
27 | #define USE_FMEM /* Borland has _fmemcpy() and _fmemset() */
28 | #endif
29 |
30 | #endif /* JPEG_INTERNALS */
31 |
32 | #ifdef JPEG_CJPEG_DJPEG
33 |
34 | #define BMP_SUPPORTED /* BMP image file format */
35 | #define GIF_SUPPORTED /* GIF image file format */
36 | #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
37 | #undef RLE_SUPPORTED /* Utah RLE image file format */
38 | #define TARGA_SUPPORTED /* Targa image file format */
39 |
40 | #define TWO_FILE_COMMANDLINE
41 | #define USE_SETMODE /* Borland has setmode() */
42 | #ifdef __MSDOS__
43 | #define NEED_SIGNAL_CATCHER /* Define this if you use jmemdos.c */
44 | #endif
45 | #undef DONT_USE_B_MODE
46 | #undef PROGRESS_REPORT /* optional */
47 |
48 | #endif /* JPEG_CJPEG_DJPEG */
49 |
--------------------------------------------------------------------------------
/src/R2/R2Distance.h:
--------------------------------------------------------------------------------
1 | // Include file for R2 distance utility
2 |
3 |
4 |
5 | // Function declarations
6 |
7 | double R2Distance(const R2Point& point1, const R2Point& point2);
8 | double R2Distance(const R2Point& point, const R2Line& line);
9 | double R2Distance(const R2Point& point, const R2Segment& segment);
10 |
11 | double R2Distance(const R2Line& line, const R2Point& point);
12 | double R2Distance(const R2Line& line1, const R2Line& line2);
13 | double R2Distance(const R2Line& line, const R2Segment& segment);
14 |
15 | double R2Distance(const R2Segment& segment, const R2Point& point);
16 | double R2Distance(const R2Segment& segment, const R2Line& line);
17 | double R2Distance(const R2Segment& segment1, const R2Segment& segment2);
18 |
19 | double R2SignedDistance(const R2Point& point, const R2Line& line);
20 | double R2SignedDistance(const R2Line& line, const R2Point& point);
21 |
22 |
23 |
24 | // Inline functions
25 |
26 | inline double R2Distance(const R2Line& line, const R2Point& point)
27 | {
28 | // Distance is commutative
29 | return R2Distance(point, line);
30 | }
31 |
32 |
33 |
34 | inline double R2Distance(const R2Segment& segment, const R2Point& point)
35 | {
36 | // Distance is commutative
37 | return R2Distance(point, segment);
38 | }
39 |
40 |
41 |
42 | inline double R2Distance(const R2Segment& segment, const R2Line& line)
43 | {
44 | // Distance is commutative
45 | return R2Distance(line, segment);
46 | }
47 |
48 |
49 |
50 | inline double R2SignedDistance(const R2Point& point, const R2Line& line)
51 | {
52 | // Distance is commutative
53 | return R2SignedDistance(line, point);
54 | }
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/src/jpeg/ansi2knr.1:
--------------------------------------------------------------------------------
1 | .TH ANSI2KNR 1 "19 Jan 1996"
2 | .SH NAME
3 | ansi2knr \- convert ANSI C to Kernighan & Ritchie C
4 | .SH SYNOPSIS
5 | .I ansi2knr
6 | [--varargs] input_file [output_file]
7 | .SH DESCRIPTION
8 | If no output_file is supplied, output goes to stdout.
9 | .br
10 | There are no error messages.
11 | .sp
12 | .I ansi2knr
13 | recognizes function definitions by seeing a non-keyword identifier at the left
14 | margin, followed by a left parenthesis, with a right parenthesis as the last
15 | character on the line, and with a left brace as the first token on the
16 | following line (ignoring possible intervening comments). It will recognize a
17 | multi-line header provided that no intervening line ends with a left or right
18 | brace or a semicolon. These algorithms ignore whitespace and comments, except
19 | that the function name must be the first thing on the line.
20 | .sp
21 | The following constructs will confuse it:
22 | .br
23 | - Any other construct that starts at the left margin and follows the
24 | above syntax (such as a macro or function call).
25 | .br
26 | - Some macros that tinker with the syntax of the function header.
27 | .sp
28 | The --varargs switch is obsolete, and is recognized only for
29 | backwards compatibility. The present version of
30 | .I ansi2knr
31 | will always attempt to convert a ... argument to va_alist and va_dcl.
32 | .SH AUTHOR
33 | L. Peter Deutsch wrote the original ansi2knr and
34 | continues to maintain the current version; most of the code in the current
35 | version is his work. ansi2knr also includes contributions by Francois
36 | Pinard and Jim Avera .
37 |
--------------------------------------------------------------------------------
/input/distributed.scn:
--------------------------------------------------------------------------------
1 | # spheres inside a box.
2 |
3 | # A camera
4 | camera 0.0 2 8 0 0 -1 0.000 1 0 0.78 0.01 100
5 |
6 | # One light, black, to suppress automatic generation of light sources.
7 | point_light 0 0 0 0 3.5 1 0 0 1
8 |
9 | # Three diffuse materials (red, green, gray)
10 | material 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 10 1 0
11 | material 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 10 1 0
12 | material 0 0 0 0.8 0.8 0.8 0 0 0 0 0 0 0 0 0 10 1 0
13 |
14 | # one mirroring material
15 | material 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 100 1 0
16 |
17 | # one glass material, blue tint
18 | material .1 .1 .1 0 0 0 0.25 0.25 0.25 .5 .5 .75 0 0 0 20 2 0
19 |
20 | # emissive ceiling light
21 | material 0 0 0 0 0 0 0.0 0 0 0 0 0 4 4 4 1 1 0
22 |
23 | # box
24 |
25 | # reduce geometric complexity: build the cornell box out of a mesh
26 |
27 | mesh 2 distributed-box.off
28 | mesh 0 distributed-left.off
29 | mesh 1 distributed-right.off
30 |
31 | # floor
32 | # box 2 -4 -1 -4 4 0 5
33 | # roof
34 | # box 2 -4 4 -4 4 5 5
35 | # back wall
36 | # box 2 -4 0 -4 4 5 -3
37 | # front wall
38 | # box 2 -4 0 9 4 5 5
39 | # left wall
40 | # box 0 -5 -1 -4 -4 5 5
41 | # right wall
42 | # box 1 4 -1 -4 5 5 5
43 |
44 | mesh 5 distributed-ceilinglight.off
45 |
46 | # emissive ceiling light
47 | #box 5 -2 3.9 -2 2 4 2
48 |
49 |
50 | # diffuse sphere sitting to the left in the box
51 | sphere 2 -2 1 1 1
52 | # mirroring sphere sitting in the center of the box
53 | sphere 3 0 1 1 1
54 | # glass sphere sitting to the right (lower than the other spheres so that its caustic hopefully becomes visible)
55 | sphere 4 2 1 1 1
56 |
--------------------------------------------------------------------------------
/input/stack.scn:
--------------------------------------------------------------------------------
1 | # This scene shows a stack of four teapots
2 | # It is useful for testing acceleration of ray-mesh intersection
3 | # after you have tested handling of transformations during ray-scene intersection
4 |
5 | # A camera
6 | camera 1 8 16 -0.053 -0.316 -0.947 0.003 0.949 -0.316 0.25 0.01 100
7 |
8 | # Three colored point lights and directional light
9 | point_light 1 0 0 0 6 3 0 0 1
10 | point_light 1 1 0 -2 1 3 0 0 1
11 | point_light 0 1 1 2 1 3 0 0 1
12 | dir_light 0.2 0.2 0.2 0 -1 0
13 |
14 | # Two shiny gray materials
15 | material 0 0 0 0.8 0.8 0.8 1 1 1 0 0 0 0 0 0 10 1 0
16 | material 0 0 0 0.5 0.5 0.5 1 1 1 0 0 0 0 0 0 10 1 0
17 |
18 | # A box
19 | box 1 -4 -1 -4 4 0 4
20 |
21 | # A stack of teapots
22 | begin -1
23 | 1 0 0 0
24 | 0 1 0 0
25 | 0 0 1 0
26 | 0 0 0 1
27 |
28 | mesh 0 teapot.off
29 |
30 | begin -1
31 | 0.5 0 0 0
32 | 0 0.5 0 3
33 | 0 0 0.5 0
34 | 0 0 0 1
35 |
36 | mesh 0 teapot.off
37 |
38 | begin -1
39 | 0.5 0 0 0
40 | 0 0.5 0 3
41 | 0 0 0.5 0
42 | 0 0 0 1
43 |
44 | mesh 0 teapot.off
45 |
46 | begin -1
47 | 0.5 0 0 0
48 | 0 0.5 0 3
49 | 0 0 0.5 0
50 | 0 0 0 1
51 |
52 | mesh 0 teapot.off
53 |
54 |
55 | begin -1
56 | 0.5 0 0 0
57 | 0 0.5 0 3
58 | 0 0 0.5 0
59 | 0 0 0 1
60 |
61 | mesh 0 teapot.off
62 |
63 | end
64 |
65 | end
66 |
67 | end
68 |
69 | end
70 |
71 | end
72 |
73 |
--------------------------------------------------------------------------------
/input/mixedprimitives3.scn:
--------------------------------------------------------------------------------
1 | # This scene shows a mixture of primitives with different colors.
2 | # It is the same as mixedprimitives2.scn, but with transformations
3 | # in the grouping nodes.
4 | # It is useful for testing ray-scene intersections with transformations.
5 |
6 | # A camera
7 | camera 0 0 15 0 0 -1 0 1 0 0.25 0.01 100
8 |
9 | # Two directional lights
10 | dir_light 1 1 1 -3 -4 -5
11 | dir_light 0.5 0.5 0.5 3 2 3
12 |
13 | # Five shiny materials (yellow, cyan, magenta, red, green)
14 | material 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 10 1 0
15 | material 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 10 1 0
16 | material 0 0 0 1 0 1 1 0 1 0 0 0 0 0 0 10 1 0
17 | material 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 10 1 0
18 | material 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 10 1 0
19 |
20 | # Group with material 0 and identity transformation
21 | begin 0
22 | 1 0 0 -2
23 | 0 1 0 -2
24 | 0 0 1 0
25 | 0 0 0 1
26 |
27 | sphere 0 0 0 0 1
28 | end
29 |
30 |
31 | # Group with material 1 and identity transformation
32 | begin 1
33 | 1 0 0 2
34 | 0 1 0 2
35 | 0 0 1 0
36 | 0 0 0 1
37 |
38 | box -1 -1 -1 -1 1 1 1
39 | end
40 |
41 |
42 | # Group with material 2 and identity transformation
43 | begin 2
44 | 1 0 0 0
45 | 0 1 0 0
46 | 0 0 1 0
47 | 0 0 0 1
48 |
49 | mesh -1 ico.off
50 | end
51 |
52 |
53 | # Group with default material and identity transformation
54 | begin -1
55 | 1 0 0 -2
56 | 0 1 0 2
57 | 0 0 1 0
58 | 0 0 0 1
59 |
60 | sphere 3 0 0 0 1
61 | end
62 |
63 |
64 | # Group with default material and identity transformation
65 | begin -1
66 | 1 0 0 2
67 | 0 1 0 -2
68 | 0 0 1 0
69 | 0 0 0 1
70 |
71 | box 4 -1 -1 -1 1 1 1
72 | end
73 |
74 |
75 |
--------------------------------------------------------------------------------
/src/R3/R3Sphere.h:
--------------------------------------------------------------------------------
1 | // Include file for the R3 sphere class
2 |
3 | #include "cos426_opengl.h"
4 |
5 | // Class definition
6 |
7 | class R3Sphere {
8 | public:
9 | // Constructor functions
10 | R3Sphere(void);
11 | R3Sphere(const R3Sphere& sphere);
12 | R3Sphere(const R3Point& center, double radius);
13 |
14 | // Sphere property functions/operators
15 | const R3Point& Center(void) const;
16 | const double Radius(void) const;
17 | const bool IsEmpty(void) const;
18 |
19 | // Shape property functions/operators
20 | double Area(void) const;
21 | double Volume(void) const;
22 | R3Box BBox(void) const;
23 |
24 | // Manipulation functions/operators
25 | void Empty(void);
26 | void Translate(const R3Vector& vector);
27 | void Reposition(const R3Point& center);
28 | void Resize(double radius);
29 |
30 | // Output functions
31 | void Draw(void) const;
32 | void Outline(void) const;
33 | void Print(FILE *fp = stdout) const;
34 |
35 | private:
36 | R3Point center;
37 | double radius;
38 | };
39 |
40 |
41 |
42 | // Public variables
43 |
44 | extern const R3Sphere R3null_sphere;
45 | extern const R3Sphere R3zero_sphere;
46 | extern const R3Sphere R3unit_sphere;
47 |
48 |
49 |
50 | // Inline functions
51 |
52 | inline const R3Point& R3Sphere::
53 | Center(void) const
54 | {
55 | // Return sphere center
56 | return center;
57 | }
58 |
59 |
60 |
61 | inline const double R3Sphere::
62 | Radius(void) const
63 | {
64 | // Return sphere radius
65 | return radius;
66 | }
67 |
68 |
69 |
70 | inline const bool R3Sphere::
71 | IsEmpty(void) const
72 | {
73 | // Return whether the sphere is null
74 | return (radius < 0.0);
75 | }
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/src/jpeg/jchuff.h:
--------------------------------------------------------------------------------
1 | /*
2 | * jchuff.h
3 | *
4 | * Copyright (C) 1991-1997, Thomas G. Lane.
5 | * This file is part of the Independent JPEG Group's software.
6 | * For conditions of distribution and use, see the accompanying README file.
7 | *
8 | * This file contains declarations for Huffman entropy encoding routines
9 | * that are shared between the sequential encoder (jchuff.c) and the
10 | * progressive encoder (jcphuff.c). No other modules need to see these.
11 | */
12 |
13 | /* The legal range of a DCT coefficient is
14 | * -1024 .. +1023 for 8-bit data;
15 | * -16384 .. +16383 for 12-bit data.
16 | * Hence the magnitude should always fit in 10 or 14 bits respectively.
17 | */
18 |
19 | #if BITS_IN_JSAMPLE == 8
20 | #define MAX_COEF_BITS 10
21 | #else
22 | #define MAX_COEF_BITS 14
23 | #endif
24 |
25 | /* Derived data constructed for each Huffman table */
26 |
27 | typedef struct {
28 | unsigned int ehufco[256]; /* code for each symbol */
29 | char ehufsi[256]; /* length of code for each symbol */
30 | /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */
31 | } c_derived_tbl;
32 |
33 | /* Short forms of external names for systems with brain-damaged linkers. */
34 |
35 | #ifdef NEED_SHORT_EXTERNAL_NAMES
36 | #define jpeg_make_c_derived_tbl jMkCDerived
37 | #define jpeg_gen_optimal_table jGenOptTbl
38 | #endif /* NEED_SHORT_EXTERNAL_NAMES */
39 |
40 | /* Expand a Huffman table definition into the derived format */
41 | EXTERN(void) jpeg_make_c_derived_tbl
42 | JPP((j_compress_ptr cinfo, jboolean isDC, int tblno,
43 | c_derived_tbl ** pdtbl));
44 |
45 | /* Generate an optimal table definition given the specified counts */
46 | EXTERN(void) jpeg_gen_optimal_table
47 | JPP((j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[]));
48 |
--------------------------------------------------------------------------------
/src/jpeg/rdjpgcom.1:
--------------------------------------------------------------------------------
1 | .TH RDJPGCOM 1 "11 October 1997"
2 | .SH NAME
3 | rdjpgcom \- display text comments from a JPEG file
4 | .SH SYNOPSIS
5 | .B rdjpgcom
6 | [
7 | .B \-verbose
8 | ]
9 | [
10 | .I filename
11 | ]
12 | .LP
13 | .SH DESCRIPTION
14 | .LP
15 | .B rdjpgcom
16 | reads the named JPEG/JFIF file, or the standard input if no file is named,
17 | and prints any text comments found in the file on the standard output.
18 | .PP
19 | The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file.
20 | Although the standard doesn't actually define what COM blocks are for, they
21 | are widely used to hold user-supplied text strings. This lets you add
22 | annotations, titles, index terms, etc to your JPEG files, and later retrieve
23 | them as text. COM blocks do not interfere with the image stored in the JPEG
24 | file. The maximum size of a COM block is 64K, but you can have as many of
25 | them as you like in one JPEG file.
26 | .SH OPTIONS
27 | .TP
28 | .B \-verbose
29 | Causes
30 | .B rdjpgcom
31 | to also display the JPEG image dimensions.
32 | .PP
33 | Switch names may be abbreviated, and are not case sensitive.
34 | .SH HINTS
35 | .B rdjpgcom
36 | does not depend on the IJG JPEG library. Its source code is intended as an
37 | illustration of the minimum amount of code required to parse a JPEG file
38 | header correctly.
39 | .PP
40 | In
41 | .B \-verbose
42 | mode,
43 | .B rdjpgcom
44 | will also attempt to print the contents of any "APP12" markers as text.
45 | Some digital cameras produce APP12 markers containing useful textual
46 | information. If you like, you can modify the source code to print
47 | other APPn marker types as well.
48 | .SH SEE ALSO
49 | .BR cjpeg (1),
50 | .BR djpeg (1),
51 | .BR jpegtran (1),
52 | .BR wrjpgcom (1)
53 | .SH AUTHOR
54 | Independent JPEG Group
55 |
--------------------------------------------------------------------------------
/src/jpeg/jconfig.mc6:
--------------------------------------------------------------------------------
1 | /* jconfig.mc6 --- jconfig.h for Microsoft C on MS-DOS, version 6.00A & up. */
2 | /* see jconfig.doc for explanations */
3 |
4 | #define HAVE_PROTOTYPES
5 | #define HAVE_UNSIGNED_CHAR
6 | #define HAVE_UNSIGNED_SHORT
7 | /* #define void char */
8 | /* #define const */
9 | #undef CHAR_IS_UNSIGNED
10 | #define HAVE_STDDEF_H
11 | #define HAVE_STDLIB_H
12 | #undef NEED_BSD_STRINGS
13 | #undef NEED_SYS_TYPES_H
14 | #define NEED_FAR_POINTERS /* for small or medium memory model */
15 | #undef NEED_SHORT_EXTERNAL_NAMES
16 | #undef INCOMPLETE_TYPES_BROKEN
17 |
18 | #ifdef JPEG_INTERNALS
19 |
20 | #undef RIGHT_SHIFT_IS_UNSIGNED
21 |
22 | #define USE_MSDOS_MEMMGR /* Define this if you use jmemdos.c */
23 |
24 | #define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */
25 |
26 | #define USE_FMEM /* Microsoft has _fmemcpy() and _fmemset() */
27 |
28 | #define NEED_FHEAPMIN /* far heap management routines are broken */
29 |
30 | #define SHORTxLCONST_32 /* enable compiler-specific DCT optimization */
31 | /* Note: the above define is known to improve the code with Microsoft C 6.00A.
32 | * I do not know whether it is good for later compiler versions.
33 | * Please report any info on this point to jpeg-info@uunet.uu.net.
34 | */
35 |
36 | #endif /* JPEG_INTERNALS */
37 |
38 | #ifdef JPEG_CJPEG_DJPEG
39 |
40 | #define BMP_SUPPORTED /* BMP image file format */
41 | #define GIF_SUPPORTED /* GIF image file format */
42 | #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
43 | #undef RLE_SUPPORTED /* Utah RLE image file format */
44 | #define TARGA_SUPPORTED /* Targa image file format */
45 |
46 | #define TWO_FILE_COMMANDLINE
47 | #define USE_SETMODE /* Microsoft has setmode() */
48 | #define NEED_SIGNAL_CATCHER /* Define this if you use jmemdos.c */
49 | #undef DONT_USE_B_MODE
50 | #undef PROGRESS_REPORT /* optional */
51 |
52 | #endif /* JPEG_CJPEG_DJPEG */
53 |
--------------------------------------------------------------------------------
/src/jpeg/makcjpeg.st:
--------------------------------------------------------------------------------
1 | ; Project file for Independent JPEG Group's software
2 | ;
3 | ; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C.
4 | ; Thanks to Frank Moehle (Frank.Moehle@arbi.informatik.uni-oldenburg.de),
5 | ; Dr. B. Setzepfandt (bernd@gina.uni-muenster.de),
6 | ; and Guido Vollbeding (guivol@esc.de).
7 | ;
8 | ; To use this file, rename it to cjpeg.prj.
9 | ; If you are using Turbo C, change filenames beginning with "pc..." to "tc..."
10 | ; Read installation instructions before trying to make the program!
11 | ;
12 | ;
13 | ; * * * Output file * * *
14 | cjpeg.ttp
15 | ;
16 | ; * * * COMPILER OPTIONS * * *
17 | .C[-P] ; absolute calls
18 | .C[-M] ; and no string merging, folks
19 | .C[-w-cln] ; no "constant is long" warnings
20 | .C[-w-par] ; no "parameter xxxx unused"
21 | .C[-w-rch] ; no "unreachable code"
22 | .C[-wsig] ; warn if significant digits may be lost
23 | =
24 | ; * * * * List of modules * * * *
25 | pcstart.o
26 | cjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,jversion.h)
27 | cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h)
28 | rdswitch.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h)
29 | rdppm.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h)
30 | rdgif.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h)
31 | rdtarga.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h)
32 | rdbmp.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h)
33 | rdrle.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h)
34 | libjpeg.lib ; built by libjpeg.prj
35 | pcfltlib.lib ; floating point library
36 | ; the float library can be omitted if you've turned off DCT_FLOAT_SUPPORTED
37 | pcstdlib.lib ; standard library
38 | pcextlib.lib ; extended library
39 |
--------------------------------------------------------------------------------
/src/jpeg/makdjpeg.st:
--------------------------------------------------------------------------------
1 | ; Project file for Independent JPEG Group's software
2 | ;
3 | ; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C.
4 | ; Thanks to Frank Moehle (Frank.Moehle@arbi.informatik.uni-oldenburg.de),
5 | ; Dr. B. Setzepfandt (bernd@gina.uni-muenster.de),
6 | ; and Guido Vollbeding (guivol@esc.de).
7 | ;
8 | ; To use this file, rename it to djpeg.prj.
9 | ; If you are using Turbo C, change filenames beginning with "pc..." to "tc..."
10 | ; Read installation instructions before trying to make the program!
11 | ;
12 | ;
13 | ; * * * Output file * * *
14 | djpeg.ttp
15 | ;
16 | ; * * * COMPILER OPTIONS * * *
17 | .C[-P] ; absolute calls
18 | .C[-M] ; and no string merging, folks
19 | .C[-w-cln] ; no "constant is long" warnings
20 | .C[-w-par] ; no "parameter xxxx unused"
21 | .C[-w-rch] ; no "unreachable code"
22 | .C[-wsig] ; warn if significant digits may be lost
23 | =
24 | ; * * * * List of modules * * * *
25 | pcstart.o
26 | djpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,jversion.h)
27 | cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h)
28 | rdcolmap.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h)
29 | wrppm.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h)
30 | wrgif.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h)
31 | wrtarga.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h)
32 | wrbmp.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h)
33 | wrrle.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h)
34 | libjpeg.lib ; built by libjpeg.prj
35 | pcfltlib.lib ; floating point library
36 | ; the float library can be omitted if you've turned off DCT_FLOAT_SUPPORTED
37 | pcstdlib.lib ; standard library
38 | pcextlib.lib ; extended library
39 |
--------------------------------------------------------------------------------
/src/R3/R3Cone.h:
--------------------------------------------------------------------------------
1 | // Include file for the R3 cone class
2 |
3 |
4 |
5 | // Class definition
6 |
7 | class R3Cone {
8 | public:
9 | // Constructor functions
10 | R3Cone(void);
11 | R3Cone(const R3Cone& cone);
12 | R3Cone(const R3Point& center, double radius, double height);
13 |
14 | // Cone propetry functions/operators
15 | const R3Point& Center(void) const;
16 | double Radius(void) const;
17 | double Height(void) const;
18 | R3Segment Axis(void) const;
19 |
20 | // Shape propetry functions/operators
21 | double Area(void) const;
22 | double Volume(void) const;
23 | R3Box BBox(void) const;
24 |
25 | // Manipulation functions/operators
26 | void Empty(void);
27 | void Translate(const R3Vector& vector);
28 | void Reposition(const R3Point& center);
29 | void Resize(double radius, double height);
30 |
31 | // Output functions
32 | void Draw(void) const;
33 | void Outline(void) const;
34 | void Print(FILE *fp = stdout) const;
35 |
36 | private:
37 | R3Point center;
38 | double radius;
39 | double height;
40 | };
41 |
42 |
43 |
44 | // Public variables
45 |
46 | extern const R3Cone R3null_cone;
47 | extern const R3Cone R3zero_cone;
48 | extern const R3Cone R3unit_cone;
49 |
50 |
51 |
52 | // Inline functions
53 |
54 | inline const R3Point& R3Cone::
55 | Center(void) const
56 | {
57 | // Return center point
58 | return center;
59 | }
60 |
61 |
62 |
63 | inline double R3Cone::
64 | Radius(void) const
65 | {
66 | // Return cone radius
67 | return radius;
68 | }
69 |
70 |
71 |
72 | inline double R3Cone::
73 | Height(void) const
74 | {
75 | // Return cone height
76 | return height;
77 | }
78 |
79 |
80 |
81 | inline R3Segment R3Cone::
82 | Axis(void) const
83 | {
84 | // Return cone axis
85 | return R3Segment(center + 0.5 * height * R3negy_vector, center + 0.5 * height * R3posy_vector);
86 | }
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/input/transform.scn:
--------------------------------------------------------------------------------
1 | # This scene shows seven spheres scattered in space
2 | # It is useful for testing handling of transformations
3 | # during ray-scene interesection
4 |
5 | # A camera
6 | camera 0 0 20 0 0 -1 0 1 0 0.25 0.01 100
7 |
8 | # Two directional lights
9 | dir_light 1 1 1 -3 -4 -5
10 | dir_light 0.5 0.5 0.5 3 2 3
11 |
12 | # Materials
13 | material 0 0 0 1 0 0 0.5 0.5 0.5 0 0 0 0 0 0 10 1 0
14 | material 0 0 0 0 1 0 0.5 0.5 0.5 0 0 0 0 0 0 10 1 0
15 | material 0 0 0 0 0 1 0.5 0.5 0.5 0 0 0 0 0 0 10 1 0
16 | material 0 0 0 1 1 0 0.5 0.5 0.5 0 0 0 0 0 0 10 1 0
17 |
18 | # Group with material 0 and translation by (-2,-2,0)
19 | begin 0
20 | 1 0 0 -2
21 | 0 1 0 -2
22 | 0 0 1 0
23 | 0 0 0 1
24 |
25 | # These spheres have material (-1),
26 | # which means they inherit the material of the group
27 | sphere -1 -1 -1 0 1
28 | sphere -1 -1 1 0 1
29 | sphere -1 1 -1 0 1
30 | sphere -1 1 1 0 1
31 |
32 | end
33 |
34 |
35 | # Group with material 1 and translation by (2,2,0)
36 | begin 1
37 | 1 0 0 2
38 | 0 1 0 2
39 | 0 0 1 0
40 | 0 0 0 1
41 |
42 | # These spheres have material (-1),
43 | # which means they inherit the material of the group
44 | sphere -1 0 0 0 1
45 |
46 | end
47 |
48 |
49 | # Group with material 2, scale by 0.5, and translation by (-2, 2,0)
50 | begin 2
51 | 0.5 0 0 -2
52 | 0 0.5 0 2
53 | 0 0 0.5 0
54 | 0 0 0 1
55 |
56 | # These spheres have material (-1),
57 | # which means they inherit the material of the group
58 | sphere -1 0 0 0 1
59 |
60 | end
61 |
62 |
63 | # Group with material 3, scale by 2, and translation by (0,0,-5)
64 | begin 3
65 | 2 0 0 0
66 | 0 2 0 0
67 | 0 0 2 -5
68 | 0 0 0 1
69 |
70 | # These spheres have material (-1),
71 | # which means they inherit the material of the group
72 | sphere -1 0 0 0 1
73 |
74 | end
75 |
76 |
--------------------------------------------------------------------------------
/src/R3/R3Cylinder.h:
--------------------------------------------------------------------------------
1 | // Include file for the R3 cylinder class
2 |
3 |
4 |
5 | // Class definition
6 |
7 | class R3Cylinder {
8 | public:
9 | // Constructor functions
10 | R3Cylinder(void);
11 | R3Cylinder(const R3Cylinder& cylinder);
12 | R3Cylinder(const R3Point& center, double radius, double height);
13 |
14 | // Cylinder propetry functions/operators
15 | const R3Point& Center(void) const;
16 | double Radius(void) const;
17 | double Height(void) const;
18 | R3Segment Axis(void) const;
19 |
20 | // Shape propetry functions/operators
21 | double Area(void) const;
22 | double Volume(void) const;
23 | R3Box BBox(void) const;
24 |
25 | // Manipulation functions/operators
26 | void Empty(void);
27 | void Translate(const R3Vector& vector);
28 | void Reposition(const R3Point& center);
29 | void Resize(double radius, double height);
30 |
31 | // Output functions
32 | void Draw(void) const;
33 | void Outline(void) const;
34 | void Print(FILE *fp = stdout) const;
35 |
36 | private:
37 | R3Point center;
38 | double radius;
39 | double height;
40 | };
41 |
42 |
43 |
44 | // Public variables
45 |
46 | extern const R3Cylinder R3null_cylinder;
47 | extern const R3Cylinder R3zero_cylinder;
48 | extern const R3Cylinder R3unit_cylinder;
49 |
50 |
51 |
52 | // Inline functions
53 |
54 | inline const R3Point& R3Cylinder::
55 | Center(void) const
56 | {
57 | // Return center point
58 | return center;
59 | }
60 |
61 |
62 |
63 | inline double R3Cylinder::
64 | Radius(void) const
65 | {
66 | // Return cylinder radius
67 | return radius;
68 | }
69 |
70 |
71 |
72 | inline double R3Cylinder::
73 | Height(void) const
74 | {
75 | // Return cylinder height
76 | return height;
77 | }
78 |
79 |
80 |
81 | inline R3Segment R3Cylinder::
82 | Axis(void) const
83 | {
84 | // Return cylinder axis
85 | return R3Segment(center + 0.5 * height * R3negy_vector, center + 0.5 * height * R3posy_vector);
86 | }
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/src/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile for COS426 assignment #3
3 | #
4 |
5 | #
6 | # List of source files
7 | #
8 |
9 | RAYPRO_SRCS=raypro.cpp raytrace.cpp R3Scene.cpp R3Chunk.cpp
10 | RAYPRO_OBJS=$(RAYPRO_SRCS:.cpp=.o)
11 |
12 | RAYVIEW_SRCS=minecraft.cpp raytrace.cpp R3Scene.cpp R3Chunk.cpp materials.cpp \
13 | utils.cpp ui.cpp draw.cpp
14 | RAYVIEW_OBJS=$(RAYVIEW_SRCS:.cpp=.o)
15 |
16 | #
17 | # Compile and link options. You can change the -g to -O to get
18 | # an optimized, rather than debug, build.
19 | #
20 |
21 | CXX=g++
22 | CXXFLAGS=-Wall -I. -g -DUSE_JPEG -O2
23 |
24 | #
25 | # OpenGL libraries
26 | #
27 | UNAME := $(shell uname)
28 | # Mac OS
29 | ifneq (,$(findstring Darwin,$(UNAME)))
30 | GLLIBS = -framework GLUT -framework OpenGL
31 | # Windows
32 | else
33 | ifneq (,$(findstring CYGWIN,$(UNAME)))
34 | GLLIBS = -lglut32 -lglu32 -lopengl32
35 | # Linux
36 | else
37 | GLLIBS = -lglut -lGLU -lGL -lopenal -lalut
38 | endif
39 | endif
40 |
41 | #
42 | # GNU Make: targets that don't build files
43 | #
44 |
45 | .PHONY: all clean distclean
46 |
47 | #
48 | # Rules encoding targets and dependencies. By default, the first of
49 | # these is built, but you can also build any individual target by
50 | # passing it to make - e.g., "make imgpro" or "make clean"
51 | #
52 | # Notice that many of the dependencies are implicit (e.g. a .o depends
53 | # on its corresponding .cpp), as are many of the compilation rules.
54 | #
55 |
56 | LIBS=R3/libR3.a R2/libR2.a jpeg/libjpeg.a
57 |
58 | all: raypro minecraft
59 |
60 | R3/libR3.a:
61 | $(MAKE) -C R3
62 |
63 | R2/libR2.a:
64 | $(MAKE) -C R2
65 |
66 | jpeg/libjpeg.a:
67 | $(MAKE) -C jpeg
68 |
69 | raypro: $(RAYPRO_OBJS) $(LIBS)
70 | rm -f $@
71 | $(CXX) $(CXXFLAGS) $^ -lm -o $@ $(GLLIBS)
72 |
73 | minecraft: $(RAYVIEW_OBJS) $(LIBS)
74 | rm -f $@
75 | $(CXX) $(CXXFLAGS) $^ -lm -o $@ $(GLLIBS)
76 |
77 | clean:
78 | rm -f *.o raypro minecraft
79 | $(MAKE) -C R3 clean
80 | $(MAKE) -C R2 clean
81 | $(MAKE) -C jpeg clean
82 |
83 |
84 | distclean: clean
85 |
86 |
--------------------------------------------------------------------------------
/src/R3Scene.h:
--------------------------------------------------------------------------------
1 | #ifndef __R3SCENE_H__
2 | #define __R3SCENE_H__
3 |
4 | #include
5 |
6 | #include "R3/R3.h"
7 | #include "R3Chunk.h"
8 |
9 | #define R3Rgb R2Pixel
10 | #define CHUNKS 3
11 | #define MIDCHUNK = (CHUNKS-1)/2
12 |
13 | // Scene graph definition
14 |
15 | typedef struct
16 | {
17 | int x;
18 | int y;
19 | int z;
20 | R3Chunk* current;
21 | } R3Index;
22 |
23 | struct R3Scene {
24 | public:
25 | // Constructor functions
26 | R3Scene(void);
27 |
28 | // Access functions
29 | R3Node *Root(void) const;
30 | int NLights(void) const;
31 | R3Light *Light(int k) const;
32 | R3Camera& Camera(void);
33 | R3Box& BBox(void);
34 |
35 | R3Index getIndex(R3Point p);
36 | int UpdateScene(R3Point loc);
37 | R3Node* getBlock(R3Point loc);
38 | R3Chunk* LoadChunk(int x_chunk, int z_chunk);
39 | // void MakeMaterials(R3Material* group_materials[]);
40 |
41 | // I/O functions
42 | int Read(const char *filename, R3Node *root = NULL);
43 | int WriteScene(const char* filename);
44 |
45 | public:
46 | R3Node *root;
47 | R3Chunk *terrain[CHUNKS][CHUNKS];
48 | R3Point start;
49 | vector lights;
50 | R3Camera camera;
51 | R3Box bbox;
52 | R3Rgb background;
53 | R3Rgb ambient;
54 | // R3Character* main_character;
55 | set< pair > generatedChunks;
56 | };
57 |
58 | inline R3Node *R3Scene::
59 | Root(void) const
60 | {
61 | // Return root node
62 | return root;
63 | }
64 |
65 |
66 |
67 | inline int R3Scene::
68 | NLights(void) const
69 | {
70 | // Return number of lights
71 | return lights.size();
72 | }
73 |
74 |
75 |
76 | inline R3Light *R3Scene::
77 | Light(int k) const
78 | {
79 | // Return kth light
80 | return lights[k];
81 | }
82 |
83 |
84 |
85 | inline R3Camera& R3Scene::
86 | Camera(void)
87 | {
88 | // Return camera
89 | return camera;
90 | }
91 |
92 |
93 |
94 | inline R3Box& R3Scene::
95 | BBox(void)
96 | {
97 | // Return bounding box
98 | return bbox;
99 | }
100 |
101 | #endif
102 |
--------------------------------------------------------------------------------
/src/R2/R2Distance.cpp:
--------------------------------------------------------------------------------
1 | // Source file for R2 distance utility
2 |
3 |
4 |
5 | // Include files
6 |
7 | #include "R2.h"
8 |
9 |
10 |
11 | // Public distance functions
12 |
13 | double R2Distance(const R2Point& point1, const R2Point& point2)
14 | {
15 | // Return length of vector between points
16 | R2Vector v = point1 - point2;
17 | return v.Length();
18 | }
19 |
20 |
21 |
22 | double R2Distance(const R2Point& point, const R2Line& line)
23 | {
24 | // Return distance from point to line
25 | double d = point.X() * line.A() + point.Y() * line.B() + line.C();
26 | return (d < 0.0) ? -d : d;
27 | }
28 |
29 |
30 |
31 | double R2Distance(const R2Point& point, const R2Segment& segment)
32 | {
33 | // Check segment
34 | if (segment.IsPoint()) return R2Distance(point, segment.Start());
35 |
36 | // Check if start point is closest
37 | R2Vector v1 = point - segment.Start();
38 | double dir1 = v1.Dot(segment.Vector());
39 | if (dir1 < 0) return v1.Length();
40 |
41 | // Check if end point is closest
42 | R2Vector v2 = point - segment.End();
43 | double dir2 = v2.Dot(segment.Vector());
44 | if (dir2 > 0) return v2.Length();
45 |
46 | // Return distance from point to segment line
47 | return R2Distance(point, segment.Line());
48 | }
49 |
50 |
51 |
52 | double R2Distance(const R2Line& line1, const R2Line& line2)
53 | {
54 | // Return distance from line to line
55 | if (line1.Vector() != line2.Vector()) return 0;
56 | else return fabs(line1.C() - line2.C());
57 | }
58 |
59 |
60 |
61 | double R2Distance(const R2Line& line, const R2Segment& segment)
62 | {
63 | // Return distance from segment to line
64 | double d1 = R2SignedDistance(line, segment.Start());
65 | double d2 = R2SignedDistance(line, segment.End());
66 | if (d1 < 0) {
67 | if (d2 < 0) return (d1 > d2) ? -d1 : -d2;
68 | else return 0;
69 | }
70 | else {
71 | if (d2 > 0) return (d1 < d2) ? d1 : d2;
72 | else return 0;
73 | }
74 | }
75 |
76 |
77 |
78 | double R2SignedDistance(const R2Line& line, const R2Point& point)
79 | {
80 | // Return signed distance from line to point
81 | return line.A() * point.X() + line.B() * point.Y() + line.C();
82 | }
83 |
84 |
85 |
--------------------------------------------------------------------------------
/input/mixedprimitives2.scn:
--------------------------------------------------------------------------------
1 | # This scene shows a mixture of primitives with different colors.
2 | # It is the same as mixedprimitives1.scn, but with the primitives
3 | # arranged in a deeper scene graph hierarchy.
4 | # It is useful for testing ray-scene intersections
5 | # with scene graph recursion. It also demonstrates how materials
6 | # can be inherited from parent groups in the scene graph
7 |
8 | # A camera
9 | camera 0 0 15 0 0 -1 0 1 0 0.25 0.01 100
10 |
11 | # Two directional lights
12 | dir_light 1 1 1 -3 -4 -5
13 | dir_light 0.5 0.5 0.5 3 2 3
14 |
15 | # Five shiny materials (yellow, cyan, magenta, red, green)
16 | material 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 10 1 0
17 | material 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 10 1 0
18 | material 0 0 0 1 0 1 1 0 1 0 0 0 0 0 0 10 1 0
19 | material 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 10 1 0
20 | material 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 10 1 0
21 |
22 | # Group with material 0 and identity transformation
23 | begin 0
24 | 1 0 0 0
25 | 0 1 0 0
26 | 0 0 1 0
27 | 0 0 0 1
28 |
29 | # This sphere has material -1, which means it inherits the material of the group
30 | sphere 0 -2 -2 0 1
31 | end
32 |
33 |
34 | # Group with material 1 and identity transformation
35 | begin 1
36 | 1 0 0 0
37 | 0 1 0 0
38 | 0 0 1 0
39 | 0 0 0 1
40 |
41 | # This box has material -1, which means it inherits the material of the group
42 | box -1 1 1 -1 3 3 1
43 | end
44 |
45 |
46 | # Group with material 2 and identity transformation
47 | begin 2
48 | 1 0 0 0
49 | 0 1 0 0
50 | 0 0 1 0
51 | 0 0 0 1
52 |
53 | # This mesh material -1, which means it inherits the material of the group
54 | mesh -1 ico.off
55 | end
56 |
57 |
58 | # Group with default material and identity transformation
59 | begin -1
60 | 1 0 0 0
61 | 0 1 0 0
62 | 0 0 1 0
63 | 0 0 0 1
64 |
65 | # This sphere has material -1, which means it inherits the material of the group
66 | sphere 3 -2 2 0 1
67 | end
68 |
69 |
70 | # Group with default material and identity transformation
71 | begin -1
72 | 1 0 0 0
73 | 0 1 0 0
74 | 0 0 1 0
75 | 0 0 0 1
76 |
77 | # This box has material -1, which means it inherits the material of the group
78 | box 4 1 -1 -1 3 -3 1
79 | end
80 |
81 |
82 |
--------------------------------------------------------------------------------
/src/R3/R3Ray.cpp:
--------------------------------------------------------------------------------
1 | // Source file for the R3 ray class
2 |
3 |
4 |
5 | // Include files
6 |
7 | #include "R3.h"
8 |
9 |
10 |
11 | // Public variables
12 |
13 | const R3Ray R3null_ray(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
14 | const R3Ray R3posx_ray(0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
15 | const R3Ray R3posy_ray(0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
16 | const R3Ray R3posz_ray(0.0, 0.0, 0.0, 0.0, 0.0, 1.0);
17 | const R3Ray R3negx_ray(0.0, 0.0, 0.0, -1.0, 0.0, 0.0);
18 | const R3Ray R3negy_ray(0.0, 0.0, 0.0, 0.0, -1.0, 0.0);
19 | const R3Ray R3negz_ray(0.0, 0.0, 0.0, 0.0, 0.0, -1.0);
20 |
21 |
22 |
23 | // Public functions
24 |
25 | R3Ray::
26 | R3Ray(void)
27 | {
28 | }
29 |
30 |
31 |
32 | R3Ray::
33 | R3Ray(const R3Ray& ray)
34 | : line(ray.line)
35 | {
36 | }
37 |
38 |
39 |
40 | R3Ray::
41 | R3Ray(const R3Point& point, const R3Vector& vector, bool normalized)
42 | : line(point, vector, normalized)
43 | {
44 | }
45 |
46 |
47 |
48 | R3Ray::
49 | R3Ray(const R3Point& point1, const R3Point& point2)
50 | : line(point1, point2)
51 | {
52 | }
53 |
54 |
55 |
56 | R3Ray::
57 | R3Ray(double x1, double y1, double z1, double x2, double y2, double z2)
58 | : line(x1, y1, z1, x2, y2, z2)
59 | {
60 | }
61 |
62 |
63 |
64 | const R3Point R3Ray::
65 | Point(double t) const
66 | {
67 | // Return point along span
68 | return (Start() + Vector() * t);
69 | }
70 |
71 |
72 |
73 | const double R3Ray::
74 | T(const R3Point& point) const
75 | {
76 | // Return parametric value of closest point on ray
77 | if (IsZero()) return 0.0;
78 | double denom = Vector().Dot(Vector());
79 | assert(denom != 0);
80 | R3Vector topoint = point - Start();
81 | return (Vector().Dot(topoint) / denom);
82 | }
83 |
84 |
85 |
86 | void R3Ray::
87 | Transform (const R3Matrix& matrix)
88 | {
89 | // Transform line
90 | line.Transform(matrix);
91 | }
92 |
93 |
94 |
95 | void R3Ray::
96 | InverseTransform (const R3Matrix& matrix)
97 | {
98 | // Transform line
99 | line.InverseTransform(matrix);
100 | }
101 |
102 |
103 |
104 |
105 | void R3Ray::
106 | Print(FILE *fp) const
107 | {
108 | // Print line containing ray
109 | line.Print();
110 | }
111 |
112 |
113 |
114 |
115 |
--------------------------------------------------------------------------------
/src/jpeg/jcinit.c:
--------------------------------------------------------------------------------
1 | /*
2 | * jcinit.c
3 | *
4 | * Copyright (C) 1991-1997, Thomas G. Lane.
5 | * This file is part of the Independent JPEG Group's software.
6 | * For conditions of distribution and use, see the accompanying README file.
7 | *
8 | * This file contains initialization logic for the JPEG compressor.
9 | * This routine is in charge of selecting the modules to be executed and
10 | * making an initialization call to each one.
11 | *
12 | * Logically, this code belongs in jcmaster.c. It's split out because
13 | * linking this routine implies linking the entire compression library.
14 | * For a transcoding-only application, we want to be able to use jcmaster.c
15 | * without linking in the whole library.
16 | */
17 |
18 | #define JPEG_INTERNALS
19 | #include "jinclude.h"
20 | #include "jpeglib.h"
21 |
22 |
23 | /*
24 | * Master selection of compression modules.
25 | * This is done once at the start of processing an image. We determine
26 | * which modules will be used and give them appropriate initialization calls.
27 | */
28 |
29 | GLOBAL(void)
30 | jinit_compress_master (j_compress_ptr cinfo)
31 | {
32 | /* Initialize master control (includes parameter checking/processing) */
33 | jinit_c_master_control(cinfo, FALSE /* full compression */);
34 |
35 | /* Preprocessing */
36 | if (! cinfo->raw_data_in) {
37 | jinit_color_converter(cinfo);
38 | jinit_downsampler(cinfo);
39 | jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */);
40 | }
41 | /* Forward DCT */
42 | jinit_forward_dct(cinfo);
43 | /* Entropy encoding: either Huffman or arithmetic coding. */
44 | if (cinfo->arith_code) {
45 | ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
46 | } else {
47 | if (cinfo->progressive_mode) {
48 | #ifdef C_PROGRESSIVE_SUPPORTED
49 | jinit_phuff_encoder(cinfo);
50 | #else
51 | ERREXIT(cinfo, JERR_NOT_COMPILED);
52 | #endif
53 | } else
54 | jinit_huff_encoder(cinfo);
55 | }
56 |
57 | /* Need a full-image coefficient buffer in any multi-pass mode. */
58 | jinit_c_coef_controller(cinfo,
59 | (jboolean) (cinfo->num_scans > 1 || cinfo->optimize_coding));
60 | jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);
61 |
62 | jinit_marker_writer(cinfo);
63 |
64 | /* We can now tell the memory manager to allocate virtual arrays. */
65 | (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
66 |
67 | /* Write the datastream header (SOI) immediately.
68 | * Frame and scan headers are postponed till later.
69 | * This lets application insert special markers after the SOI.
70 | */
71 | (*cinfo->marker->write_file_header) (cinfo);
72 | }
73 |
--------------------------------------------------------------------------------
/src/R3/R3Line.cpp:
--------------------------------------------------------------------------------
1 | // Source file for the R3 line class
2 |
3 |
4 |
5 | // Include files
6 |
7 | #include "R3.h"
8 |
9 |
10 |
11 | // Public variables
12 |
13 | const R3Line R3null_line(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
14 | const R3Line R3posx_line(0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
15 | const R3Line R3posy_line(0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
16 | const R3Line R3posz_line(0.0, 0.0, 0.0, 0.0, 0.0, 1.0);
17 | const R3Line R3negx_line(0.0, 0.0, 0.0, -1.0, 0.0, 0.0);
18 | const R3Line R3negy_line(0.0, 0.0, 0.0, 0.0, -1.0, 0.0);
19 | const R3Line R3negz_line(0.0, 0.0, 0.0, 0.0, 0.0, -1.0);
20 |
21 |
22 |
23 | // Public functions
24 |
25 | R3Line::
26 | R3Line(void)
27 | {
28 | }
29 |
30 |
31 |
32 | R3Line::
33 | R3Line(const R3Line& line)
34 | : point(line.point),
35 | vector(line.vector)
36 | {
37 | }
38 |
39 |
40 |
41 | R3Line::
42 | R3Line(const R3Point& point, const R3Vector& vector, bool normalized)
43 | : point(point),
44 | vector(vector)
45 | {
46 | // Normalize vector
47 | if (!normalized) this->vector.Normalize();
48 | }
49 |
50 |
51 |
52 | R3Line::
53 | R3Line(const R3Point& point1, const R3Point& point2)
54 | : point(point1),
55 | vector(point2 - point1)
56 | {
57 | // Normalize vector
58 | vector.Normalize();
59 | }
60 |
61 |
62 |
63 | R3Line::
64 | R3Line(double x1, double y1, double z1, double x2, double y2, double z2)
65 | : point(x1, y1, z1),
66 | vector(x2-x1, y2-y1, z2-z1)
67 | {
68 | // Normalize vector
69 | vector.Normalize();
70 | }
71 |
72 |
73 |
74 |
75 | void R3Line::
76 | Transform (const R3Matrix& matrix)
77 | {
78 | // Transform point and vector
79 | point = matrix * point;
80 | vector = matrix * vector;
81 | vector.Normalize();
82 | }
83 |
84 |
85 |
86 | void R3Line::
87 | InverseTransform (const R3Matrix& matrix)
88 | {
89 | // Transform point and vector
90 | R3Matrix inverse = matrix.Inverse();
91 | Transform(inverse);
92 | }
93 |
94 |
95 |
96 | bool R3Line::
97 | operator==(const R3Line& line) const
98 | {
99 | // Check if vectors are equal
100 | if (vector != line.vector) return false;
101 |
102 | // Return whether point lies on this line
103 | R3Vector v = vector;
104 | v.Cross(line.Point() - point);
105 | return v.IsZero();
106 | }
107 |
108 |
109 |
110 |
111 | void R3Line::
112 | Print(FILE *fp) const
113 | {
114 | // Print point and vector
115 | fprintf(fp, "(%g %g %g) (%g %g %g)", point[0], point[1], point[2], vector[0], vector[1], vector[2]);
116 | }
117 |
118 |
119 |
120 |
121 |
--------------------------------------------------------------------------------
/src/R3/R3Sphere.cpp:
--------------------------------------------------------------------------------
1 | // Source file for the R3 sphere class
2 |
3 |
4 |
5 | // Include files
6 |
7 | #include "R3.h"
8 |
9 |
10 |
11 | // Public variables
12 |
13 | const R3Sphere R3null_sphere(R3Point(0.0, 0.0, 0.0), -1.0);
14 | const R3Sphere R3zero_sphere(R3Point(0.0, 0.0, 0.0), 0.0);
15 | const R3Sphere R3unit_sphere(R3Point(0.0, 0.0, 0.0), 1.0);
16 |
17 |
18 |
19 | R3Sphere::
20 | R3Sphere(void)
21 | {
22 | }
23 |
24 |
25 |
26 | R3Sphere::
27 | R3Sphere(const R3Sphere& sphere)
28 | : center(sphere.center),
29 | radius(sphere.radius)
30 | {
31 | }
32 |
33 |
34 |
35 | R3Sphere::
36 | R3Sphere(const R3Point& center, double radius)
37 | : center(center),
38 | radius(radius)
39 | {
40 | }
41 |
42 |
43 |
44 | double R3Sphere::
45 | Area(void) const
46 | {
47 | // Return surface area of sphere
48 | return (4.0 * M_PI * radius * radius);
49 | }
50 |
51 |
52 |
53 | double R3Sphere::
54 | Volume(void) const
55 | {
56 | // Return volume of sphere
57 | return (1.3333333333333 * M_PI * radius * radius * radius);
58 | }
59 |
60 |
61 |
62 | R3Box R3Sphere::
63 | BBox(void) const
64 | {
65 | // Return bounding box of sphere
66 | return R3Box(center.X() - radius, center.Y() - radius, center.Z() - radius,
67 | center.X() + radius, center.Y() + radius, center.Z() + radius);
68 | }
69 |
70 |
71 |
72 | void R3Sphere::
73 | Empty(void)
74 | {
75 | // Empty sphere
76 | *this = R3null_sphere;
77 | }
78 |
79 |
80 |
81 | void R3Sphere::
82 | Translate(const R3Vector& vector)
83 | {
84 | // Move sphere center
85 | center.Translate(vector);
86 | }
87 |
88 |
89 |
90 | void R3Sphere::
91 | Reposition(const R3Point& center)
92 | {
93 | // Set sphere center
94 | this->center = center;
95 | }
96 |
97 |
98 |
99 | void R3Sphere::
100 | Resize(double radius)
101 | {
102 | // Set sphere radius
103 | this->radius = radius;
104 | }
105 |
106 |
107 | void R3Sphere::
108 | Draw(void) const
109 | {
110 | // Draw sphere
111 | glPushMatrix();
112 | glTranslated(center[0], center[1], center[2]);
113 | static GLUquadricObj *glu_sphere = gluNewQuadric();
114 | gluQuadricTexture(glu_sphere, GL_TRUE);
115 | gluQuadricNormals(glu_sphere, (GLenum) GLU_SMOOTH);
116 | gluQuadricDrawStyle(glu_sphere, (GLenum) GLU_FILL);
117 | gluSphere(glu_sphere, radius, 32, 32);
118 | glPopMatrix();
119 | }
120 |
121 |
122 |
123 | void R3Sphere::
124 | Outline(void) const
125 | {
126 | // Draw sphere in wireframe
127 | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
128 | Draw();
129 | glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
130 | }
131 |
132 |
133 |
134 | void R3Sphere::
135 | Print(FILE *fp) const
136 | {
137 | // Print min and max points
138 | fprintf(fp, "(%g %g %g) %g", center[0], center[1], center[2], radius);
139 | }
140 |
141 |
--------------------------------------------------------------------------------
/src/R3Chunk.h:
--------------------------------------------------------------------------------
1 | #ifndef __CHUNK_H__
2 | #define __CHUNK_H__
3 |
4 | #include "R3/R3.h"
5 | #include "strings.h"
6 |
7 | #include
8 |
9 |
10 | #define R3Rgb R2Pixel
11 |
12 | #define CHUNK_Z 16
13 | #define CHUNK_X 16
14 | #define CHUNK_Y 16
15 |
16 | using namespace std;
17 |
18 | typedef enum {
19 | R3_BOX_SHAPE,
20 | R3_SPHERE_SHAPE,
21 | R3_CYLINDER_SHAPE,
22 | R3_CONE_SHAPE,
23 | R3_MESH_SHAPE,
24 | R3_SEGMENT_SHAPE,
25 | R3_BLOCK_SHAPE,
26 | R3_NUM_SHAPE_TYPES,
27 | } R3ShapeType;
28 |
29 | typedef enum {
30 | R3_DIRECTIONAL_LIGHT,
31 | R3_POINT_LIGHT,
32 | R3_SPOT_LIGHT,
33 | R3_AREA_LIGHT,
34 | R3_NUM_LIGHT_TYPES
35 | } R3LightType;
36 |
37 |
38 | // Scene element definitions
39 |
40 | struct R3Shape {
41 | R3ShapeType type;
42 | R3Box *box;
43 | R3Sphere *sphere;
44 | R3Cylinder *cylinder;
45 | R3Cone *cone;
46 | R3Mesh *mesh;
47 | R3Segment *segment;
48 | R3Block *block;
49 | };
50 |
51 | struct R3Material {
52 | R3Rgb ka;
53 | R3Rgb kd;
54 | R3Rgb ks;
55 | R3Rgb kt;
56 | R3Rgb emission;
57 | double shininess;
58 | double indexofrefraction;
59 | R2Image *texture;
60 | int texture_index;
61 | int id;
62 | };
63 |
64 | struct R3Light {
65 | R3LightType type;
66 | R3Point position;
67 | R3Vector direction;
68 | double radius;
69 | R3Rgb color;
70 | double constant_attenuation;
71 | double linear_attenuation;
72 | double quadratic_attenuation;
73 | double angle_attenuation;
74 | double angle_cutoff;
75 | };
76 |
77 | struct R3Camera {
78 | R3Point eye;
79 | R3Vector towards;
80 | R3Vector right;
81 | R3Vector up;
82 | double xfov, yfov;
83 | double neardist, fardist;
84 | };
85 |
86 | struct R3Node {
87 | struct R3Node *parent;
88 | vector children;
89 | R3Shape *shape;
90 | R3Matrix transformation;
91 | R3Material *material;
92 | /* R3Material *material_top;
93 | R3Material *material_sides;*/
94 | R3Box bbox;
95 | bool selected;
96 | };
97 |
98 | struct R3Chunk {
99 | public:
100 | void MakeTree(int types[CHUNK_X][CHUNK_Y][CHUNK_Z], int count);
101 | void GrowTree(int types[CHUNK_X][CHUNK_Y][CHUNK_Z], int x, int z, int y, int recDepth);
102 | void MakeMountain(int types[CHUNK_X][CHUNK_Y][CHUNK_Z], int height);
103 | void GrowMountain(int types[CHUNK_X][CHUNK_Y][CHUNK_Z], int x, int z, int d);
104 | R3Chunk(void);
105 | void DeleteChunk();
106 | int ReadChunk(int xChunkCoord, int zChunkCoord);
107 | int WriteChunk(const char *filename);
108 | int GenerateChunk(int c_x, int c_z);
109 |
110 | public:
111 | // Global (x, y, z) coordinates for start of chunk
112 | R3Point start_point;
113 | // Global (x, y, z) coordinates for end of chunk
114 | R3Point end_point;
115 | // Chunk coordinates of this chunk
116 | int chunk_x;
117 | int chunk_z;
118 | double block_side;
119 | R3Node *chunk[CHUNK_X][CHUNK_Y][CHUNK_Z];
120 | };
121 |
122 | #endif
123 |
--------------------------------------------------------------------------------
/src/GLUT.windows/glut.def:
--------------------------------------------------------------------------------
1 | DESCRIPTION 'OpenGL Utility Toolkit for Win32'
2 |
3 | VERSION 3.7
4 |
5 | EXPORTS
6 |
7 | glutAddMenuEntry
8 | glutAddSubMenu
9 | glutAttachMenu
10 | glutBitmapCharacter
11 | glutBitmapLength
12 | glutBitmapWidth
13 | glutButtonBoxFunc
14 | glutChangeToMenuEntry
15 | glutChangeToSubMenu
16 | glutCopyColormap
17 | glutCreateMenu
18 | __glutCreateMenuWithExit
19 | glutCreateSubWindow
20 | glutCreateWindow
21 | __glutCreateWindowWithExit
22 | glutDestroyMenu
23 | glutDestroyWindow
24 | glutDetachMenu
25 | glutDeviceGet
26 | glutDialsFunc
27 | glutDisplayFunc
28 | glutEnterGameMode
29 | glutEntryFunc
30 | glutEstablishOverlay
31 | glutExtensionSupported
32 | glutForceJoystickFunc
33 | glutFullScreen
34 | glutGameModeGet
35 | glutGameModeString
36 | glutGet
37 | glutGetColor
38 | glutGetMenu
39 | glutGetModifiers
40 | glutGetWindow
41 | glutHideOverlay
42 | glutHideWindow
43 | glutIconifyWindow
44 | glutIdleFunc
45 | glutIgnoreKeyRepeat
46 | glutInit
47 | __glutInitWithExit
48 | glutInitDisplayMode
49 | glutInitDisplayString
50 | glutInitWindowPosition
51 | glutInitWindowSize
52 | glutJoystickFunc
53 | glutKeyboardFunc
54 | glutKeyboardUpFunc
55 | glutLayerGet
56 | glutLeaveGameMode
57 | glutMainLoop
58 | glutMenuStateFunc
59 | glutMenuStatusFunc
60 | glutMotionFunc
61 | glutMouseFunc
62 | glutOverlayDisplayFunc
63 | glutPassiveMotionFunc
64 | glutPopWindow
65 | glutPositionWindow
66 | glutPostOverlayRedisplay
67 | glutPostRedisplay
68 | glutPostWindowOverlayRedisplay
69 | glutPostWindowRedisplay
70 | glutPushWindow
71 | glutRemoveMenuItem
72 | glutRemoveOverlay
73 | glutReportErrors
74 | glutReshapeFunc
75 | glutReshapeWindow
76 | glutSetColor
77 | glutSetCursor
78 | glutSetIconTitle
79 | glutSetKeyRepeat
80 | glutSetMenu
81 | glutSetWindow
82 | glutSetWindowTitle
83 | glutSetupVideoResizing
84 | glutShowOverlay
85 | glutShowWindow
86 | glutSolidCone
87 | glutSolidCube
88 | glutSolidDodecahedron
89 | glutSolidIcosahedron
90 | glutSolidOctahedron
91 | glutSolidSphere
92 | glutSolidTeapot
93 | glutSolidTetrahedron
94 | glutSolidTorus
95 | glutSpaceballButtonFunc
96 | glutSpaceballMotionFunc
97 | glutSpaceballRotateFunc
98 | glutSpecialFunc
99 | glutSpecialUpFunc
100 | glutStopVideoResizing
101 | glutStrokeCharacter
102 | glutStrokeLength
103 | glutStrokeWidth
104 | glutSwapBuffers
105 | glutTabletButtonFunc
106 | glutTabletMotionFunc
107 | glutTimerFunc
108 | glutUseLayer
109 | glutVideoPan
110 | glutVideoResize
111 | glutVideoResizeGet
112 | glutVisibilityFunc
113 | glutWarpPointer
114 | glutWindowStatusFunc
115 | glutWireCone
116 | glutWireCube
117 | glutWireDodecahedron
118 | glutWireIcosahedron
119 | glutWireOctahedron
120 | glutWireSphere
121 | glutWireTeapot
122 | glutWireTetrahedron
123 | glutWireTorus
124 | ; __glutSetFCB
125 | ; __glutGetFCB
126 |
127 |
--------------------------------------------------------------------------------
/src/jpeg/wrjpgcom.1:
--------------------------------------------------------------------------------
1 | .TH WRJPGCOM 1 "15 June 1995"
2 | .SH NAME
3 | wrjpgcom \- insert text comments into a JPEG file
4 | .SH SYNOPSIS
5 | .B wrjpgcom
6 | [
7 | .B \-replace
8 | ]
9 | [
10 | .BI \-comment " text"
11 | ]
12 | [
13 | .BI \-cfile " name"
14 | ]
15 | [
16 | .I filename
17 | ]
18 | .LP
19 | .SH DESCRIPTION
20 | .LP
21 | .B wrjpgcom
22 | reads the named JPEG/JFIF file, or the standard input if no file is named,
23 | and generates a new JPEG/JFIF file on standard output. A comment block is
24 | added to the file.
25 | .PP
26 | The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file.
27 | Although the standard doesn't actually define what COM blocks are for, they
28 | are widely used to hold user-supplied text strings. This lets you add
29 | annotations, titles, index terms, etc to your JPEG files, and later retrieve
30 | them as text. COM blocks do not interfere with the image stored in the JPEG
31 | file. The maximum size of a COM block is 64K, but you can have as many of
32 | them as you like in one JPEG file.
33 | .PP
34 | .B wrjpgcom
35 | adds a COM block, containing text you provide, to a JPEG file.
36 | Ordinarily, the COM block is added after any existing COM blocks; but you
37 | can delete the old COM blocks if you wish.
38 | .SH OPTIONS
39 | Switch names may be abbreviated, and are not case sensitive.
40 | .TP
41 | .B \-replace
42 | Delete any existing COM blocks from the file.
43 | .TP
44 | .BI \-comment " text"
45 | Supply text for new COM block on command line.
46 | .TP
47 | .BI \-cfile " name"
48 | Read text for new COM block from named file.
49 | .PP
50 | If you have only one line of comment text to add, you can provide it on the
51 | command line with
52 | .BR \-comment .
53 | The comment text must be surrounded with quotes so that it is treated as a
54 | single argument. Longer comments can be read from a text file.
55 | .PP
56 | If you give neither
57 | .B \-comment
58 | nor
59 | .BR \-cfile ,
60 | then
61 | .B wrjpgcom
62 | will read the comment text from standard input. (In this case an input image
63 | file name MUST be supplied, so that the source JPEG file comes from somewhere
64 | else.) You can enter multiple lines, up to 64KB worth. Type an end-of-file
65 | indicator (usually control-D) to terminate the comment text entry.
66 | .PP
67 | .B wrjpgcom
68 | will not add a COM block if the provided comment string is empty. Therefore
69 | \fB\-replace \-comment ""\fR can be used to delete all COM blocks from a file.
70 | .SH EXAMPLES
71 | .LP
72 | Add a short comment to in.jpg, producing out.jpg:
73 | .IP
74 | .B wrjpgcom \-c
75 | \fI"View of my back yard" in.jpg
76 | .B >
77 | .I out.jpg
78 | .PP
79 | Attach a long comment previously stored in comment.txt:
80 | .IP
81 | .B wrjpgcom
82 | .I in.jpg
83 | .B <
84 | .I comment.txt
85 | .B >
86 | .I out.jpg
87 | .PP
88 | or equivalently
89 | .IP
90 | .B wrjpgcom
91 | .B -cfile
92 | .I comment.txt
93 | .B <
94 | .I in.jpg
95 | .B >
96 | .I out.jpg
97 | .SH SEE ALSO
98 | .BR cjpeg (1),
99 | .BR djpeg (1),
100 | .BR jpegtran (1),
101 | .BR rdjpgcom (1)
102 | .SH AUTHOR
103 | Independent JPEG Group
104 |
--------------------------------------------------------------------------------
/src/jpeg/jmemnobs.c:
--------------------------------------------------------------------------------
1 | /*
2 | * jmemnobs.c
3 | *
4 | * Copyright (C) 1992-1996, Thomas G. Lane.
5 | * This file is part of the Independent JPEG Group's software.
6 | * For conditions of distribution and use, see the accompanying README file.
7 | *
8 | * This file provides a really simple implementation of the system-
9 | * dependent portion of the JPEG memory manager. This implementation
10 | * assumes that no backing-store files are needed: all required space
11 | * can be obtained from malloc().
12 | * This is very portable in the sense that it'll compile on almost anything,
13 | * but you'd better have lots of main memory (or virtual memory) if you want
14 | * to process big images.
15 | * Note that the max_memory_to_use option is ignored by this implementation.
16 | */
17 |
18 | #define JPEG_INTERNALS
19 | #include "jinclude.h"
20 | #include "jpeglib.h"
21 | #include "jmemsys.h" /* import the system-dependent declarations */
22 |
23 | #ifndef HAVE_STDLIB_H /* should declare malloc(),free() */
24 | extern void * malloc JPP((size_t size));
25 | extern void free JPP((void *ptr));
26 | #endif
27 |
28 |
29 | /*
30 | * Memory allocation and freeing are controlled by the regular library
31 | * routines malloc() and free().
32 | */
33 |
34 | GLOBAL(void *)
35 | jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)
36 | {
37 | return (void *) malloc(sizeofobject);
38 | }
39 |
40 | GLOBAL(void)
41 | jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)
42 | {
43 | free(object);
44 | }
45 |
46 |
47 | /*
48 | * "Large" objects are treated the same as "small" ones.
49 | * NB: although we include FAR keywords in the routine declarations,
50 | * this file won't actually work in 80x86 small/medium model; at least,
51 | * you probably won't be able to process useful-size images in only 64KB.
52 | */
53 |
54 | GLOBAL(void FAR *)
55 | jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
56 | {
57 | return (void FAR *) malloc(sizeofobject);
58 | }
59 |
60 | GLOBAL(void)
61 | jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)
62 | {
63 | free(object);
64 | }
65 |
66 |
67 | /*
68 | * This routine computes the total memory space available for allocation.
69 | * Here we always say, "we got all you want bud!"
70 | */
71 |
72 | GLOBAL(long)
73 | jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,
74 | long max_bytes_needed, long already_allocated)
75 | {
76 | return max_bytes_needed;
77 | }
78 |
79 |
80 | /*
81 | * Backing store (temporary file) management.
82 | * Since jpeg_mem_available always promised the moon,
83 | * this should never be called and we can just error out.
84 | */
85 |
86 | GLOBAL(void)
87 | jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,
88 | long total_bytes_needed)
89 | {
90 | ERREXIT(cinfo, JERR_NO_BACKING_STORE);
91 | }
92 |
93 |
94 | /*
95 | * These routines take care of any system-dependent initialization and
96 | * cleanup required. Here, there isn't any.
97 | */
98 |
99 | GLOBAL(long)
100 | jpeg_mem_init (j_common_ptr cinfo)
101 | {
102 | return 0; /* just set max_memory_to_use to 0 */
103 | }
104 |
105 | GLOBAL(void)
106 | jpeg_mem_term (j_common_ptr cinfo)
107 | {
108 | /* no work */
109 | }
110 |
--------------------------------------------------------------------------------
/src/R2/R2Segment.cpp:
--------------------------------------------------------------------------------
1 | // Source file for the R2 segment class
2 |
3 |
4 |
5 | // Include files
6 |
7 | #include "R2.h"
8 |
9 |
10 |
11 | R2Segment::
12 | R2Segment(void)
13 | {
14 | }
15 |
16 |
17 |
18 | R2Segment::
19 | R2Segment(const R2Segment& segment)
20 | : line(segment.line),
21 | length(segment.length)
22 | {
23 | points[0] = segment.points[0];
24 | points[1] = segment.points[1];
25 | }
26 |
27 |
28 |
29 | R2Segment::
30 | R2Segment(const R2Point& point, const R2Vector& vector)
31 | {
32 | Reset(point, point + vector);
33 | }
34 |
35 |
36 |
37 | R2Segment::
38 | R2Segment(const R2Point& point1, const R2Point& point2)
39 | {
40 | Reset(point1, point2);
41 | }
42 |
43 |
44 |
45 | R2Segment::
46 | R2Segment(double x1, double y1, double x2, double y2)
47 | {
48 | Reset(R2Point(x1,y1), R2Point(x2,y2));
49 | }
50 |
51 |
52 |
53 | void R2Segment::
54 | Project(const R2Line& projection_line)
55 | {
56 | // Project segment onto line
57 | points[0].Project(projection_line);
58 | points[1].Project(projection_line);
59 | R2Vector v(points[1] - points[0]);
60 | length = v.Length();
61 | if (length > 0) v /= length;
62 | line.Reset(points[0], v, true);
63 | }
64 |
65 |
66 |
67 | void R2Segment::
68 | Flip(void)
69 | {
70 | // Flip direction of segment
71 | R2Point swap = points[0];
72 | points[0] = points[1];
73 | points[1] = swap;
74 | line.Flip();
75 | }
76 |
77 |
78 |
79 | void R2Segment::
80 | Mirror(const R2Line& mirror_line)
81 | {
82 | // Mirror segment over line
83 | points[0].Mirror(mirror_line);
84 | points[1].Mirror(mirror_line);
85 | line.Mirror(mirror_line);
86 | }
87 |
88 |
89 |
90 | void R2Segment::
91 | Translate(const R2Vector& vector)
92 | {
93 | // Translate segment
94 | points[0].Translate(vector);
95 | points[1].Translate(vector);
96 | line.Translate(vector);
97 | }
98 |
99 |
100 |
101 | void R2Segment::
102 | Rotate(const R2Point& origin, double angle)
103 | {
104 | // Rotate segment around specified origin counterclockwise by angle
105 | points[0].Rotate(origin, angle);
106 | points[1].Rotate(origin, angle);
107 | Reset(points[0], points[1]);
108 | }
109 |
110 |
111 |
112 | void R2Segment::
113 | Reset(const R2Point& point1, const R2Point& point2)
114 | {
115 | // Reset segment
116 | points[0] = point1;
117 | points[1] = point2;
118 | R2Vector v(points[1] - points[0]);
119 | length = v.Length();
120 | if (length > 0) v /= length;
121 | line.Reset(points[0], v, true);
122 | }
123 |
124 |
125 |
126 | void R2Segment::
127 | SetPoint(const R2Point& point, int k)
128 | {
129 | // Reset segment
130 | points[k] = point;
131 | R2Vector v(points[1] - points[0]);
132 | length = v.Length();
133 | if (length > 0) v /= length;
134 | line.Reset(points[0], v, true);
135 | }
136 |
137 |
138 |
139 | R2Segment R2Segment::
140 | operator-(void)
141 | {
142 | // Return segment with flipped orientation
143 | return R2Segment(End(), Start());
144 | }
145 |
146 |
147 |
148 | void R2Segment::
149 | Print(FILE *fp) const
150 | {
151 | // Print segment endpoints
152 | points[0].Print(fp);
153 | fprintf(fp, " ");
154 | points[1].Print(fp);
155 | }
156 |
--------------------------------------------------------------------------------
/src/utils.cpp:
--------------------------------------------------------------------------------
1 | #include "utils.h"
2 |
3 | int GLUTwindow = 0;
4 | int GLUTwindow_height = 512;
5 | int GLUTwindow_width = 512;
6 | double GLUTaspect = 1.;
7 |
8 | double RandomNumber(void)
9 | {
10 | // Windows
11 | #ifdef _WIN32
12 |
13 | // Seed random number generator
14 | static int first = 1;
15 |
16 | if (first)
17 | {
18 | srand(GetTickCount());
19 | first = 0;
20 | }
21 |
22 | // Return random number
23 | int r1 = rand();
24 | double r2 = ((double) rand()) / ((double) RAND_MAX);
25 | return (r1 + r2) / ((double) RAND_MAX);
26 |
27 | // Mac OS and Linux
28 | #else
29 |
30 | // Seed random number generator
31 | static int first = 1;
32 |
33 | if (first)
34 | {
35 | struct timeval timevalue;
36 | gettimeofday(&timevalue, 0);
37 | srand48(timevalue.tv_usec);
38 | first = 0;
39 | }
40 |
41 | // Return random number
42 | return drand48();
43 |
44 | #endif
45 | }
46 |
47 | double GetTime(void)
48 | {
49 | // Windows
50 | #ifdef _WIN32
51 |
52 | // Return number of seconds since start of execution
53 | static int first = 1;
54 | static LARGE_INTEGER timefreq;
55 | static LARGE_INTEGER start_timevalue;
56 |
57 | // Check if this is the first time
58 | if (first)
59 | {
60 | // Initialize first time
61 | QueryPerformanceFrequency(&timefreq);
62 | QueryPerformanceCounter(&start_timevalue);
63 | first = 0;
64 | return 0;
65 | }
66 | else
67 | {
68 | // Return time since start
69 | LARGE_INTEGER current_timevalue;
70 | QueryPerformanceCounter(¤t_timevalue);
71 | return ((double) current_timevalue.QuadPart -
72 | (double) start_timevalue.QuadPart) / (double) timefreq.QuadPart;
73 | }
74 |
75 | // Linux or Mac OS
76 | #else
77 | // Return number of seconds since start of execution
78 | static int first = 1;
79 | static struct timeval start_timevalue;
80 |
81 | // Check if this is the first time
82 | if (first)
83 | {
84 | // Initialize first time
85 | gettimeofday(&start_timevalue, NULL);
86 | first = 0;
87 | return 0;
88 | }
89 | else
90 | {
91 | // Return time since start
92 | struct timeval current_timevalue;
93 | gettimeofday(¤t_timevalue, NULL);
94 | int secs = current_timevalue.tv_sec - start_timevalue.tv_sec;
95 | int usecs = current_timevalue.tv_usec - start_timevalue.tv_usec;
96 | return (double) (secs + 1.0E-6F * usecs);
97 | }
98 |
99 | #endif
100 | }
101 |
102 | void LoadMatrix(R3Matrix *matrix)
103 | {
104 | // Multiply matrix by top of stack
105 | // Take transpose of matrix because OpenGL represents vectors with
106 | // column-vectors and R3 represents them with row-vectors
107 | R3Matrix m = matrix->Transpose();
108 | glMultMatrixd((double *) &m);
109 | }
110 |
111 | void GLUTDrawText(const R3Point& p, const char *s)
112 | {
113 | // Draw text string s and position p
114 | glRasterPos3d(p[0], p[1], p[2]);
115 | #ifndef __CYGWIN__
116 | while (*s) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, *(s++));
117 | #else
118 | while (*s) glutBitmapCharacter((void*)7, *(s++));
119 | #endif
120 | }
121 |
122 | void GLUTDrawTitle(const R3Point& p, const char *s)
123 | {
124 | // Draw text string s and position p
125 | glRasterPos3d(p[0], p[1], p[2]);
126 | #ifndef __CYGWIN__
127 | while (*s) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, *(s++));
128 | #else
129 | while (*s) glutBitmapCharacter((void*)7, *(s++));
130 | #endif
131 | }
132 |
--------------------------------------------------------------------------------
/src/R3/R3Cone.cpp:
--------------------------------------------------------------------------------
1 | // Source file for the R3 cone class
2 |
3 |
4 |
5 | // Include files
6 |
7 | #include "R3.h"
8 |
9 |
10 |
11 | // Public variables
12 |
13 | const R3Cone R3null_cone(R3Point(0.0, 0.0, 0.0), 0, 0);
14 | const R3Cone R3zero_cone(R3Point(0.0, 0.0, 0.0), 0, 0);
15 | const R3Cone R3unit_cone(R3Point(0.0, 0.5, 0.0), 1, 1);
16 |
17 |
18 |
19 | R3Cone::
20 | R3Cone(void)
21 | {
22 | }
23 |
24 |
25 |
26 | R3Cone::
27 | R3Cone(const R3Cone& cone)
28 | : center(cone.center),
29 | radius(cone.radius),
30 | height(cone.height)
31 | {
32 | }
33 |
34 |
35 |
36 | R3Cone::
37 | R3Cone(const R3Point& center, double radius, double height)
38 | : center(center),
39 | radius(radius),
40 | height(height)
41 | {
42 | }
43 |
44 |
45 |
46 | double R3Cone::
47 | Area(void) const
48 | {
49 | // Return surface area of cone
50 | double s = sqrt((Height() * Height()) + (Radius() * Radius()));
51 | return (M_PI * Radius() * (Radius() + s));
52 | }
53 |
54 |
55 |
56 | double R3Cone::
57 | Volume(void) const
58 | {
59 | // Return volume of cone
60 | return (0.33333333 * M_PI * Radius() * Radius() * Height());
61 | }
62 |
63 |
64 |
65 | R3Box R3Cone::
66 | BBox(void) const
67 | {
68 | // Return bounding box of cone
69 | R3Box bbox(R3null_box);
70 | bbox.Union(center + 0.5 * height * R3negy_vector + radius * R3negx_vector + radius * R3negz_vector);
71 | bbox.Union(center + 0.5 * height * R3posy_vector + radius * R3posx_vector + radius * R3posz_vector);
72 | return bbox;
73 | }
74 |
75 |
76 |
77 | void R3Cone::
78 | Empty(void)
79 | {
80 | // Empty cone
81 | *this = R3null_cone;
82 | }
83 |
84 |
85 | void R3Cone::
86 | Translate(const R3Vector& vector)
87 | {
88 | // Move cone
89 | center.Translate(vector);
90 | }
91 |
92 |
93 |
94 | void R3Cone::
95 | Reposition(const R3Point& center)
96 | {
97 | // Set cone center
98 | this->center = center;
99 | }
100 |
101 |
102 |
103 | void R3Cone::
104 | Resize(double radius, double height)
105 | {
106 | // Set cone radius
107 | this->radius = radius;
108 | this->height = height;
109 | }
110 |
111 |
112 |
113 | void R3Cone::
114 | Draw(void) const
115 | {
116 | // Draw cone
117 | glPushMatrix();
118 | glTranslated(center[0], center[1], center[2]);
119 | glRotated(-90, 1, 0, 0);
120 | glTranslated(0, 0, -0.5 * height);
121 | static GLUquadricObj *glu_cone = gluNewQuadric();
122 | gluQuadricTexture(glu_cone, GL_TRUE);
123 | gluQuadricNormals(glu_cone, (GLenum) GLU_SMOOTH);
124 | gluQuadricDrawStyle(glu_cone, (GLenum) GLU_FILL);
125 | gluQuadricOrientation(glu_cone, (GLenum) GLU_OUTSIDE);
126 | gluCylinder(glu_cone, radius, 0, height, 32, 8);
127 | gluQuadricOrientation(glu_cone, (GLenum) GLU_INSIDE);
128 | gluDisk(glu_cone, 0, radius, 32, 8);
129 | glPopMatrix();
130 | }
131 |
132 |
133 |
134 | void R3Cone::
135 | Outline(void) const
136 | {
137 | // Draw cone in wireframe
138 | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
139 | Draw();
140 | glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
141 | }
142 |
143 |
144 |
145 | void R3Cone::
146 | Print(FILE *fp) const
147 | {
148 | // Print min and max points
149 | fprintf(fp, "(%g %g %g) %g %g", center[0], center[1], center[2], radius, height);
150 | }
151 |
152 |
153 |
--------------------------------------------------------------------------------
/src/jpeg/jinclude.h:
--------------------------------------------------------------------------------
1 | /*
2 | * jinclude.h
3 | *
4 | * Copyright (C) 1991-1994, Thomas G. Lane.
5 | * This file is part of the Independent JPEG Group's software.
6 | * For conditions of distribution and use, see the accompanying README file.
7 | *
8 | * This file exists to provide a single place to fix any problems with
9 | * including the wrong system include files. (Common problems are taken
10 | * care of by the standard jconfig symbols, but on really weird systems
11 | * you may have to edit this file.)
12 | *
13 | * NOTE: this file is NOT intended to be included by applications using the
14 | * JPEG library. Most applications need only include jpeglib.h.
15 | */
16 |
17 |
18 | /* Include auto-config file to find out which system include files we need. */
19 |
20 | #include "jconfig.h" /* auto configuration options */
21 | #define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */
22 |
23 | /*
24 | * We need the NULL macro and size_t typedef.
25 | * On an ANSI-conforming system it is sufficient to include .
26 | * Otherwise, we get them from or ; we may have to
27 | * pull in as well.
28 | * Note that the core JPEG library does not require ;
29 | * only the default error handler and data source/destination modules do.
30 | * But we must pull it in because of the references to FILE in jpeglib.h.
31 | * You can remove those references if you want to compile without .
32 | */
33 |
34 | #ifdef HAVE_STDDEF_H
35 | #include
36 | #endif
37 |
38 | #ifdef HAVE_STDLIB_H
39 | #include
40 | #endif
41 |
42 | #ifdef NEED_SYS_TYPES_H
43 | #include
44 | #endif
45 |
46 | #include
47 |
48 | /*
49 | * We need memory copying and zeroing functions, plus strncpy().
50 | * ANSI and System V implementations declare these in .
51 | * BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
52 | * Some systems may declare memset and memcpy in .
53 | *
54 | * NOTE: we assume the size parameters to these functions are of type size_t.
55 | * Change the casts in these macros if not!
56 | */
57 |
58 | #ifdef NEED_BSD_STRINGS
59 |
60 | #include
61 | #define MEMZERO(target,size) bzero((void *)(target), (size_t)(size))
62 | #define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size))
63 |
64 | #else /* not BSD, assume ANSI/SysV string lib */
65 |
66 | #include
67 | #define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size))
68 | #define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size))
69 |
70 | #endif
71 |
72 | /*
73 | * In ANSI C, and indeed any rational implementation, size_t is also the
74 | * type returned by sizeof(). However, it seems there are some irrational
75 | * implementations out there, in which sizeof() returns an int even though
76 | * size_t is defined as long or unsigned long. To ensure consistent results
77 | * we always use this SIZEOF() macro in place of using sizeof() directly.
78 | */
79 |
80 | #define SIZEOF(object) ((size_t) sizeof(object))
81 |
82 | /*
83 | * The modules that use fread() and fwrite() always invoke them through
84 | * these macros. On some systems you may need to twiddle the argument casts.
85 | * CAUTION: argument order is different from underlying functions!
86 | */
87 |
88 | #define JFREAD(file,buf,sizeofbuf) \
89 | ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
90 | #define JFWRITE(file,buf,sizeofbuf) \
91 | ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
92 |
--------------------------------------------------------------------------------
/src/jpeg/jcomapi.c:
--------------------------------------------------------------------------------
1 | /*
2 | * jcomapi.c
3 | *
4 | * Copyright (C) 1994-1997, Thomas G. Lane.
5 | * This file is part of the Independent JPEG Group's software.
6 | * For conditions of distribution and use, see the accompanying README file.
7 | *
8 | * This file contains application interface routines that are used for both
9 | * compression and decompression.
10 | */
11 |
12 | #define JPEG_INTERNALS
13 | #include "jinclude.h"
14 | #include "jpeglib.h"
15 |
16 |
17 | /*
18 | * Abort processing of a JPEG compression or decompression operation,
19 | * but don't destroy the object itself.
20 | *
21 | * For this, we merely clean up all the nonpermanent memory pools.
22 | * Note that temp files (virtual arrays) are not allowed to belong to
23 | * the permanent pool, so we will be able to close all temp files here.
24 | * Closing a data source or destination, if necessary, is the application's
25 | * responsibility.
26 | */
27 |
28 | GLOBAL(void)
29 | jpeg_abort (j_common_ptr cinfo)
30 | {
31 | int pool;
32 |
33 | /* Do nothing if called on a not-initialized or destroyed JPEG object. */
34 | if (cinfo->mem == NULL)
35 | return;
36 |
37 | /* Releasing pools in reverse order might help avoid fragmentation
38 | * with some (brain-damaged) malloc libraries.
39 | */
40 | for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) {
41 | (*cinfo->mem->free_pool) (cinfo, pool);
42 | }
43 |
44 | /* Reset overall state for possible reuse of object */
45 | if (cinfo->is_decompressor) {
46 | cinfo->global_state = DSTATE_START;
47 | /* Try to keep application from accessing now-deleted marker list.
48 | * A bit kludgy to do it here, but this is the most central place.
49 | */
50 | ((j_decompress_ptr) cinfo)->marker_list = NULL;
51 | } else {
52 | cinfo->global_state = CSTATE_START;
53 | }
54 | }
55 |
56 |
57 | /*
58 | * Destruction of a JPEG object.
59 | *
60 | * Everything gets deallocated except the master jpeg_compress_struct itself
61 | * and the error manager struct. Both of these are supplied by the application
62 | * and must be freed, if necessary, by the application. (Often they are on
63 | * the stack and so don't need to be freed anyway.)
64 | * Closing a data source or destination, if necessary, is the application's
65 | * responsibility.
66 | */
67 |
68 | GLOBAL(void)
69 | jpeg_destroy (j_common_ptr cinfo)
70 | {
71 | /* We need only tell the memory manager to release everything. */
72 | /* NB: mem pointer is NULL if memory mgr failed to initialize. */
73 | if (cinfo->mem != NULL)
74 | (*cinfo->mem->self_destruct) (cinfo);
75 | cinfo->mem = NULL; /* be safe if jpeg_destroy is called twice */
76 | cinfo->global_state = 0; /* mark it destroyed */
77 | }
78 |
79 |
80 | /*
81 | * Convenience routines for allocating quantization and Huffman tables.
82 | * (Would jutils.c be a more reasonable place to put these?)
83 | */
84 |
85 | GLOBAL(JQUANT_TBL *)
86 | jpeg_alloc_quant_table (j_common_ptr cinfo)
87 | {
88 | JQUANT_TBL *tbl;
89 |
90 | tbl = (JQUANT_TBL *)
91 | (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL));
92 | tbl->sent_table = FALSE; /* make sure this is false in any new table */
93 | return tbl;
94 | }
95 |
96 |
97 | GLOBAL(JHUFF_TBL *)
98 | jpeg_alloc_huff_table (j_common_ptr cinfo)
99 | {
100 | JHUFF_TBL *tbl;
101 |
102 | tbl = (JHUFF_TBL *)
103 | (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL));
104 | tbl->sent_table = FALSE; /* make sure this is false in any new table */
105 | return tbl;
106 | }
107 |
--------------------------------------------------------------------------------
/src/R2/R2Line.h:
--------------------------------------------------------------------------------
1 | // Include file for the R2 line class
2 |
3 |
4 |
5 | // Class definition
6 |
7 | class R2Line {
8 | public:
9 | // Constructor functions
10 | R2Line(void);
11 | R2Line(const R2Line& line);
12 | R2Line(double a, double b, double c);
13 | R2Line(double array[3]);
14 | R2Line(const R2Point& point, const R2Vector& vector, bool normalized = false);
15 | R2Line(const R2Point& point1, const R2Point& point2);
16 | R2Line(double x1, double y1, double x2, double y2);
17 |
18 | // Property functions/operators
19 | double A(void) const;
20 | double B(void) const;
21 | double C(void) const;
22 | R2Point AnyPoint(void) const;
23 | R2Point ClosestPoint(const R2Point& point) const;
24 | R2Vector Vector(void) const;
25 | R2Vector Normal(void) const;
26 | bool operator==(const R2Line& line) const;
27 | bool operator!=(const R2Line& line) const;
28 |
29 | // Manipulation functions/operators
30 | void Flip(void);
31 | void Mirror(const R2Line& line);
32 | void Translate(const R2Vector& vector);
33 | void Rotate(const R2Point& origin, double angle);
34 | void Reset(const R2Point& point, const R2Vector& vector, bool normalized = false);
35 | R2Line& operator=(const R2Line& line);
36 |
37 | // Arithmetic functions/operators
38 | R2Line operator-(void);
39 |
40 | // Output functions
41 | void Print(FILE *fp = stdout) const;
42 |
43 | private:
44 | R2Vector vector;
45 | R2Vector normal;
46 | double c;
47 | };
48 |
49 |
50 |
51 | // Public variables
52 |
53 | extern R2Line R2null_line;
54 | extern R2Line R2posx_line;
55 | extern R2Line R2posy_line;
56 | extern R2Line R2negx_line;
57 | extern R2Line R2negy_line;
58 | #define R2xaxis_line R2posx_line
59 | #define R2yaxis_line R2posy_line
60 |
61 |
62 |
63 | // Inline functions
64 |
65 | inline double R2Line::
66 | A(void) const
67 | {
68 | // Return A coefficient of AX+BY+C=0
69 | return normal.X();
70 | }
71 |
72 |
73 |
74 | inline double R2Line::
75 | B(void) const
76 | {
77 | // Return B coefficient of AX+BY+C=0
78 | return normal.Y();
79 | }
80 |
81 |
82 |
83 | inline double R2Line::
84 | C(void) const
85 | {
86 | // Return C coefficient of AX+BY+C=0
87 | return c;
88 | }
89 |
90 |
91 |
92 | inline R2Point R2Line::
93 | AnyPoint(void) const
94 | {
95 | // Return point on line
96 | return R2zero_point + normal * -c;
97 | }
98 |
99 |
100 |
101 | inline R2Point R2Line::
102 | ClosestPoint(const R2Point& point) const
103 | {
104 | // Return point on line closest to given point
105 | double d = A()*point[0] + B()*point[1] + C();
106 | return point - d * normal;
107 | }
108 |
109 |
110 |
111 | inline R2Vector R2Line::
112 | Vector(void) const
113 | {
114 | // Return direction vector of line
115 | return vector;
116 | }
117 |
118 |
119 |
120 | inline R2Vector R2Line::
121 | Normal(void) const
122 | {
123 | // Return normal vector of line
124 | // This vector is counterclockwise by 90 degrees with respect to direction vector
125 | return normal;
126 | }
127 |
128 |
129 |
130 | inline bool R2Line::
131 | operator==(const R2Line& line) const
132 | {
133 | // Return whether line is same
134 | if (normal != line.normal) return false;
135 | if (c != line.c) return false;
136 | return true;
137 | }
138 |
139 |
140 |
141 | inline bool R2Line::
142 | operator!=(const R2Line& line) const
143 | {
144 | // Return whether line is not equal
145 | return (!(*this == line));
146 | }
147 |
148 |
149 |
150 |
--------------------------------------------------------------------------------
/src/R3/R3Cylinder.cpp:
--------------------------------------------------------------------------------
1 | // Source file for the R3 cylinder class
2 |
3 |
4 |
5 | // Include files
6 |
7 | #include "R3.h"
8 |
9 |
10 |
11 | // Public variables
12 |
13 | const R3Cylinder R3null_cylinder(R3Point(0.0, 0.0, 0.0), 0, 0);
14 | const R3Cylinder R3zero_cylinder(R3Point(0.0, 0.0, 0.0), 0, 0);
15 | const R3Cylinder R3unit_cylinder(R3Point(0.0, 0.5, 0.0), 1, 1);
16 |
17 |
18 |
19 | R3Cylinder::
20 | R3Cylinder(void)
21 | {
22 | }
23 |
24 |
25 |
26 | R3Cylinder::
27 | R3Cylinder(const R3Cylinder& cylinder)
28 | : center(cylinder.center),
29 | radius(cylinder.radius),
30 | height(cylinder.height)
31 | {
32 | }
33 |
34 |
35 |
36 | R3Cylinder::
37 | R3Cylinder(const R3Point& center, double radius, double height)
38 | : center(center),
39 | radius(radius),
40 | height(height)
41 | {
42 | }
43 |
44 |
45 |
46 | double R3Cylinder::
47 | Area(void) const
48 | {
49 | // Return surface area of cylinder
50 | return (2.0 * M_PI * Radius() * (Radius() + Height()));
51 | }
52 |
53 |
54 |
55 | double R3Cylinder::
56 | Volume(void) const
57 | {
58 | // Return volume of cylinder
59 | return (M_PI * Radius() * Radius() * Height());
60 | }
61 |
62 |
63 |
64 | R3Box R3Cylinder::
65 | BBox(void) const
66 | {
67 | // Return bounding box of cylinder
68 | R3Box bbox(R3null_box);
69 | bbox.Union(center + 0.5 * height * R3negy_vector + radius * R3negx_vector + radius * R3negz_vector);
70 | bbox.Union(center + 0.5 * height * R3posy_vector + radius * R3posx_vector + radius * R3posz_vector);
71 | return bbox;
72 | }
73 |
74 |
75 |
76 | void R3Cylinder::
77 | Empty(void)
78 | {
79 | // Empty cylinder
80 | *this = R3null_cylinder;
81 | }
82 |
83 |
84 | void R3Cylinder::
85 | Translate(const R3Vector& vector)
86 | {
87 | // Move cylinder
88 | center.Translate(vector);
89 | }
90 |
91 |
92 |
93 | void R3Cylinder::
94 | Reposition(const R3Point& center)
95 | {
96 | // Set cylinder center
97 | this->center = center;
98 | }
99 |
100 |
101 |
102 | void R3Cylinder::
103 | Resize(double radius, double height)
104 | {
105 | // Set cylinder radius
106 | this->radius = radius;
107 | this->height = height;
108 | }
109 |
110 |
111 |
112 |
113 | void R3Cylinder::
114 | Draw(void) const
115 | {
116 | // Draw cylinder
117 | glPushMatrix();
118 | glTranslated(center[0], center[1], center[2]);
119 | glRotated(-90, 1, 0, 0);
120 | glTranslated(0, 0, -0.5 * height);
121 | static GLUquadricObj *glu_cylinder = gluNewQuadric();
122 | gluQuadricTexture(glu_cylinder, GL_TRUE);
123 | gluQuadricNormals(glu_cylinder, (GLenum) GLU_SMOOTH);
124 | gluQuadricDrawStyle(glu_cylinder, (GLenum) GLU_FILL);
125 | gluQuadricOrientation(glu_cylinder, (GLenum) GLU_OUTSIDE);
126 | gluCylinder(glu_cylinder, radius, radius, height, 32, 8);
127 | gluQuadricOrientation(glu_cylinder, (GLenum) GLU_INSIDE);
128 | gluDisk(glu_cylinder, 0, radius, 32, 8);
129 | gluQuadricOrientation(glu_cylinder, (GLenum) GLU_OUTSIDE);
130 | glTranslated(0, 0, height);
131 | gluDisk(glu_cylinder, 0, radius, 32, 8);
132 | glPopMatrix();
133 | }
134 |
135 |
136 |
137 | void R3Cylinder::
138 | Outline(void) const
139 | {
140 | // Draw cylinder in wireframe
141 | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
142 | Draw();
143 | glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
144 | }
145 |
146 |
147 |
148 | void R3Cylinder::
149 | Print(FILE *fp) const
150 | {
151 | // Print min and max points
152 | fprintf(fp, "(%g %g %g) %g %g", center[0], center[1], center[2], radius, height);
153 | }
154 |
155 |
156 |
--------------------------------------------------------------------------------
/src/minecraft.h:
--------------------------------------------------------------------------------
1 | #ifndef __MINECRAFT_H__
2 | #define __MINECRAFT_H__
3 |
4 | #include
5 | #include