Sega 500 Placing target boxes on the HUD Jeff “Ezeikeil” Giles

Slides:



Advertisements
Similar presentations
Defining the Viewing Coordinate System
Advertisements

Graphing Linear Equations and Functions
APPLICATIONS OF DIFFERENTIATION
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
Chapter 3 Vectors.
Chapter 4.1 Mathematical Concepts
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
17 VECTOR CALCULUS.
IAT 800 Lecture 4. Sept 18, Fall 2006IAT 8002 Outline  Programming concepts –Methods –Classes  Talk about project 1  Reading: Read Chapters 1-4 of.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
CS 376 Introduction to Computer Graphics 02 / 26 / 2007 Instructor: Michael Eckmann.
Now Playing: Gong Sigur Rós From Takk... Released September 13, 2005.
Chapter 2: Vectors Ian Parberry University of North Texas Fletcher Dunn Valve Software 3D Math Primer for Graphics and Game Development.
APPLICATIONS OF DIFFERENTIATION 4. In Sections 2.2 and 2.4, we investigated infinite limits and vertical asymptotes.  There, we let x approach a number.
Scalar and Vector Fields
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
IAT 355 Lecture 4 Computer Graphics: Rocket. May 9, 2014IAT 3552 Outline  Programming concepts –Programming Computer Graphics –Transformations –Methods.
Geometric Intuition Randy Gaul. Vectors, Points and Basis Matrices Rotation Matrices Dot product and how it’s useful Cross product and how it’s useful.
1 CO Games Development 1 Week 5 Deriving a "look at" function + Graph Theory Gareth Bellaby.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
CS 325 Introduction to Computer Graphics 03 / 03 / 2010 Instructor: Michael Eckmann.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
Vectors Jeff Chastine.
Combining vectors in 2D Components, Overall Velocity or force Equilibrium, Equilibriants.
Maths Notes Number 5. Decimals
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
Chapter 4.1 Mathematical Concepts
Number 8. Negative Numbers
An-Najah National University College of Engineering
Copyright © Cengage Learning. All rights reserved. 3 Applications of Differentiation.
02/26/02 (c) 2002 University of Wisconsin, CS 559 Last Time Canonical view pipeline Orthographic projection –There was an error in the matrix for taking.
Sega 500 Close Combat weapons Jeff “Ezeikeil” Giles
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
R 2R2R a a Today… More on Electric Field: –Continuous Charge Distributions Electric Flux: –Definition –How to think about flux.
Unit 2 Example Problems: Forces AP Physics B. Welcome to this little tutorial about the Unit 2 forces example problems. The focus of this tutorial, and.
January 23, 2006Vectors1 Directions – Pointed Things January 23, 2005.
VECTORS. A vector is a quantity that has both magnitude and direction. It is represented by an arrow. The length of the vector represents the magnitude.
Copyright © Cengage Learning. All rights reserved. 2 Limits and Derivatives.
Scalar Quantities Scalar quantities are measurements that have only magnitude (size) but no direction. Examples of scalar quantities are; Distance Speed.
Algebraic Plane Solution Let’s solve the system of equations: 2x – 5y + 2z = 15 x + 3y - z = -4 2x - y - z = 2 First we make our assumption that they all.
Matthew Christian. About Me Introduction to Linear Algebra Vectors Matrices Quaternions Links.
Realtime NPR Toon and Pencil Shading Joel Jorgensen May 4, 2010.
CS 450: COMPUTER GRAPHICS PROJECTIONS SPRING 2015 DR. MICHAEL J. REALE.
Advanced Computer Graphics Shadow Techniques CO2409 Computer Graphics Week 20.
Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Sega 500 Scripted events and Sequences Jeff “Ezeikeil” Giles
Sega 500 Precaching in UT2003 Jeff “Ezeikeil” Giles
© 2013 Pearson Education, Inc. 12G Vectors in Space.
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Graphics Lecture 2: Slide 1 Lecture 2 Transformations for animation.
Vectors and Scalars and Their Physical Significance.
Unit 10 Transformations. Lesson 10.1 Dilations Lesson 10.1 Objectives Define transformation (G3.1.1) Differentiate between types of transformations (G3.1.2)
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry "Old Henry And His Old Aunt" Defined using right triangle  x y h.
Competency Goal 4: The learner will develop an understanding of forces and Newton's Laws of Motion Assess the independence of the vector components.
OpenGL LAB III.
Sega 500 More on Possession and Using Stuff Jeff “Ezeikeil” Giles
Vectors Chapter 2.  Scalars and vectors : A scalar quantity: is a quantity that has magnitude only. Mass, time, speed, distance, pressure, Temperature.
LCC 6310 Computation as an Expressive Medium
Vectors Jeff Chastine.
6.2 Volume: The Disc Method
Vectors for Calculus-Based Physics
Last Time Canonical view pipeline Projection Local Coordinate Space
Game Programming Algorithms and Techniques
Presentation transcript:

