Assignment 2a Q&A Xu Wang.

Slides:



Advertisements
Similar presentations
Introduction to C++ An object-oriented language Unit - 01.
Advertisements

Compilation and Debugging 101. Compilation in C/C++ hello.c Preprocessor Compiler stdio.h tmpXQ.i (C code) hello.o (object file)
1 Week 2 Questions / Concerns Schedule this week: Homework1 & Lab1a due at midnight on Friday. Sherry will be in Klamath Falls on Friday Lexical Analyzer.
Write a program step by step. Step 1: Problem definition. Given the coordinate of two points in 2-D space, compute and print their straight distance.
Chapter 2: Graphics Programming
1 Building Models. 2 Objectives Introduce simple data structures for building polygonal models ­Vertex lists ­Edge lists OpenGL vertex arrays.
Functions, Projects, and C++ I/O Streams Dr. Nancy Warter-Perez June 4, 2003.
CMPUT 101 Lab # 5 October 22, :00 – 17:00.
Meshes Dr. Scott Schaefer. 3D Surfaces Vertex Table.
1 Lab Session-XIV CSIT121 Spring 2002 b Namespaces b First Class Travel b Lab Exercise 14 (Demo) b Lab Exercise b Practice Problem.
Chapter 11-12, Appendix D C Programs Higher Level languages Compilers C programming Converting C to Machine Code C Compiler for LC-3.
Programming C/C++ on Eclipe Trình bày: Ths HungNM C/C++ Training.
Guide To UNIX Using Linux Third Edition
Sierpinski Gasket Program
Computer Graphics CS 385 February 7, Fundamentals of OpenGl and Glut Today we will go through the basics of a minimal OpenGl Glut project, explaining.
Dr. Amr Talaat. #include ; /* this makes the header file for the PIC16f877 ready to be used in the C-class */ #define LED PORTC ; /* defines.
CSCI 130 Chapter 2. Program Components main() #include Variable Definition Function Prototype Program Statements Function Call Function Definition Comments.
Games Programming Assignment Adam Kaye, Lee Taylor, Matthew Hall, Nick Abbott Tom Sampson.
COS 397 Computer Graphics Assoc. Prof. Svetla Boytcheva AUBG 2013 COS 397 Computer Graphics Practical Session №1 Introduction to OpenGL, GLFW and CG.
Basic OpenGL Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, September 10, 2003.
CP104 Introduction to Programming File I/O Lecture 33 __ 1 File Input/Output Text file and binary files File Input/output File input / output functions.
02 – Object Modeling Overview Point Selection Bounding Box Line Equation Least Square Line Equation Conclusions.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical.
CSCI 130 Chapter 5 Functions. Functions are named uniquely Performs a specific task Is independent –should not interfere with other parts of program May.
Computer Graphics CS 385 January 31, Fractals Some definitions Object which is self-similar at all scales. Regardless of scale the same level of.
Interactive Computer Graphics CS 418 – Spring 2015 Mesh Rendering, Transformation, Camera Viewing and Projection in OpenGL TA: Zhicheng Yan Sushma S Kini.
C Programming Laboratory I. Introduction to C Language /* the first program for user */ #include int a=0; int main(void) { printf(“Hello World\n”); return.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 25P. 1Winter Quarter C++: I/O and Classes Lecture 25.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
Structure of a C program Preprocessor directive (header file) Program statement } Preprocessor directive Global variable declaration Comments Local variable.
Fundamentals of C and C++ Programming. EEL 3801 – Lotzi Bölöni Sub-Topics  Basic Program Structure  Variables - Types and Declarations  Basic Program.
Dr. Mohamed Ben Othman 1 Project phase 3 1)Rewrite the code of the project in the slides, run it: 1)change it so the input should be from file with extension.exp.
1 Lab 1. C Introduction  C: –Developed by Bell lab. in –a procedure-oriented programming language.  Developing environments: –Editing –Preprocessing.
Introduction to the Maya C++ API Brent Haley The Ohio State University
Object Oriented Programming COP3330 / CGS5409.  Inheritance  Assignment 5.
Minimal standard C program int main(void) { return 0 ; }
By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)
PHY 107 – Programming For Science. Science Means Solving Problems  Physics – How does an atom work?
XNA Tutorial 1 For CS134 Lecture. Overview Some of the hard work has already been done for you. If you build and run your game now, the GraphicsDeviceManager.
Programming with Visual Studio MFC and OpenGL. Outline Creating a project Adding OpenGL initialization code and libraries Creating a mouse event Drawing.
OpenGL: Introduction #include main() { OpenWindow() ; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0,
XNA Sound Effects. float volume, pitch, pan; SoundEffect boing1; SoundEffect boing2; boing1 = Content.Load ("boing1"); boing2 = Content.Load ("boing2");
OpenGL CS418 Computer Graphics John C. Hart. OpenGL Based on GL (graphics library) by Silicon Graphics Inc. (SGI) Advantages: Runs on everything, including.
OpenGL CS418 Computer Graphics John C. Hart. OpenGL: Event-driven How in OpenGL? Programmer registers callback functions Callback function called when.
Unit 10 Code Reuse. Key Concepts Abstraction Header files Implementation files Storage classes Exit function Conditional compilation Command-line arguments.
Computer Graphics -practical- Lecture 6. (visual c++) open gl library To use open GL with VC++ we add these files:- 1)Glut.h C:\program files\ Microsoft.
UMBC GDC Programming Tutorial
OpenGL and GLUT Review Daniel Ritchie Monday, October 3 rd, 2011.
C++ / G4MICE Course Session 4 Create a complete C++ class
The build process + misc
CS380 Lab Spring Myungbae Son.
More Events.
CISC105 – General Computer Science
Objectives Identify the built-in data types in C++
C Short Overview Lembit Jürimägi.
OpenGL (Open Graphics Library) Mr. B.A.Swamy Assistant Professor Dept of CSE.
Starting to draw dealing with Windows which libraries? clipping
Preprocessor C program → Modified C program → Object Code
CSI-121 Structured Programming Language Lecture 14 Functions (Part 2)
פרטים נוספים בסילבוס של הקורס
CSE 3302 Programming Languages
Stack Memory 2 (also called Call Stack)
Drawing in the plane 455.
Problem Definition Input: Output: Requirement:
OpenGL program.
Java for Beginners University Greenwich Computing At School DASCO
Starting to draw dealing with Windows which libraries? clipping
C Language B. DHIVYA 17PCA140 II MCA.
CPS125.
Introduction to OpenGL Programming
Presentation transcript:

