Courses‎ > ‎Computer Graphics‎ > ‎

Konstantinovich

SUPER IMPORTANT SUBMISSION GUIDELINES
  • You must include a makefile for each assignment!
    • The makefile should invoke whatever is needed to compile and/or run your program. When I type make, I expect to have your program generate an image.
  • Every assignment (unless otherwise noted) will require both a github submission and an image gallery submission. Full credit will require both.
  • All github repos should be named exactly as described. (Except the final project - which must be submitted in a google form)
  • NEVER EVER EVER add image files to github
    • Adding image files will result in deductions
    • You can include a .gitignore if you want to help avoid issues!
  • Gallery submissions should be made here: http://gallery.stuycs.org
sample gitignore:

2019-05-28 Final Projects

posted May 28, 2019, 10:10 AM by Konstantinovich Samuel   [ updated May 31, 2019, 12:07 PM ]

Goal: Final Project  

Can work in groups of at most two people. 
Your purpose is to add new functionality. Priority is new features, not more elegant old features or restructuring the scripting language to be nicer to use.
Due: June 14th. This is a hard deadline because of senior grade deadlines. 

  • Create a GitHub repository for your project.
  • In the README.md file put
    • Your Name(s) at the top
    • Your Team Name
    • List of features you plan to implement.
  • NO LATER THAN 8am Monday morning (6/3)
Submit your group/Repo here:

Possible Final Project Additions: 

MDL Commands:
  • LIGHT
    • Add a light to the symbol table
    • When calculating diffuse and specular: loop through all the lights.
  • MESH
    • Use an external .obj file for polygons
    • Read up on the obj format here.
    • Find example files here.
    • Make sure you deal with .obj files that list quadrilateral faces instead of triangles.

  • SET
    • Assign a value to a knob
  • SAVEKNOBS
    • Save current knob values to a list
  • TWEEN
    • Produce an animation going between two knob lists
  • SHADING
    • Use different shading techniques / calculating I more or less frequently.
    • As discussed in class, a hash table structure can be very helpful for dealing with vertex normals. If you are woking in c, check out uthash
  • SAVE COORDINATE SYSTEM
    • Save a copy of the top of the stack to the symbol table
    • use this coordinate system when drawing shapes (extra argument required)
Additions to MDL that require changes to the language:
  • New primitive shapes
  • Change the behavior of vary
    • add a parameter to change how it calculates the change over time
    • Linear , Exponential, Logarithmic, Arbitrary equation, etc. 
  • Anti-aliasing / Super-sampling 
    • Reduce pixelated edges by calculating a higher resolution version of the image then reducing it to the intended size
  • Texture Mapping
  • Using vary to move the light position / color

2019-05-20 MDL-Animation

posted May 20, 2019, 9:32 AM by Konstantinovich Samuel

Animation! 

New MDL commands to implement:
  • frames 
    • set the number of frames
  • basename 
    • sets the basename for animation file saving
  • vary
    • vary the values for a knob between 2 values in a set range of frames
Animation Features:
  • The key animation commands are frames, basename and vary. You should proceed with animation code in 3 steps:
    • Go through the operations list and look for any of the three animation commands
      • Set frames and basename
      • Handle errors as needed
    • Go through the operations list a second time and look for the vary command
      • Populate a table that has an entry for each frame, and in each frame it has a value for each knob
        • When completed, the table should contain the correctly set values for each knob (perform the varying calculation)
        • In c, there is a struct vary_node defined in parser.h
        • In python, you could use a dictionary/list combination
        • Handle errors as needed
    • Perform the normal interpreting/drawing steps that are currently working, with the following additions if animation code is present. 
      • First, look at the table of knob values (set in the second step) and set each knob in the symbol table to the appropriate value.
      • Run the normal commands
      • At the end of the loop, save the current screen to a file, the file should have the basename followed by a number, so that animate will work correctly. 
        • I suggest you put all the animation frames in a subdirectory, so just append a directory name to the basename when saving files
        • in c, you can pad the beginning of a string with 0's using the following syntax (if x = 12):
          • sprintf (s, "%03d", x ) will set s to the string "012"
          • The 0 indicates that you are padding with 0, and the 3 indicates that if x is less that 3 digits in length the number will be padded with 0
        • python has similar functionality using python formatted strings
          • "%03d"%12  will give you "012"
      • When you are done with each frame loop, don't forget to reset the screen, origin stack and any other pieces of data that are specific to a given frame
  • Once you have all the files created, you can generate the animation using imagemagick's animate and convert commands:
    • animate
      • Will display multiple single image files in succession as a single animation, with a default frame rate of 100 frames per second, by using the -delay option, you can change the fps ( -delay x will set the frame rate to 100/x fps )
        • $ animate -delay 1.7 animations/orb*
      • Convert can, like animate, take a number of frames and animate them, but instead of displaying the animation, it will combine them into a single animated gif file. Note that the only image format that can use animation is gif.
        • $ convert -delay 10 animations/orb* orb.gif will create a single animated gif called orb.gif
    • In python and c, I've included a make_animation function in display.c/py that will generate the animation for you.