Sega 500 Placing target boxes on the HUD Jeff “Ezeikeil” Giles

Today Carrying on with our game type, we’re going to continue to expand on our pawn detection system by building a “lock on” system into the HUD. So the goal is to draw some sort of targeting recticle or target box over where the enemy pawn is displayed on the HUD.

What we’re after The idea is to help the player spot distant or hidden pawns. This target recticle will indicate their approximate position.

What we’re after

In effect, we are going to be translating a 3D coordinate from world space to a 2D coordinate on the HUD.

What we’re after Now that doesn’t look to tough now does it? After all, we did pretty much just that with the radar blips didn’t we? Well….sorta.

What we’re after I know it doesn’t look too tough. But trust me, there is some funky math going on here. At a minimum, we need to know 3 things about the world to make this work.

What we’re after Where the target pawn is. Where we are. Which way we are facing.

What we’re after As we learned yesterday, given this information we can infer: How far away they are. What direction they are from us.

Are they in front of us? We have to figure out if the are in our visible field. E.g. In front of us…and this, obviously depends on which way we are facing. To find out what our facing is, we can simply grab our rotational value out of PawnOwner.

Are they in front of us? At this point, we have a our rotation and a vector to the target pawn. …But how can we tell if they are in front of us? Look closer at what we have…a rotator & a vector.

Are they in front of us? Starting with a rotator. Functionally, what is it?

Are they in front of us? We talked about this yesterday, essentially nothing more that an unit vector. And a unit vector is like any other vector but with a magnitude of 1.

Are they in front of us? So what about a vector? Functionally, what does it tell us?

Are they in front of us? A vector tells us a couple of things A position in space…but we’re not interested I that right now. A size…how BIG it is. And a direction...which way it’s pointing.

Are they in front of us? Remember, rotators and vectors are interchangeable. It just takes a bit of twiddling. In effect, we have 2 vectors to work with.

Are they in front of us? Look at it this way, we have our 2 vectors. We are at the origin (0,0,0) and A is our orientation The target it at B (0,0,0) A B C

Are they in front of us? So, what we are REALLY interest in is the angle between these 2 vectors E.g. Angle ACB A B (0,0,0) C

Are they in front of us? Now we can do all sorts of high school algebra & trigonometry to figure this out. A B (0,0,0) C

Are they in front of us? Or we could use a DOT product. A B (0,0,0) C

Are they in front of us? The DOT product is one of these handy little items used all the time in 3D. Commonly found in lighting calculations. It’s primary purpose in life is to allow us to find the angle between 2 vectors. It returns a scalar float value which ranges from -1 to 1.

Are they in front of us? Depending on the relative directions of the 2 vectors, will determine if the value is positive or negative.

Are they in front of us? So if vector V is parallel to the positive X axis, as vector U approaches it, the DOT product will approach 1 X+ Y+ (0,0,0) V U

Are they in front of us? As vector U moves towards the perpendicular (parallel to the positive Y axis), the DOT product will approach 0 X+ Y+ (0,0,0) V U

Are they in front of us? And as vector U approaches being parallel to the negative X axis, the DOT product will approach -1 X+ Y+ (0,0,0) V U

Are they in front of us? Therefore, knowing that the X positive in UT 2003 is forward of the player, The DOT of our forward vector and the direction to the target is approaching 1, we know it’s in front of us.

Are they in front of us? Right, time to code. For clarity, I’m going to create a new function called DrawTargetRectical. Which will iterate over all near by pawns & test if they are in front of us. For now, we’ll just throw some text at the screen when they are.

