3n4n / opengl-gun Goto Github PK
View Code? Open in Web Editor NEWBUET UGCSE410 Assignment on OpenGL
BUET UGCSE410 Assignment on OpenGL
Assignment on OpenGL ==================== Fully Controllable Camera ------------------------- Up arrow - move forward Down arrow - move backward Right arrow - move right Left arrow - move left PgUp - move up PgDn - move down 1 - rotate/look left 2 - rotate/look right 3 - look up 4 - look down 5 - tilt clockwise 6 - tilt counterclockwise Hint: Maintain four global variables: one 3d point pos to indicate the position of the camera and three 3d unit vectors u, r, and l to indicate the up, right, and look directions respectively. u, r, and l must be perpendicular to each other, i.e., u. r = r. l = l. u = 0, u = r × l, l = u × r, r = l × u. You should initialize and maintain the values of u, r, and l such that the above property holds throughout the run of the program. For example, you can initialize them as follows: u = (0, 0, 1), r = (−1/√2, 1/√2, 0), l = (−1/√2, −1/√2, 0), pos = (100, 100, 0) And while changing u, r, and l, make sure that they remain unit vectors perpendicular to each other. The first 6 operations listed above are move operations, where the position of the camera changes but the up, right, and look directions do not. The last 6 operations are rotate operations, where the camera position does not change, but the direction vectors do. In case of a move operation, move pos a certain amount along the appropriate direction, but leave the direction vectors unchanged. For example, in the move right operation, move pos along r by 2 (or by any amount you find appropriate) units. In case of a rotate operation, rotate two appropriate direction vectors a certain amount around the other direction vector, but leave the position of the camera unchanged. For example, in the look up operation, rotate l and u counterclockwise with respect to r by 3 (or by any amount you find appropriate) degrees. If you maintain pos, u, r, and l in this way, your gluLookAt statement will look as follows: gluLookAt(pos.x, pos.y, pos.z, pos.x + l.x, pos.y + l.y, pos.z + l.z, u.x, u.y, u.z); Gun --- Color pattern of the gun should be same as the one modeled in Problem 1.exe. You can't use any OpenGL library function to draw the parts of the gun. Press the keys q, w, e, r, a, s, d and f to find out how the gun rotates. Also observe that after certain amount, each joint ceases to rotate. Left click the mouse to fire the gun. Draw the gunshots (red squares) slightly in front of the wall to avoid glitches. Be careful to ensure that your model is located well within the far distance (assigned in gluPerspective) from the camera. See the link below to find how to compute the intersection of a line with a plane. https://ocw.mit.edu/courses/mathematics/18-02sc-multivariable-calculus-fall-2010/1.-vectors-and-matrices/part-c-parametric-equations-for-curves/session-16-intersection-of-a-line-and-a-plane/MIT18_02SC_we_9_comb.pdf Right click the mouse to toggle viewing the axis.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.