github repo:
mks66-animation

2019-05-10 MDL

posted May 10, 2019, 10:50 AM by Konstantinovich Samuel

(MDL actually stands for Motion Description Language)

Before doing anything else, take a look at MDL.spec, it provides important information about the language structure.

There are many commands and features in MDL that we will not be using yet, you should ignore those for now.

Implement the following mdl commands:
  • push
    • push a copy of the current top of the origins stack onto the origins stack (a full copy, not just a reference to the current top)
  • pop
    • removes the top of the origins stack (nothing needs to be done with this data)
  • move/rotate/scale
    • create a translation/rotation/scale matrix and multiply the current top by it
    • do not try to use the optional arguments for these commands
  • box/sphere/torus
    • add a box/sphere/torus to a temporary polygon matrix, multiply it by the current top and draw it to the screen 
    • if a constants variable is present, use those for lighting, otherwise, use a default set.
    • ignore the optional variable at the end of the command.
  • constants
    • you actually don't need to do anything for this command, the semantic analyzer will already create a symbol table entry for the reflective constants.
  • line
    • add a line to a temporary edge matrix, multiply it by the current top and draw it to the screen
    • do not try to use the optional arguments for this command
  • save
    • save the screen to the provided file name
  • display
    • show the image
  • You only need to modify one of the following files (c/python):
    • C
      • my_main.c 
        • look at print_pcode.c, it is an ideal template to follow for my_main.c
      • mdl.y: there is a comment at the very bottom that you will need to check.
    • Python
      • script.py
github repo:
mks66-mdl

2019-05-07

posted May 7, 2019, 10:17 AM by Konstantinovich Samuel   [ updated May 7, 2019, 10:37 AM ]

Goal: Regular Expressions.

[ ]   -  e.g.  [a]  [ab] [acf]
a-z  - e.g. [a-z] [a-zA-Z]
+  
*
?



1. Any of these words:
The quick brown fox jumps over the lazy dog.
Sally saw Sam with binoculars.
Fair  is unfair to sheep.
BUT NOT THESE:
FFool F1sh s_oop sh00p "Fleece"
D4R3 T0 83 5700P1D

2. Any of these numbers:
1        -3
185        -270
9124    -294291

3. Any of these numbers:
-0.3        2.5
-3.89        2891.2
18.            1028000.02820

Any of these identifiers
x                xy3a
x2                x2y2
win4life        the_best
hot_fuzz        D_A_N_G_E_R_1_0_0

Fun with regex:

2019-05-01 Lights but no moving camera or actions.

posted May 1, 2019, 10:15 AM by Konstantinovich Samuel

Due: 8am Monday 5/6

Implement the Phong Reflection model with flat shading. (Note: if you look up information online, do not confuse this with Phong Shading).
  • You should be calculating I once per polygon.
  • Remember to limit I to be in the range [0, 255]. Some of the sub calculations must be restricted to [0,255] so that negative values do not cancel out light.
  • There are a lot of user-defined values in lighting calculation, eventually, we will to be able to set them in our scripts. For now, pass them around to the necessary functions, and set them in either your main/parser functions. This is modeled in the provided source code.
  • Once again, our robot friend is not a great test for lighting, boxes in general are not good since they have very few polygons. 
github repo: mks66-lighting

2019-04-09 ScanLine-ZBuffer

posted Apr 10, 2019, 12:14 PM by Konstantinovich Samuel   [ updated Apr 10, 2019, 12:15 PM ]

Add scanline conversion and z-buffering to your graphics engine.
  • Parser Note:
    • In the previous assignment, I noted that the clear command was no longer needed, because we immediately clear the polygon/edge matrix after a shape is drawn. In order to test Scanline conversion on multiple shapes, a different version of clear is useful. Now, clear will clear the screen and zbuffer, allowing us to reset and test multiple shapes in the same script. 
    • I have added this command to the provided source code, but everyone should implement it.
  • Scanline conversion
    • Create a new function that handles the scanline conversion.
    • Call this in your draw_polygons function.
    • Make sure that you change color values for each triangle.
  • z-buffering
    • In the base files provided, I've added a z-buffer argument to the necessary functions, but have not done anything with it.
    • The z-buffer should only be modified in your plot function, or when clear_zbuffer is called.
    • You will need to calculate z values in both scanline_convert and draw_line.
      • Your z values are not limited to the integers.