Are they in front of us? Function & required variables function DrawTargetRectical (Canvas c) { local vector x,y,z, direction; local float distance; local Pawn targetP;

Are they in front of us? GetAxes(pawnowner.Rotation,x,y,z); foreach RadiusActors(class'pawn',targetP,range,PawnOwner.Location) { direction= targetP.Location-PawnOwner.Location; distance = VSize( direction); direction= vector(rotator( direction)); if( direction dot x > 0.7) { c.SetPos(20,100); c.DrawText("-->"$targetP.PlayerReplicationInfo.Playername$" ahead"); }

Are they in front of us?

What’s going on Hey cool! It actually pops up when someone is in front of us. But what’s going on?

What’s going on GetAxes(pawnowner.Rotation,x,y,z); From the actor class native(229) static final function GetAxes ( rotator A, out vector X, out vector Y, out vector Z ); Get X,Y and Z axes values for the given rotator and sets X,Y,Z Accordingly. Where X is forward direction, Y points right and Z points upwards. (relative to the rotation expressed by A)

What’s going on foreach RadiusActors(class'pawn',targetP,range,PawnOwner.Location) { direction= targetP.Location-PawnOwner.Location; distance = VSize(direction); This should look familiar. It’s the same code from the Radar screen. We simply calculate it’s direction & distance.

What’s going on direction= vector( Normalize( rotator (direction))); Looks a bit sticky, but were really just doing a bunch of casting to get our normalized vector.

What’s going on From the Wiki rotator Normalize (rotator Rot) [static] Returns the corresponding rotator with components between 0 and

What’s going on if( direction dot x > 0.7) Calculating the DOT product. Remember, as the DOT of 2 vectors approach 1, they line up. Notice that the “dot” keyword is in fact an operator in UT2003

However… We have a problem. For some reason, I’m occasionally “in front of myself”. Notice that there is no one on the radar.

An easy fix We have 2 options. The obvious solution is to exclude myself from the test using an if condition. Or we could be clever…

An easy fix Swap this line direction= vector(Normalize( rotator(direction))); with… direction= direction/distance; Same end result. What are getting in both cases is the normalized unit vector. This works because a distance to myself is GOING to be zero and UT2003 seems to deal with divide by zero quite well. Treating them as an ignore case.

Drawing the recticle Now that we’ve fixed that, Lets go about adding a target recticle overtop of the pawn. My texture: target=Texture'Crosshairs.HUD.Crosshair_Circle2‘

Drawing the recticle And I just used DrawIcon similar to how we placed the blips yesterday. c.SetPos( Xpos-16, Ypos-16); c.DrawIcon(target, 1); 16 being ½ the texture dimension

Drawing the recticle To set our position to the screen, we need to do 2 more dot products. One of the z axis (vertical) and the Y (left & right) And then set our position. I created 2 int’s to make this a bit easier. local int XPos, YPos;

Drawing the recticle Casting it to screen space. The Clip/2 places us at the center of the screen Xpos = c.ClipX/2 * (1+1.4*(direction dot Y)); Ypos = c.ClipY/2 * (1-1.4*(direction dot Z));

Drawing the recticle The DOT products tell us it we need to move the cursor position up, down, left, or right from the center of the screen. Remember that they give us a value between -1 and 1 Xpos = c.ClipX/2 * (1+1.4*(direction dot Y)); Ypos = c.ClipY/2 * (1-1.4*(direction dot Z));

Drawing the recticle As for the and they are important for the positioning of the recticle when the player pitches their point of view. When the player pitches, the DOT moves away from zero causing these to be relevant. In effect they are corrections. Xpos = c.ClipX/2 * (1+1.4*(direction dot Y)); Ypos = c.ClipY/2 * (1-1.4*(direction dot Z));

But there is one more thing Notice that as I pitch up and down, the rectical pulls away from the target. Although it’s nearly perfectly lined up if my pitch is parallel to the horizontal.

But there is one more thing But I’m going to leave this to you as part of your assignment. After all, there’s not much point in me simply *giving* you the bonus part of the assignment. It’s actually a fairly easy fix, although somewhat obscure.

Drawing the recticle Also, this is not the only way to do this. There are many was to skin the proverbial “cat”. However, I feel it does a reasonable job illustrating how to go from world coordinates to screen coordinates;

Drawing the recticle But if your interest, Chimeric has an interesting tutorial on this matter.

That’s all folks Have a good weekend & start researching your assignment. Next class, we start messing with the camera system.