Assignment 2a Q&A Xu Wang

.obj file format y z x triangle faces vertices

Parser Demo Header Global variable #include<vector> vector<GLfloat*> vertices; vector<GLint*> faces;

Function to load .obj mesh char *file = “path to obj”; FILE *input; char c; GLfloat f1, f2, f3, *arrayfloat; GLint d1, d2, d3, *arrayint; vertices.clear(); faces.clear(); input = fopen(file, "r"); while (!feof(input)){ fscanf(input, "%c", &c); if (c == 'v') { arrayfloat = new GLfloat[3]; fscanf(input, "%f %f %f", &f1, &f2, &f3); arrayfloat[0] = f1; arrayfloat[1] = f2; arrayfloat[2] = f3; vertices.push_back(arrayfloat); } else if (c == 'f'){ arrayint = new GLint[3]; fscanf(input, "%d %d %d", &d1, &d2, &d3); arrayint[0] = d1; arrayint[1] = d2; arrayint[2] = d3; faces.push_back(arrayint); fclose(input);

Hints Project -> property -> C/C++ -> Preprocessor -> Preprocessor Definitions add _CRT_SECURE_NO_DEPRECATE to avoid fopen error If you use 64 bit machine, it might be useful to include the following in the beginning of the code: #define WIN32

Where is the pig and teapot?

teapot.obj

Normalization Maxx, maxy, maxz Center: x: [-1, 1] Y: [-1, 1] x: [-1, 1] Y: [-1, 1] Z: [-1, 1] Minx, miny, minz Center: (maxx+minx)/2 (maxy+miny)/2 (maxz+minz)/2

points glBegin(GL_POINTS); for (int i = 0; i<vertices.size(); i++) { glVertex3fv(vertices[i]); } glEnd();

wireframe glBegin(GL_LINES); // GL_LINE_STRIP for (int i = 0; i<faces.size(); i++) { glVertex3fv(vertices[faces[i][0] - 1]); glVertex3fv(vertices[faces[i][1] - 1]); glVertex3fv(vertices[faces[i][2] - 1]); } glEnd();

surface glBegin(GL_TRIANGLES); for (int i = 0; i<faces.size(); i++) { glVertex3fv(vertices[faces[i][0] - 1]); glVertex3fv(vertices[faces[i][1] - 1]); glVertex3fv(vertices[faces[i][2] - 1]); } glEnd();

Keyboard callback In main() glutKeyboardFunc(processKeys); void processKeys(unsigned char key, int x, int y) { if (key == ‘a') // your code here glutPostRedisplay(); }