GitHub repository:
mks66-solids

2019-04-03 07FatCoordinateStacks

posted Apr 3, 2019, 10:33 AM by Konstantinovich Samuel   [ updated Apr 3, 2019, 10:34 AM ]

Due: 8am Monday, 4/8

07CoordinateStacks

Repo:  MKS66-CoordinateStack


Note: If you are working in c, I have provided a basic stack library that you can use in the 66source repository

To implement a relative coordinate system... system, add/modify your current parser so it has the following behavior
  • push
    • push a copy of the current top of the coordinate system (cs) stack onto the cs stack (a full copy, not just a reference to the current top... I'm looking at you python people)
  • pop
    • removes the top of the cs stack (nothing needs to be done with this data)
  • translate/rotate/scale
    • create a translation/rotation/scale matrix
    • multiply the current top of the cs stack by it
    • The ordering of multiplication is important here.
  • box/sphere/torus
    • add a box/sphere/torus to a temporary polygon matrix
    • multiply it by the current top of the cs stack
    • draw it to the screen
    • clear the polygon matrix 
  • line/curve/circle
    • add a line to a temporary edge matrix
    • multiply it by the current top
    • draw it to the screen (note a line is not a solid, so avoid draw_polygons)
  • save
    • save the screen with the provided file name
  • display
    • show the image
  • Also note that the identapply and clear commands no longer have any use

2019-03-22 PTC

posted Mar 22, 2019, 5:57 AM by Konstantinovich Samuel

PTC

In observance with the longstanding tradition of 'gooning' I now solicit volunteers to be the meatshields between me and the hoards of parents in the upcoming week.

Please send an email to me with the subject line: (depending on which day you can make it)

"PTC Volunteer Spring 2019 Thr"
"PTC Volunteer Spring 2019 Fri"
"PTC Volunteer Spring 2019 Thr Fri"
I will reply This weekend so please send the email sooner rather than later!

Thursday is 5pm-8pm
Friday is 1pm-330pm
I need at least one laptop to help with organization, so please let me know if you normally bring a laptop.

2019-03-21 06Triangles

posted Mar 21, 2019, 6:21 AM by Konstantinovich Samuel

You must do the following things:
  1. Write correct, functioning code.
  2. Submit code that runs the provided testing script
  3. Upload an original picture to the gallery
The Drawing:
  • Create new functions to add a polygon to a matrix, and go through the matrix 3 points at a time to draw triangles.
    • You should have a new triangle matrix that exists alongside the edge matrix. The edge matrix should be used for the shapes that are exclusively 2d (lines, circles, splines), and the triangle matrix for our 3d shapes.
    • Anything aside from shape drawing that modifies/uses the edge matrix (apply, clear, display, save) should now modify/use the triangle matrix as well.
  • Modify add box, add sphere and add torus to add triangles instead of points.
  • Make sure the parser calls the draw_polygons functions when needed instead of draw_lines
  • More to come...

Repo:  MKS66-Triangles

Basefile including the old assignment's parser can be found in the source repo:
https://github.com/mks66/66source

2019-03-15 05ThreeDee

posted Mar 15, 2019, 11:50 AM by Konstantinovich Samuel   [ updated Mar 21, 2019, 6:19 AM ]

We will now begin to add 3d shapes (as points only) to our already simmering graphics stew.

Deadline Wednesday March 20th 8am.
You must do the following things:
  1. Write correct, functioning code.
  2. Create a script file
  3. Upload a new picture to the gallery
  • add the following commands to the parser
    • clear: clears the edge matrix of all points
      • c people: this is an incredibly simple operation that shouldn't involve futzing with any of the points in the edge matrix.
    • box: adds a rectangular prism (box) to the edge matrix - takes 6 parameters (x, y, z, width, height, depth)
    • sphere: adds a sphere to the edge matrix - takes 4 parameters (x, y, z, radius)
    • torus: adds a torus to the edge matrix - takes 5 parameters (x, y, z, radius1, radius2)
      • radius1 is the radius of the circle that makes up the torus
      • radius2 is the full radius of the torus (the translation factor). You can think of this as the distance from the center of the torus to the center of any circular slice of the torus.
  • To future-proof your code, you should split sphere/torus creation into 2 parts:
    • Generating only the points on the surface of the shape.
    • Adding the points to an edge matrix so that they can be drawn.
      • Eventually, this part will be changed to handle solid shapes, but the points part will stay the same.
  • You should actually add edges to draw the box.
  • For the sphere and torus, just add the points for each point on the surface, and an edge from it to a point 1 pixel away to make it easier to see.
REPO:
MKS66-3D

1-10 of 17