SlideShare ist ein Scribd-Unternehmen logo
1 von 110
Downloaden Sie, um offline zu lesen
Mohammad Shaker
mohammadshaker.com
@ZGTRShaker
2011, 2012, 2013, 2014
XNA Game Development
L08 – Amazing XNA Utilities
Collision Detection
Collision Detection
determines whether two objects overlap and therefore have
collided in your virtual world.
Collision Detection
Accurate collision detection is fundamental
to a solid game engine.
Your cars would drive off the road, your people
would walk through buildings, and your camera
would travel through cement walls :D
Collision Detection
• Microsoft Book, Chapter 18, Page: 285
Collision Detection
• XNA has two main types for implementing collision detection
Collision Detection
• XNA has two main types for implementing collision detection
– BoundingBox
Collision Detection
• XNA has two main types for implementing collision detection
– BoundingBox
– BoundingSphere
Collision Detection
• XNA has two main types for implementing collision detection
– BoundingBox
• a box will better suit a rectangular high-rise building
– BoundingSphere
Collision Detection
• XNA has two main types for implementing collision detection
– BoundingBox
• a box will better suit a rectangular high-rise building
– BoundingSphere
• a bounding sphere offers a better fit for rounded objects such as a domed arena
Collision Detection
– BoundingSphere
Collision Detection
– BoundingSphere
Collision Detection
– BoundingSphere
Collision Detection
– BoundingSphere
Collision Detection
• CONTAINMENT TYPE
– BoundingBox
– BoundingSphere
Collision Detection
• CONTAINMENT TYPE
– BoundingBox
– BoundingSphere
Collision Detection
• CONTAINMENT TYPE
– BoundingBox
– BoundingSphere
Collision Detection
BOUNDING BOX
Collision Detection - BOUNDING BOX
• Initializing the Bounding BOX
• Intersects() common overloads
BoundingBox boundingBox = new BoundingBox(Vector3 min, Vector3 max);
public bool Intersects(BoundingBox box);
public bool Intersects(BoundingSphere sphere);
Collision Detection - BOUNDING BOX
• Comparing one bounding box with another:
• Comparing a bounding box with a bounding sphere:
• Comparing a bounding box with a single three-dimensional position:
public void Contains(ref BoundingBox box, out ContainmentType result);
public void Contains(ref BoundingSphere sphere, out ContainmentType result);
public void Contains(ref Vector3 point, out ContainmentType result);
Collision Detection
BOUNDING SPHERE
Collision Detection - BOUNDING SPHERE
• Initializing the Bounding Sphere
• Intersects() Common Overloads
• Contains()
public BoundingSphere(Vector3 center, float radius);
public bool Intersects(BoundingBox box);
public bool Intersects(BoundingSphere sphere);
public void Contains(ref BoundingSphere sphere,out ContainmentType result);
public void Contains(ref BoundingBox box, out ContainmentType result);
public void Contains(ref Vector3 point, out ContainmentType result);
Collision Detection - BOUNDING SPHERE
• Initializing the Bounding Sphere
• Intersects() Common Overloads
• Contains()
public bool Intersects(BoundingBox box);
public bool Intersects(BoundingSphere sphere);
public void Contains(ref BoundingSphere sphere,out ContainmentType result);
public void Contains(ref BoundingBox box, out ContainmentType result);
public void Contains(ref Vector3 point, out ContainmentType result);
a three-dimensional position
public BoundingSphere(Vector3 center, float radius);
Collision Detection
• Different sphere groups for varying levels of efficiency and accuracy
Collision Detection
• Microsoft, Collision Detection, P: 290 - 304
Check it out in
“App1-CollisionDetection-
Micosoft”
Collision Detection
Apress book, Chapter 13, Page 367
Collision Detection
Collision Detection
• Also, because the default model processor doesn’t generate a bounding box
(AABB) volume, we need to generate one for the model
Collision Detection
• Avoid testing the collision with each mesh of the model, by creating a global
bounding sphere (or global bounding Box) for the entire model!
Collision Detection
• Usage of bounding spheres is emphasized because spheres are easier to update
and transform than bounding boxes
EARLY WARNING SYSTEMS
Don’t check a 200 miles sphere collision with you!
Rbwhitaker web site: http://rbwhitaker.wikidot.com/collision-detection
Collision Detection
• Approximation
Collision Detection
• Approximation
Collision Detection
• Approximation
Collision Detection
• Approximation
When to use What?
Collision Detection
• Approximation
A better way to combine
both approaches
Collision Detection
hierarchical modeling
Collision Detection
Collision Detection
Collision Detection
Collision Detection
In hierarchical model you would use both the
large sphere, and the small spheres.
Collision Detection
Quad Tree Approach
Collision Detection Example in XNA
private bool IsCollision(Model model1, Matrix world1, Model model2, Matrix world2)
{
for (int meshIndex1 = 0; meshIndex1 < model1.Meshes.Count; meshIndex1++)
{
BoundingSphere sphere1 = model1.Meshes[meshIndex1].BoundingSphere;
sphere1 = sphere1.Transform(world1);
for (int meshIndex2 = 0; meshIndex2 < model2.Meshes.Count; meshIndex2++)
{
BoundingSphere sphere2 = model2.Meshes[meshIndex2].BoundingSphere;
sphere2 = sphere2.Transform(world2);
if (sphere1.Intersects(sphere2))
return true;
}
}
return false;
}
Collision Detection Example in XNA
“App2-CollisionDetection-WebSite”
XNA With Windows Form App/ WPF App
For more info, go to:
http://www.codeproject.com/KB/game/XNA_And_Beyond.aspx
XNA With Windows Form App
• 2 WAYS!
– 2D Graphics (Professional)
– Windows Forms (Ordinary)
XNA With Windows Form App
• 2 WAYS!
– 2D Graphics (Professional)
• See the appendix for full tutorial pdf
– Windows Forms (Ordinary)
XNA With Windows Form App
• 2 WAYS!
– 2D Graphics (Professional)
• See the appendix for full tutorial pdf
– Windows Forms (Ordinary)
• Use the appended project directly
XNA With Windows Form App
• 2 WAYS!
– 2D Graphics (Professional)
• See the appendix for full tutorial pdf
– Windows Forms (Ordinary)
• Use the appended project directly
• OR, do it your self as the following slides
XNA With Windows Form App
• Windows Forms! (See the template project in appendix)
XNA With Windows Form App
• Steps
– Add new Form in the same XNA Project (“Form1”);
– Add Panel to the form you have just created (“Form1”);
– Add to the top of “Form1”
public IntPtr PanelHandle
{
get
{
return this.panel1.IsHandleCreated? this.panel1.Handle : IntPtr.Zero;
}
}
XNA With Windows Form App
• Now, In Game1 class do the following
– Add the following at the top (using, renaming namespace)
– Create a reference to Form1 to handle the instance at runtime;using SysWinForms = System.Windows.Forms;
Form1 myForm;
XNA With Windows Form App
• Now, In Game1 class do the following
– Add the following two methods
– Create a reference to Form1 to handle the instance at runtime;
– Initialize
void myForm_HandleDestroyed(object sender, EventArgs e)
{
this.Exit();
}
void gameWindowForm_Shown(object sender, EventArgs e)
{
((SysWinForms.Form)sender).Hide();
}
XNA With Windows Form App
• Now, In Game1 class do the following
– Add the following code to Initialize() method
– Create a reference to Form1 to handle the instance at runtime;
– Initialize
protected override void Initialize()
{
SysWinForms.Form gameWindowForm =
(SysWinForms.Form)SysWinForms.Form.FromHandle(this.Window.Handle);
gameWindowForm.Shown += new EventHandler(gameWindowForm_Shown);
this.myForm = new Form1();
myForm.HandleDestroyed += new EventHandler(myForm_HandleDestroyed);
myForm.Show();
base.Initialize();
}
XNA With Windows Form App
• Now, In Game1 class do the following
– Add the following code to Draw() method so it looks like this
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
base.Draw(gameTime);
// This one will do the trick we are looking for!
this.GraphicsDevice.Present(null, null, myForm.PanelHandle);
}
XNA With Windows Form App
• Now, ctrl+F5 and u r good to go!
2D and 3D Combined
2D and 3D Combined
2D and 3D Combined
2D and 3D Combined
2D and 3D Combined
2D and 3D Combined
2D and 3D Combined
Begin Method (SpriteSortMode, BlendState, SamplerState,
DepthStencilState,
RasterizerState,
Effect,
Matrix)
Begin Method ()
Begin Method (SpriteSortMode, BlendState)
Begin Method (SpriteSortMode, BlendState, SamplerState,
DepthStencilState,
RasterizerState)
Begin Method (SpriteSortMode, BlendState, SamplerState,
DepthStencilState,
RasterizerState,
Effect)
sortMode
Sprite drawing order.
blendState
Blending options.
samplerState
Texture sampling options.
depthStencilState
Depth and stencil options.
rasterizerState
Rasterization options.
effect
Effect state options.
transformMatrix
Transformation matrix for scale, rotate,
translate options.
2D and 3D Combined
• SpriteSortMode
2D and 3D Combined
• BlendState
• See more: http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.blend.aspx
2D and 3D Combined
• BlendState
2D and 3D Combined
• BlendState
2D and 3D Combined
• BlendState
2D and 3D Combined
spriteBatch.Begin();
spriteBatch.Begin(SpriteSortMode.Immediate,
BlendState.Opaque);
• finally! change SpriteBatch From
• To
2D and 3D Combined
spriteBatch.Begin();
spriteBatch.Begin(SpriteSortMode.Immediate,
BlendState.Opaque);
• finally! change SpriteBatch From
• To
2D and 3D Combined
spriteBatch.Begin();
spriteBatch.Begin(SpriteSortMode.Immediate,
BlendState.AlphaBlend);
• finally! change SpriteBatch From
• To
2D and 3D Combined
spriteBatch.Begin();
spriteBatch.Begin(SpriteSortMode.BackToFront,
BlendState.AlphaBlend);
• finally! change SpriteBatch From
• To
Viewports & Split Screen Games
Viewports & Split Screen Games
• Base Project
• “App1-Viewports”
Viewports & Split Screen Games
• Viewports
Viewports & Split Screen Games
• Viewports – Multiple ones
So, What’s the idea
is all about?!
Viewports & Split Screen Games
• Viewports – Multiple ones
Multiple “Camera”s
Viewports & Split Screen Games
• Viewports – Multiple ones
Multiple “LookAt()”s
Viewports & Split Screen Games
• Global Scope
private Matrix topView = Matrix.CreateLookAt(new Vector3(0, 0, 4),
new Vector3(0, 0, 0), new Vector3(0, 0.001f, 1f));
private Matrix frontView = Matrix.CreateLookAt(new Vector3(0, 4, 0),
new Vector3(0, 0, 0), Vector3.UnitZ);
private Matrix sideView = Matrix.CreateLookAt(new Vector3(4, 0, 0),
new Vector3(0, 0, 0), Vector3.UnitZ);
private Matrix perspectiveView = Matrix.CreateLookAt(new Vector3(4, 4, 4),
new Vector3(0, 0, 0), Vector3.UnitZ);
private Viewport topViewport;
private Viewport sideViewport;
private Viewport frontViewport;
private Viewport perspectiveViewport;
private Matrix topView = Matrix.CreateLookAt(new Vector3(0, 0, 4),
new Vector3(0, 0, 0), new Vector3(0, 0.001f, 1f));
private Matrix frontView = Matrix.CreateLookAt(new Vector3(0, 4, 0),
new Vector3(0, 0, 0), Vector3.UnitZ);
private Matrix sideView = Matrix.CreateLookAt(new Vector3(4, 0, 0),
new Vector3(0, 0, 0), Vector3.UnitZ);
private Matrix perspectiveView = Matrix.CreateLookAt(new Vector3(4, 4, 4),
new Vector3(0, 0, 0), Vector3.UnitZ);
private Viewport topViewport;
private Viewport sideViewport;
private Viewport frontViewport;
private Viewport perspectiveViewport;
Matrix.CreateLookAt(CameraPosition, CameraTarget, CameraUp);
Viewports & Split Screen Games
LookAt()
• Initialize()
protected override void Initialize()
{
base.Initialize();
int ViewportWidth = 200;
int ViewportHeight = 200;
Viewport defaultViewport = GraphicsDevice.Viewport;
topViewport = defaultViewport;
topViewport.X = 0;
topViewport.Y = 0;
topViewport.Width = ViewportWidth;
topViewport.Height = ViewportHeight;
topViewport.MinDepth = 0;
topViewport.MaxDepth = 1;
sideViewport = defaultViewport;
sideViewport.X = ViewportWidth;
sideViewport.Y = 0;
sideViewport.Width = ViewportWidth;
sideViewport.Height = ViewportHeight;
sideViewport.MinDepth = 0;
sideViewport.MaxDepth = 1;
frontViewport = defaultViewport;
frontViewport.X = 0;
frontViewport.Y = ViewportHeight;
frontViewport.Width = ViewportWidth;
frontViewport.Height = ViewportHeight;
frontViewport.MinDepth = 0;
frontViewport.MaxDepth = 1;
perspectiveViewport = defaultViewport;
perspectiveViewport.X = ViewportWidth;
perspectiveViewport.Y = ViewportHeight;
perspectiveViewport.Width = ViewportWidth;
perspectiveViewport.Height =
ViewportHeight;
perspectiveViewport.MinDepth = 0;
perspectiveViewport.MaxDepth = 1;
}
Viewports & Split Screen Games
Viewports & Split Screen Games
• Initialize()
protected override void Initialize()
{
base.Initialize();
int ViewportWidth = 200;
int ViewportHeight = 200;
Viewport defaultViewport = GraphicsDevice.Viewport;
topViewport = defaultViewport;
topViewport.X = 0;
topViewport.Y = 0;
topViewport.Width = ViewportWidth;
topViewport.Height = ViewportHeight;
topViewport.MinDepth = 0;
topViewport.MaxDepth = 1;
sideViewport = defaultViewport;
sideViewport.X = ViewportWidth;
sideViewport.Y = 0;
sideViewport.Width = ViewportWidth;
sideViewport.Height = ViewportHeight;
sideViewport.MinDepth = 0;
sideViewport.MaxDepth = 1;
frontViewport = defaultViewport;
frontViewport.X = 0;
frontViewport.Y = ViewportHeight;
frontViewport.Width = ViewportWidth;
frontViewport.Height = ViewportHeight;
frontViewport.MinDepth = 0;
frontViewport.MaxDepth = 1;
perspectiveViewport = defaultViewport;
perspectiveViewport.X = ViewportWidth;
perspectiveViewport.Y = ViewportHeight;
perspectiveViewport.Width = ViewportWidth;
perspectiveViewport.Height =
ViewportHeight;
perspectiveViewport.MinDepth = 0;
perspectiveViewport.MaxDepth = 1;
}
• Initialize()
protected override void Initialize()
{
base.Initialize();
int ViewportWidth = 200;
int ViewportHeight = 200;
Viewport defaultViewport = GraphicsDevice.Viewport;
topViewport = defaultViewport;
topViewport.X = 0;
topViewport.Y = 0;
topViewport.Width = ViewportWidth;
topViewport.Height = ViewportHeight;
topViewport.MinDepth = 0;
topViewport.MaxDepth = 1;
sideViewport = defaultViewport;
sideViewport.X = ViewportWidth;
sideViewport.Y = 0;
sideViewport.Width = ViewportWidth;
sideViewport.Height = ViewportHeight;
sideViewport.MinDepth = 0;
sideViewport.MaxDepth = 1;
frontViewport = defaultViewport;
frontViewport.X = 0;
frontViewport.Y = ViewportHeight;
frontViewport.Width = ViewportWidth;
frontViewport.Height = ViewportHeight;
frontViewport.MinDepth = 0;
frontViewport.MaxDepth = 1;
perspectiveViewport = defaultViewport;
perspectiveViewport.X = ViewportWidth;
perspectiveViewport.Y = ViewportHeight;
perspectiveViewport.Width = ViewportWidth;
perspectiveViewport.Height =
ViewportHeight;
perspectiveViewport.MinDepth = 0;
perspectiveViewport.MaxDepth = 1;
}
Viewports & Split Screen Games
• Initialize()
protected override void Initialize()
{
base.Initialize();
int ViewportWidth = 200;
int ViewportHeight = 200;
Viewport defaultViewport = GraphicsDevice.Viewport;
topViewport = defaultViewport;
topViewport.X = 0;
topViewport.Y = 0;
topViewport.Width = ViewportWidth;
topViewport.Height = ViewportHeight;
topViewport.MinDepth = 0;
topViewport.MaxDepth = 1;
sideViewport = defaultViewport;
sideViewport.X = ViewportWidth;
sideViewport.Y = 0;
sideViewport.Width = ViewportWidth;
sideViewport.Height = ViewportHeight;
sideViewport.MinDepth = 0;
sideViewport.MaxDepth = 1;
frontViewport = defaultViewport;
frontViewport.X = 0;
frontViewport.Y = ViewportHeight;
frontViewport.Width = ViewportWidth;
frontViewport.Height = ViewportHeight;
frontViewport.MinDepth = 0;
frontViewport.MaxDepth = 1;
perspectiveViewport = defaultViewport;
perspectiveViewport.X = ViewportWidth;
perspectiveViewport.Y = ViewportHeight;
perspectiveViewport.Width = ViewportWidth;
perspectiveViewport.Height =
ViewportHeight;
perspectiveViewport.MinDepth = 0;
perspectiveViewport.MaxDepth = 1;
}
Viewports & Split Screen Games
Viewports & Split Screen Games
Viewports & Split Screen Games
Viewports & Split Screen Games
Viewports & Split Screen Games
Viewports & Split Screen Games
Viewports & Split Screen Games
Viewports & Split Screen Games
• Draw()protected override void Draw(GameTime gameTime)
{ GraphicsDevice.Clear(Color.CornflowerBlue);
Viewport original = graphics.GraphicsDevice.Viewport;
graphics.GraphicsDevice.Viewport = topViewport;
//GraphicsDevice.Clear(Color.Black);
DrawModel(model, world, topView, projection);
graphics.GraphicsDevice.Viewport = sideViewport;
//GraphicsDevice.Clear(Color.Black);
DrawModel(model, world, sideView, projection);
graphics.GraphicsDevice.Viewport = frontViewport;
//GraphicsDevice.Clear(Color.Black);
DrawModel(model, world, frontView, projection);
graphics.GraphicsDevice.Viewport = perspectiveViewport;
//GraphicsDevice.Clear(Color.Black);
DrawModel(model, world, perspectiveView, projection);
GraphicsDevice.Viewport = original;
base.Draw(gameTime);
}
Viewports & Split Screen Games
• Draw()protected override void Draw(GameTime gameTime)
{ GraphicsDevice.Clear(Color.CornflowerBlue);
Viewport original = graphics.GraphicsDevice.Viewport;
graphics.GraphicsDevice.Viewport = topViewport;
//GraphicsDevice.Clear(Color.Black);
DrawModel(model, world, topView, projection);
graphics.GraphicsDevice.Viewport = sideViewport;
//GraphicsDevice.Clear(Color.Black);
DrawModel(model, world, sideView, projection);
graphics.GraphicsDevice.Viewport = frontViewport;
//GraphicsDevice.Clear(Color.Black);
DrawModel(model, world, frontView, projection);
graphics.GraphicsDevice.Viewport = perspectiveViewport;
//GraphicsDevice.Clear(Color.Black);
DrawModel(model, world, perspectiveView, projection);
GraphicsDevice.Viewport = original;
base.Draw(gameTime);
}
Viewports & Split Screen Games
• Draw()protected override void Draw(GameTime gameTime)
{ GraphicsDevice.Clear(Color.CornflowerBlue);
Viewport original = graphics.GraphicsDevice.Viewport;
graphics.GraphicsDevice.Viewport = topViewport;
//GraphicsDevice.Clear(Color.Black);
DrawModel(model, world, topView, projection);
graphics.GraphicsDevice.Viewport = sideViewport;
//GraphicsDevice.Clear(Color.Black);
DrawModel(model, world, sideView, projection);
graphics.GraphicsDevice.Viewport = frontViewport;
//GraphicsDevice.Clear(Color.Black);
DrawModel(model, world, frontView, projection);
graphics.GraphicsDevice.Viewport = perspectiveViewport;
//GraphicsDevice.Clear(Color.Black);
DrawModel(model, world, perspectiveView, projection);
GraphicsDevice.Viewport = original;
base.Draw(gameTime);
}
Viewports & Split Screen Games
• Draw()protected override void Draw(GameTime gameTime)
{ GraphicsDevice.Clear(Color.CornflowerBlue);
Viewport original = graphics.GraphicsDevice.Viewport;
graphics.GraphicsDevice.Viewport = topViewport;
//GraphicsDevice.Clear(Color.Black);
DrawModel(model, world, topView, projection);
graphics.GraphicsDevice.Viewport = sideViewport;
//GraphicsDevice.Clear(Color.Black);
DrawModel(model, world, sideView, projection);
graphics.GraphicsDevice.Viewport = frontViewport;
//GraphicsDevice.Clear(Color.Black);
DrawModel(model, world, frontView, projection);
graphics.GraphicsDevice.Viewport = perspectiveViewport;
//GraphicsDevice.Clear(Color.Black);
DrawModel(model, world, perspectiveView, projection);
GraphicsDevice.Viewport = original;
base.Draw(gameTime);
}
Viewports & Split Screen Games
• Draw()protected override void Draw(GameTime gameTime)
{ GraphicsDevice.Clear(Color.CornflowerBlue);
Viewport original = graphics.GraphicsDevice.Viewport;
graphics.GraphicsDevice.Viewport = topViewport;
//GraphicsDevice.Clear(Color.Black);
DrawModel(model, world, topView, projection);
graphics.GraphicsDevice.Viewport = sideViewport;
//GraphicsDevice.Clear(Color.Black);
DrawModel(model, world, sideView, projection);
graphics.GraphicsDevice.Viewport = frontViewport;
//GraphicsDevice.Clear(Color.Black);
DrawModel(model, world, frontView, projection);
graphics.GraphicsDevice.Viewport = perspectiveViewport;
//GraphicsDevice.Clear(Color.Black);
DrawModel(model, world, perspectiveView, projection);
GraphicsDevice.Viewport = original;
base.Draw(gameTime);
}
Viewports & Split Screen Games
• “App2-ViewportsFinished”
Picking Objects
Picking Objects
• How to pick?!
Picking Objects
• How to pick?!
Picking Objects
public Ray CalculateRay(Vector2 mouseLocation, Matrix view, Matrix projection,
Viewport viewport)
{
Vector3 nearPoint = viewport.Unproject(
new Vector3(mouseLocation.X, mouseLocation.Y, 0.0f),
projection,
view,
Matrix.Identity);
Vector3 farPoint = viewport.Unproject(
new Vector3(mouseLocation.X, mouseLocation.Y, 1.0f),
projection,
view,
Matrix.Identity);
Vector3 direction = farPoint - nearPoint;
direction.Normalize();
return new Ray(nearPoint, direction);
}
Picking Objects
public bool Intersects(Vector2 mouseLocation,
Model model, Matrix world, Matrix view, Matrix projection,
Viewport viewport)
{
for (int index = 0; index < model.Meshes.Count; index++)
{
BoundingSphere sphere = model.Meshes[index].BoundingSphere;
sphere = sphere.Transform(world);
float? distance = IntersectDistance(sphere, mouseLocation, view, projection, viewport);
if (distance != null)
{
return true;
}
}
return false;
}
Picking Objects
public float? IntersectDistance(BoundingSphere sphere, Vector2 mouseLocation,
Matrix view, Matrix projection, Viewport viewport)
{
Ray mouseRay = CalculateRay(mouseLocation, view, projection, viewport);
return mouseRay.Intersects(sphere);
}
Picking Objects
• “App-Picking”
Take a Look on my other courses
@ http://www.slideshare.net/ZGTRZGTR
Available courses to the date of this slide:
http://www.mohammadshaker.com
mohammadshakergtr@gmail.com
https://twitter.com/ZGTRShaker @ZGTRShaker
https://de.linkedin.com/pub/mohammad-shaker/30/122/128/
http://www.slideshare.net/ZGTRZGTR
https://www.goodreads.com/user/show/11193121-mohammad-shaker
https://plus.google.com/u/0/+MohammadShaker/
https://www.youtube.com/channel/UCvJUfadMoEaZNWdagdMyCRA
http://mohammadshakergtr.wordpress.com/

Weitere ähnliche Inhalte

Was ist angesagt?

Trident International Graphics Workshop 2014 2/5
Trident International Graphics Workshop 2014 2/5Trident International Graphics Workshop 2014 2/5
Trident International Graphics Workshop 2014 2/5Takao Wada
 
Geometry Shader-based Bump Mapping Setup
Geometry Shader-based Bump Mapping SetupGeometry Shader-based Bump Mapping Setup
Geometry Shader-based Bump Mapping SetupMark Kilgard
 
Computer Vision harris
Computer Vision harrisComputer Vision harris
Computer Vision harrisWael Badawy
 
Graphicsand animations devoxx2010 (1)
Graphicsand animations devoxx2010 (1)Graphicsand animations devoxx2010 (1)
Graphicsand animations devoxx2010 (1)Marakana Inc.
 
Company of Heroes 2 (COH2) Rendering Technology: The cold facts of recreating...
Company of Heroes 2 (COH2) Rendering Technology: The cold facts of recreating...Company of Heroes 2 (COH2) Rendering Technology: The cold facts of recreating...
Company of Heroes 2 (COH2) Rendering Technology: The cold facts of recreating...Daniel Barrero
 
Maximizing performance of 3 d user generated assets in unity
Maximizing performance of 3 d user generated assets in unityMaximizing performance of 3 d user generated assets in unity
Maximizing performance of 3 d user generated assets in unityWithTheBest
 
A practical intro to BabylonJS
A practical intro to BabylonJSA practical intro to BabylonJS
A practical intro to BabylonJSHansRontheWeb
 
Computer graphics
Computer graphics Computer graphics
Computer graphics shafiq sangi
 
Artdm170 week12 user_interaction
Artdm170 week12 user_interactionArtdm170 week12 user_interaction
Artdm170 week12 user_interactionGilbert Guerrero
 
Java applet handouts
Java applet handoutsJava applet handouts
Java applet handoutsiamkim
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualUma mohan
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualAnkit Kumar
 

Was ist angesagt? (20)

SA09 Realtime education
SA09 Realtime educationSA09 Realtime education
SA09 Realtime education
 
Trident International Graphics Workshop 2014 2/5
Trident International Graphics Workshop 2014 2/5Trident International Graphics Workshop 2014 2/5
Trident International Graphics Workshop 2014 2/5
 
Geometry Shader-based Bump Mapping Setup
Geometry Shader-based Bump Mapping SetupGeometry Shader-based Bump Mapping Setup
Geometry Shader-based Bump Mapping Setup
 
Computer Vision harris
Computer Vision harrisComputer Vision harris
Computer Vision harris
 
Graphicsand animations devoxx2010 (1)
Graphicsand animations devoxx2010 (1)Graphicsand animations devoxx2010 (1)
Graphicsand animations devoxx2010 (1)
 
Company of Heroes 2 (COH2) Rendering Technology: The cold facts of recreating...
Company of Heroes 2 (COH2) Rendering Technology: The cold facts of recreating...Company of Heroes 2 (COH2) Rendering Technology: The cold facts of recreating...
Company of Heroes 2 (COH2) Rendering Technology: The cold facts of recreating...
 
Maximizing performance of 3 d user generated assets in unity
Maximizing performance of 3 d user generated assets in unityMaximizing performance of 3 d user generated assets in unity
Maximizing performance of 3 d user generated assets in unity
 
A practical intro to BabylonJS
A practical intro to BabylonJSA practical intro to BabylonJS
A practical intro to BabylonJS
 
Applets
AppletsApplets
Applets
 
Cg lab cse-v (1) (1)
Cg lab cse-v (1) (1)Cg lab cse-v (1) (1)
Cg lab cse-v (1) (1)
 
Anschp34
Anschp34Anschp34
Anschp34
 
Computer graphics
Computer graphics Computer graphics
Computer graphics
 
Cgm Lab Manual
Cgm Lab ManualCgm Lab Manual
Cgm Lab Manual
 
Games 3 dl4-example
Games 3 dl4-exampleGames 3 dl4-example
Games 3 dl4-example
 
Artdm170 week12 user_interaction
Artdm170 week12 user_interactionArtdm170 week12 user_interaction
Artdm170 week12 user_interaction
 
10 linescan
10 linescan10 linescan
10 linescan
 
Ch32 ssm
Ch32 ssmCh32 ssm
Ch32 ssm
 
Java applet handouts
Java applet handoutsJava applet handouts
Java applet handouts
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 

Ähnlich wie XNA L08–Amazing XNA Utilities

Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5Takao Wada
 
Chapter ii(coding)
Chapter ii(coding)Chapter ii(coding)
Chapter ii(coding)Chhom Karath
 
Introduction to Coding
Introduction to CodingIntroduction to Coding
Introduction to CodingFabio506452
 
Lecture 2: C# Programming for VR application in Unity
Lecture 2: C# Programming for VR application in UnityLecture 2: C# Programming for VR application in Unity
Lecture 2: C# Programming for VR application in UnityKobkrit Viriyayudhakorn
 
Gdc09 Minigames
Gdc09 MinigamesGdc09 Minigames
Gdc09 MinigamesSusan Gold
 
Clean Code Development
Clean Code DevelopmentClean Code Development
Clean Code DevelopmentPeter Gfader
 
IL2CPP: Debugging and Profiling
IL2CPP: Debugging and ProfilingIL2CPP: Debugging and Profiling
IL2CPP: Debugging and Profilingjoncham
 
Visual sedimentation - IEEE VIS 2013 Atlanta
Visual sedimentation - IEEE VIS 2013 AtlantaVisual sedimentation - IEEE VIS 2013 Atlanta
Visual sedimentation - IEEE VIS 2013 AtlantaSamuel Huron
 
Virtual Reality Modeling Language
Virtual Reality Modeling LanguageVirtual Reality Modeling Language
Virtual Reality Modeling LanguageSwati Chauhan
 
Getting Started with 3D Game Development on Nokia Series 40 Asha Phones
Getting Started with 3D Game Development on Nokia Series 40 Asha PhonesGetting Started with 3D Game Development on Nokia Series 40 Asha Phones
Getting Started with 3D Game Development on Nokia Series 40 Asha PhonesMicrosoft Mobile Developer
 
Vrml Language (Virtual Reality)
Vrml Language (Virtual Reality) Vrml Language (Virtual Reality)
Vrml Language (Virtual Reality) Umer Awan
 
Augmented Reality With FlarToolkit and Papervision3D
Augmented Reality With FlarToolkit and Papervision3DAugmented Reality With FlarToolkit and Papervision3D
Augmented Reality With FlarToolkit and Papervision3DRoman Protsyk
 
Rainbow Over the Windows: More Colors Than You Could Expect
Rainbow Over the Windows: More Colors Than You Could ExpectRainbow Over the Windows: More Colors Than You Could Expect
Rainbow Over the Windows: More Colors Than You Could ExpectPeter Hlavaty
 
The Ring programming language version 1.8 book - Part 53 of 202
The Ring programming language version 1.8 book - Part 53 of 202The Ring programming language version 1.8 book - Part 53 of 202
The Ring programming language version 1.8 book - Part 53 of 202Mahmoud Samir Fayed
 
Design Patterns Reconsidered
Design Patterns ReconsideredDesign Patterns Reconsidered
Design Patterns ReconsideredAlex Miller
 
Soft Shake Event / A soft introduction to Neo4J
Soft Shake Event / A soft introduction to Neo4JSoft Shake Event / A soft introduction to Neo4J
Soft Shake Event / A soft introduction to Neo4JFlorent Biville
 
Beginning direct3d gameprogramming01_20161102_jintaeks
Beginning direct3d gameprogramming01_20161102_jintaeksBeginning direct3d gameprogramming01_20161102_jintaeks
Beginning direct3d gameprogramming01_20161102_jintaeksJinTaek Seo
 

Ähnlich wie XNA L08–Amazing XNA Utilities (20)

Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5
 
Chapter ii(coding)
Chapter ii(coding)Chapter ii(coding)
Chapter ii(coding)
 
Introduction to Coding
Introduction to CodingIntroduction to Coding
Introduction to Coding
 
Lecture 2: C# Programming for VR application in Unity
Lecture 2: C# Programming for VR application in UnityLecture 2: C# Programming for VR application in Unity
Lecture 2: C# Programming for VR application in Unity
 
Object-oriented Basics
Object-oriented BasicsObject-oriented Basics
Object-oriented Basics
 
Gdc09 Minigames
Gdc09 MinigamesGdc09 Minigames
Gdc09 Minigames
 
Fact, Fiction, and FP
Fact, Fiction, and FPFact, Fiction, and FP
Fact, Fiction, and FP
 
Clean Code Development
Clean Code DevelopmentClean Code Development
Clean Code Development
 
IL2CPP: Debugging and Profiling
IL2CPP: Debugging and ProfilingIL2CPP: Debugging and Profiling
IL2CPP: Debugging and Profiling
 
OOP v3
OOP v3OOP v3
OOP v3
 
Visual sedimentation - IEEE VIS 2013 Atlanta
Visual sedimentation - IEEE VIS 2013 AtlantaVisual sedimentation - IEEE VIS 2013 Atlanta
Visual sedimentation - IEEE VIS 2013 Atlanta
 
Virtual Reality Modeling Language
Virtual Reality Modeling LanguageVirtual Reality Modeling Language
Virtual Reality Modeling Language
 
Getting Started with 3D Game Development on Nokia Series 40 Asha Phones
Getting Started with 3D Game Development on Nokia Series 40 Asha PhonesGetting Started with 3D Game Development on Nokia Series 40 Asha Phones
Getting Started with 3D Game Development on Nokia Series 40 Asha Phones
 
Vrml Language (Virtual Reality)
Vrml Language (Virtual Reality) Vrml Language (Virtual Reality)
Vrml Language (Virtual Reality)
 
Augmented Reality With FlarToolkit and Papervision3D
Augmented Reality With FlarToolkit and Papervision3DAugmented Reality With FlarToolkit and Papervision3D
Augmented Reality With FlarToolkit and Papervision3D
 
Rainbow Over the Windows: More Colors Than You Could Expect
Rainbow Over the Windows: More Colors Than You Could ExpectRainbow Over the Windows: More Colors Than You Could Expect
Rainbow Over the Windows: More Colors Than You Could Expect
 
The Ring programming language version 1.8 book - Part 53 of 202
The Ring programming language version 1.8 book - Part 53 of 202The Ring programming language version 1.8 book - Part 53 of 202
The Ring programming language version 1.8 book - Part 53 of 202
 
Design Patterns Reconsidered
Design Patterns ReconsideredDesign Patterns Reconsidered
Design Patterns Reconsidered
 
Soft Shake Event / A soft introduction to Neo4J
Soft Shake Event / A soft introduction to Neo4JSoft Shake Event / A soft introduction to Neo4J
Soft Shake Event / A soft introduction to Neo4J
 
Beginning direct3d gameprogramming01_20161102_jintaeks
Beginning direct3d gameprogramming01_20161102_jintaeksBeginning direct3d gameprogramming01_20161102_jintaeks
Beginning direct3d gameprogramming01_20161102_jintaeks
 

Mehr von Mohammad Shaker

12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian GraduateMohammad Shaker
 
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Mohammad Shaker
 
Interaction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyInteraction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyMohammad Shaker
 
Short, Matters, Love - Passioneers Event 2015
Short, Matters, Love -  Passioneers Event 2015Short, Matters, Love -  Passioneers Event 2015
Short, Matters, Love - Passioneers Event 2015Mohammad Shaker
 
Unity L01 - Game Development
Unity L01 - Game DevelopmentUnity L01 - Game Development
Unity L01 - Game DevelopmentMohammad Shaker
 
Android L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesAndroid L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesMohammad Shaker
 
Interaction Design L03 - Color
Interaction Design L03 - ColorInteraction Design L03 - Color
Interaction Design L03 - ColorMohammad Shaker
 
Interaction Design L05 - Typography
Interaction Design L05 - TypographyInteraction Design L05 - Typography
Interaction Design L05 - TypographyMohammad Shaker
 
Interaction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingInteraction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingMohammad Shaker
 
Android L04 - Notifications and Threading
Android L04 - Notifications and ThreadingAndroid L04 - Notifications and Threading
Android L04 - Notifications and ThreadingMohammad Shaker
 
Android L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSAndroid L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSMohammad Shaker
 
Interaction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsInteraction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsMohammad Shaker
 
Interaction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsInteraction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsMohammad Shaker
 
Android L10 - Stores and Gaming
Android L10 - Stores and GamingAndroid L10 - Stores and Gaming
Android L10 - Stores and GamingMohammad Shaker
 
Android L06 - Cloud / Parse
Android L06 - Cloud / ParseAndroid L06 - Cloud / Parse
Android L06 - Cloud / ParseMohammad Shaker
 
Android L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesAndroid L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesMohammad Shaker
 
Android L03 - Styles and Themes
Android L03 - Styles and Themes Android L03 - Styles and Themes
Android L03 - Styles and Themes Mohammad Shaker
 
Android L02 - Activities and Adapters
Android L02 - Activities and AdaptersAndroid L02 - Activities and Adapters
Android L02 - Activities and AdaptersMohammad Shaker
 

Mehr von Mohammad Shaker (20)

12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate
 
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
 
Interaction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyInteraction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with Psychology
 
Short, Matters, Love - Passioneers Event 2015
Short, Matters, Love -  Passioneers Event 2015Short, Matters, Love -  Passioneers Event 2015
Short, Matters, Love - Passioneers Event 2015
 
Unity L01 - Game Development
Unity L01 - Game DevelopmentUnity L01 - Game Development
Unity L01 - Game Development
 
Android L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesAndroid L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and Wearables
 
Interaction Design L03 - Color
Interaction Design L03 - ColorInteraction Design L03 - Color
Interaction Design L03 - Color
 
Interaction Design L05 - Typography
Interaction Design L05 - TypographyInteraction Design L05 - Typography
Interaction Design L05 - Typography
 
Interaction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingInteraction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and Coupling
 
Android L05 - Storage
Android L05 - StorageAndroid L05 - Storage
Android L05 - Storage
 
Android L04 - Notifications and Threading
Android L04 - Notifications and ThreadingAndroid L04 - Notifications and Threading
Android L04 - Notifications and Threading
 
Android L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSAndroid L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOS
 
Interaction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsInteraction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile Constraints
 
Interaction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsInteraction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and Grids
 
Android L10 - Stores and Gaming
Android L10 - Stores and GamingAndroid L10 - Stores and Gaming
Android L10 - Stores and Gaming
 
Android L06 - Cloud / Parse
Android L06 - Cloud / ParseAndroid L06 - Cloud / Parse
Android L06 - Cloud / Parse
 
Android L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesAndroid L08 - Google Maps and Utilities
Android L08 - Google Maps and Utilities
 
Android L03 - Styles and Themes
Android L03 - Styles and Themes Android L03 - Styles and Themes
Android L03 - Styles and Themes
 
Android L02 - Activities and Adapters
Android L02 - Activities and AdaptersAndroid L02 - Activities and Adapters
Android L02 - Activities and Adapters
 
Android L01 - Warm Up
Android L01 - Warm UpAndroid L01 - Warm Up
Android L01 - Warm Up
 

Kürzlich hochgeladen

My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 

Kürzlich hochgeladen (20)

My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 

XNA L08–Amazing XNA Utilities

  • 1. Mohammad Shaker mohammadshaker.com @ZGTRShaker 2011, 2012, 2013, 2014 XNA Game Development L08 – Amazing XNA Utilities
  • 3. Collision Detection determines whether two objects overlap and therefore have collided in your virtual world.
  • 4. Collision Detection Accurate collision detection is fundamental to a solid game engine.
  • 5.
  • 6. Your cars would drive off the road, your people would walk through buildings, and your camera would travel through cement walls :D
  • 7.
  • 8. Collision Detection • Microsoft Book, Chapter 18, Page: 285
  • 9. Collision Detection • XNA has two main types for implementing collision detection
  • 10. Collision Detection • XNA has two main types for implementing collision detection – BoundingBox
  • 11. Collision Detection • XNA has two main types for implementing collision detection – BoundingBox – BoundingSphere
  • 12. Collision Detection • XNA has two main types for implementing collision detection – BoundingBox • a box will better suit a rectangular high-rise building – BoundingSphere
  • 13. Collision Detection • XNA has two main types for implementing collision detection – BoundingBox • a box will better suit a rectangular high-rise building – BoundingSphere • a bounding sphere offers a better fit for rounded objects such as a domed arena
  • 18. Collision Detection • CONTAINMENT TYPE – BoundingBox – BoundingSphere
  • 19. Collision Detection • CONTAINMENT TYPE – BoundingBox – BoundingSphere
  • 20. Collision Detection • CONTAINMENT TYPE – BoundingBox – BoundingSphere
  • 22. Collision Detection - BOUNDING BOX • Initializing the Bounding BOX • Intersects() common overloads BoundingBox boundingBox = new BoundingBox(Vector3 min, Vector3 max); public bool Intersects(BoundingBox box); public bool Intersects(BoundingSphere sphere);
  • 23. Collision Detection - BOUNDING BOX • Comparing one bounding box with another: • Comparing a bounding box with a bounding sphere: • Comparing a bounding box with a single three-dimensional position: public void Contains(ref BoundingBox box, out ContainmentType result); public void Contains(ref BoundingSphere sphere, out ContainmentType result); public void Contains(ref Vector3 point, out ContainmentType result);
  • 25. Collision Detection - BOUNDING SPHERE • Initializing the Bounding Sphere • Intersects() Common Overloads • Contains() public BoundingSphere(Vector3 center, float radius); public bool Intersects(BoundingBox box); public bool Intersects(BoundingSphere sphere); public void Contains(ref BoundingSphere sphere,out ContainmentType result); public void Contains(ref BoundingBox box, out ContainmentType result); public void Contains(ref Vector3 point, out ContainmentType result);
  • 26. Collision Detection - BOUNDING SPHERE • Initializing the Bounding Sphere • Intersects() Common Overloads • Contains() public bool Intersects(BoundingBox box); public bool Intersects(BoundingSphere sphere); public void Contains(ref BoundingSphere sphere,out ContainmentType result); public void Contains(ref BoundingBox box, out ContainmentType result); public void Contains(ref Vector3 point, out ContainmentType result); a three-dimensional position public BoundingSphere(Vector3 center, float radius);
  • 27. Collision Detection • Different sphere groups for varying levels of efficiency and accuracy
  • 28. Collision Detection • Microsoft, Collision Detection, P: 290 - 304
  • 29. Check it out in “App1-CollisionDetection- Micosoft”
  • 30. Collision Detection Apress book, Chapter 13, Page 367
  • 32. Collision Detection • Also, because the default model processor doesn’t generate a bounding box (AABB) volume, we need to generate one for the model
  • 33. Collision Detection • Avoid testing the collision with each mesh of the model, by creating a global bounding sphere (or global bounding Box) for the entire model!
  • 34. Collision Detection • Usage of bounding spheres is emphasized because spheres are easier to update and transform than bounding boxes
  • 35. EARLY WARNING SYSTEMS Don’t check a 200 miles sphere collision with you! Rbwhitaker web site: http://rbwhitaker.wikidot.com/collision-detection
  • 40. Collision Detection • Approximation A better way to combine both approaches
  • 45. Collision Detection In hierarchical model you would use both the large sphere, and the small spheres.
  • 47. Collision Detection Example in XNA private bool IsCollision(Model model1, Matrix world1, Model model2, Matrix world2) { for (int meshIndex1 = 0; meshIndex1 < model1.Meshes.Count; meshIndex1++) { BoundingSphere sphere1 = model1.Meshes[meshIndex1].BoundingSphere; sphere1 = sphere1.Transform(world1); for (int meshIndex2 = 0; meshIndex2 < model2.Meshes.Count; meshIndex2++) { BoundingSphere sphere2 = model2.Meshes[meshIndex2].BoundingSphere; sphere2 = sphere2.Transform(world2); if (sphere1.Intersects(sphere2)) return true; } } return false; }
  • 48. Collision Detection Example in XNA “App2-CollisionDetection-WebSite”
  • 49. XNA With Windows Form App/ WPF App For more info, go to: http://www.codeproject.com/KB/game/XNA_And_Beyond.aspx
  • 50. XNA With Windows Form App • 2 WAYS! – 2D Graphics (Professional) – Windows Forms (Ordinary)
  • 51. XNA With Windows Form App • 2 WAYS! – 2D Graphics (Professional) • See the appendix for full tutorial pdf – Windows Forms (Ordinary)
  • 52. XNA With Windows Form App • 2 WAYS! – 2D Graphics (Professional) • See the appendix for full tutorial pdf – Windows Forms (Ordinary) • Use the appended project directly
  • 53. XNA With Windows Form App • 2 WAYS! – 2D Graphics (Professional) • See the appendix for full tutorial pdf – Windows Forms (Ordinary) • Use the appended project directly • OR, do it your self as the following slides
  • 54. XNA With Windows Form App • Windows Forms! (See the template project in appendix)
  • 55. XNA With Windows Form App • Steps – Add new Form in the same XNA Project (“Form1”); – Add Panel to the form you have just created (“Form1”); – Add to the top of “Form1” public IntPtr PanelHandle { get { return this.panel1.IsHandleCreated? this.panel1.Handle : IntPtr.Zero; } }
  • 56. XNA With Windows Form App • Now, In Game1 class do the following – Add the following at the top (using, renaming namespace) – Create a reference to Form1 to handle the instance at runtime;using SysWinForms = System.Windows.Forms; Form1 myForm;
  • 57. XNA With Windows Form App • Now, In Game1 class do the following – Add the following two methods – Create a reference to Form1 to handle the instance at runtime; – Initialize void myForm_HandleDestroyed(object sender, EventArgs e) { this.Exit(); } void gameWindowForm_Shown(object sender, EventArgs e) { ((SysWinForms.Form)sender).Hide(); }
  • 58. XNA With Windows Form App • Now, In Game1 class do the following – Add the following code to Initialize() method – Create a reference to Form1 to handle the instance at runtime; – Initialize protected override void Initialize() { SysWinForms.Form gameWindowForm = (SysWinForms.Form)SysWinForms.Form.FromHandle(this.Window.Handle); gameWindowForm.Shown += new EventHandler(gameWindowForm_Shown); this.myForm = new Form1(); myForm.HandleDestroyed += new EventHandler(myForm_HandleDestroyed); myForm.Show(); base.Initialize(); }
  • 59. XNA With Windows Form App • Now, In Game1 class do the following – Add the following code to Draw() method so it looks like this protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); base.Draw(gameTime); // This one will do the trick we are looking for! this.GraphicsDevice.Present(null, null, myForm.PanelHandle); }
  • 60. XNA With Windows Form App • Now, ctrl+F5 and u r good to go!
  • 61. 2D and 3D Combined
  • 62. 2D and 3D Combined
  • 63. 2D and 3D Combined
  • 64. 2D and 3D Combined
  • 65. 2D and 3D Combined
  • 66. 2D and 3D Combined
  • 67. 2D and 3D Combined Begin Method (SpriteSortMode, BlendState, SamplerState, DepthStencilState, RasterizerState, Effect, Matrix) Begin Method () Begin Method (SpriteSortMode, BlendState) Begin Method (SpriteSortMode, BlendState, SamplerState, DepthStencilState, RasterizerState) Begin Method (SpriteSortMode, BlendState, SamplerState, DepthStencilState, RasterizerState, Effect) sortMode Sprite drawing order. blendState Blending options. samplerState Texture sampling options. depthStencilState Depth and stencil options. rasterizerState Rasterization options. effect Effect state options. transformMatrix Transformation matrix for scale, rotate, translate options.
  • 68. 2D and 3D Combined • SpriteSortMode
  • 69. 2D and 3D Combined • BlendState • See more: http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.blend.aspx
  • 70. 2D and 3D Combined • BlendState
  • 71. 2D and 3D Combined • BlendState
  • 72. 2D and 3D Combined • BlendState
  • 73. 2D and 3D Combined spriteBatch.Begin(); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque); • finally! change SpriteBatch From • To
  • 74. 2D and 3D Combined spriteBatch.Begin(); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque); • finally! change SpriteBatch From • To
  • 75. 2D and 3D Combined spriteBatch.Begin(); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend); • finally! change SpriteBatch From • To
  • 76. 2D and 3D Combined spriteBatch.Begin(); spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); • finally! change SpriteBatch From • To
  • 77. Viewports & Split Screen Games
  • 78. Viewports & Split Screen Games • Base Project • “App1-Viewports”
  • 79. Viewports & Split Screen Games • Viewports
  • 80. Viewports & Split Screen Games • Viewports – Multiple ones So, What’s the idea is all about?!
  • 81. Viewports & Split Screen Games • Viewports – Multiple ones Multiple “Camera”s
  • 82. Viewports & Split Screen Games • Viewports – Multiple ones Multiple “LookAt()”s
  • 83. Viewports & Split Screen Games • Global Scope private Matrix topView = Matrix.CreateLookAt(new Vector3(0, 0, 4), new Vector3(0, 0, 0), new Vector3(0, 0.001f, 1f)); private Matrix frontView = Matrix.CreateLookAt(new Vector3(0, 4, 0), new Vector3(0, 0, 0), Vector3.UnitZ); private Matrix sideView = Matrix.CreateLookAt(new Vector3(4, 0, 0), new Vector3(0, 0, 0), Vector3.UnitZ); private Matrix perspectiveView = Matrix.CreateLookAt(new Vector3(4, 4, 4), new Vector3(0, 0, 0), Vector3.UnitZ); private Viewport topViewport; private Viewport sideViewport; private Viewport frontViewport; private Viewport perspectiveViewport;
  • 84. private Matrix topView = Matrix.CreateLookAt(new Vector3(0, 0, 4), new Vector3(0, 0, 0), new Vector3(0, 0.001f, 1f)); private Matrix frontView = Matrix.CreateLookAt(new Vector3(0, 4, 0), new Vector3(0, 0, 0), Vector3.UnitZ); private Matrix sideView = Matrix.CreateLookAt(new Vector3(4, 0, 0), new Vector3(0, 0, 0), Vector3.UnitZ); private Matrix perspectiveView = Matrix.CreateLookAt(new Vector3(4, 4, 4), new Vector3(0, 0, 0), Vector3.UnitZ); private Viewport topViewport; private Viewport sideViewport; private Viewport frontViewport; private Viewport perspectiveViewport; Matrix.CreateLookAt(CameraPosition, CameraTarget, CameraUp); Viewports & Split Screen Games
  • 86. • Initialize() protected override void Initialize() { base.Initialize(); int ViewportWidth = 200; int ViewportHeight = 200; Viewport defaultViewport = GraphicsDevice.Viewport; topViewport = defaultViewport; topViewport.X = 0; topViewport.Y = 0; topViewport.Width = ViewportWidth; topViewport.Height = ViewportHeight; topViewport.MinDepth = 0; topViewport.MaxDepth = 1; sideViewport = defaultViewport; sideViewport.X = ViewportWidth; sideViewport.Y = 0; sideViewport.Width = ViewportWidth; sideViewport.Height = ViewportHeight; sideViewport.MinDepth = 0; sideViewport.MaxDepth = 1; frontViewport = defaultViewport; frontViewport.X = 0; frontViewport.Y = ViewportHeight; frontViewport.Width = ViewportWidth; frontViewport.Height = ViewportHeight; frontViewport.MinDepth = 0; frontViewport.MaxDepth = 1; perspectiveViewport = defaultViewport; perspectiveViewport.X = ViewportWidth; perspectiveViewport.Y = ViewportHeight; perspectiveViewport.Width = ViewportWidth; perspectiveViewport.Height = ViewportHeight; perspectiveViewport.MinDepth = 0; perspectiveViewport.MaxDepth = 1; } Viewports & Split Screen Games
  • 87. Viewports & Split Screen Games • Initialize() protected override void Initialize() { base.Initialize(); int ViewportWidth = 200; int ViewportHeight = 200; Viewport defaultViewport = GraphicsDevice.Viewport; topViewport = defaultViewport; topViewport.X = 0; topViewport.Y = 0; topViewport.Width = ViewportWidth; topViewport.Height = ViewportHeight; topViewport.MinDepth = 0; topViewport.MaxDepth = 1; sideViewport = defaultViewport; sideViewport.X = ViewportWidth; sideViewport.Y = 0; sideViewport.Width = ViewportWidth; sideViewport.Height = ViewportHeight; sideViewport.MinDepth = 0; sideViewport.MaxDepth = 1; frontViewport = defaultViewport; frontViewport.X = 0; frontViewport.Y = ViewportHeight; frontViewport.Width = ViewportWidth; frontViewport.Height = ViewportHeight; frontViewport.MinDepth = 0; frontViewport.MaxDepth = 1; perspectiveViewport = defaultViewport; perspectiveViewport.X = ViewportWidth; perspectiveViewport.Y = ViewportHeight; perspectiveViewport.Width = ViewportWidth; perspectiveViewport.Height = ViewportHeight; perspectiveViewport.MinDepth = 0; perspectiveViewport.MaxDepth = 1; }
  • 88. • Initialize() protected override void Initialize() { base.Initialize(); int ViewportWidth = 200; int ViewportHeight = 200; Viewport defaultViewport = GraphicsDevice.Viewport; topViewport = defaultViewport; topViewport.X = 0; topViewport.Y = 0; topViewport.Width = ViewportWidth; topViewport.Height = ViewportHeight; topViewport.MinDepth = 0; topViewport.MaxDepth = 1; sideViewport = defaultViewport; sideViewport.X = ViewportWidth; sideViewport.Y = 0; sideViewport.Width = ViewportWidth; sideViewport.Height = ViewportHeight; sideViewport.MinDepth = 0; sideViewport.MaxDepth = 1; frontViewport = defaultViewport; frontViewport.X = 0; frontViewport.Y = ViewportHeight; frontViewport.Width = ViewportWidth; frontViewport.Height = ViewportHeight; frontViewport.MinDepth = 0; frontViewport.MaxDepth = 1; perspectiveViewport = defaultViewport; perspectiveViewport.X = ViewportWidth; perspectiveViewport.Y = ViewportHeight; perspectiveViewport.Width = ViewportWidth; perspectiveViewport.Height = ViewportHeight; perspectiveViewport.MinDepth = 0; perspectiveViewport.MaxDepth = 1; } Viewports & Split Screen Games
  • 89. • Initialize() protected override void Initialize() { base.Initialize(); int ViewportWidth = 200; int ViewportHeight = 200; Viewport defaultViewport = GraphicsDevice.Viewport; topViewport = defaultViewport; topViewport.X = 0; topViewport.Y = 0; topViewport.Width = ViewportWidth; topViewport.Height = ViewportHeight; topViewport.MinDepth = 0; topViewport.MaxDepth = 1; sideViewport = defaultViewport; sideViewport.X = ViewportWidth; sideViewport.Y = 0; sideViewport.Width = ViewportWidth; sideViewport.Height = ViewportHeight; sideViewport.MinDepth = 0; sideViewport.MaxDepth = 1; frontViewport = defaultViewport; frontViewport.X = 0; frontViewport.Y = ViewportHeight; frontViewport.Width = ViewportWidth; frontViewport.Height = ViewportHeight; frontViewport.MinDepth = 0; frontViewport.MaxDepth = 1; perspectiveViewport = defaultViewport; perspectiveViewport.X = ViewportWidth; perspectiveViewport.Y = ViewportHeight; perspectiveViewport.Width = ViewportWidth; perspectiveViewport.Height = ViewportHeight; perspectiveViewport.MinDepth = 0; perspectiveViewport.MaxDepth = 1; } Viewports & Split Screen Games
  • 90. Viewports & Split Screen Games
  • 91. Viewports & Split Screen Games
  • 92. Viewports & Split Screen Games
  • 93. Viewports & Split Screen Games
  • 94. Viewports & Split Screen Games
  • 95. Viewports & Split Screen Games
  • 96. Viewports & Split Screen Games • Draw()protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); Viewport original = graphics.GraphicsDevice.Viewport; graphics.GraphicsDevice.Viewport = topViewport; //GraphicsDevice.Clear(Color.Black); DrawModel(model, world, topView, projection); graphics.GraphicsDevice.Viewport = sideViewport; //GraphicsDevice.Clear(Color.Black); DrawModel(model, world, sideView, projection); graphics.GraphicsDevice.Viewport = frontViewport; //GraphicsDevice.Clear(Color.Black); DrawModel(model, world, frontView, projection); graphics.GraphicsDevice.Viewport = perspectiveViewport; //GraphicsDevice.Clear(Color.Black); DrawModel(model, world, perspectiveView, projection); GraphicsDevice.Viewport = original; base.Draw(gameTime); }
  • 97. Viewports & Split Screen Games • Draw()protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); Viewport original = graphics.GraphicsDevice.Viewport; graphics.GraphicsDevice.Viewport = topViewport; //GraphicsDevice.Clear(Color.Black); DrawModel(model, world, topView, projection); graphics.GraphicsDevice.Viewport = sideViewport; //GraphicsDevice.Clear(Color.Black); DrawModel(model, world, sideView, projection); graphics.GraphicsDevice.Viewport = frontViewport; //GraphicsDevice.Clear(Color.Black); DrawModel(model, world, frontView, projection); graphics.GraphicsDevice.Viewport = perspectiveViewport; //GraphicsDevice.Clear(Color.Black); DrawModel(model, world, perspectiveView, projection); GraphicsDevice.Viewport = original; base.Draw(gameTime); }
  • 98. Viewports & Split Screen Games • Draw()protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); Viewport original = graphics.GraphicsDevice.Viewport; graphics.GraphicsDevice.Viewport = topViewport; //GraphicsDevice.Clear(Color.Black); DrawModel(model, world, topView, projection); graphics.GraphicsDevice.Viewport = sideViewport; //GraphicsDevice.Clear(Color.Black); DrawModel(model, world, sideView, projection); graphics.GraphicsDevice.Viewport = frontViewport; //GraphicsDevice.Clear(Color.Black); DrawModel(model, world, frontView, projection); graphics.GraphicsDevice.Viewport = perspectiveViewport; //GraphicsDevice.Clear(Color.Black); DrawModel(model, world, perspectiveView, projection); GraphicsDevice.Viewport = original; base.Draw(gameTime); }
  • 99. Viewports & Split Screen Games • Draw()protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); Viewport original = graphics.GraphicsDevice.Viewport; graphics.GraphicsDevice.Viewport = topViewport; //GraphicsDevice.Clear(Color.Black); DrawModel(model, world, topView, projection); graphics.GraphicsDevice.Viewport = sideViewport; //GraphicsDevice.Clear(Color.Black); DrawModel(model, world, sideView, projection); graphics.GraphicsDevice.Viewport = frontViewport; //GraphicsDevice.Clear(Color.Black); DrawModel(model, world, frontView, projection); graphics.GraphicsDevice.Viewport = perspectiveViewport; //GraphicsDevice.Clear(Color.Black); DrawModel(model, world, perspectiveView, projection); GraphicsDevice.Viewport = original; base.Draw(gameTime); }
  • 100. Viewports & Split Screen Games • Draw()protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); Viewport original = graphics.GraphicsDevice.Viewport; graphics.GraphicsDevice.Viewport = topViewport; //GraphicsDevice.Clear(Color.Black); DrawModel(model, world, topView, projection); graphics.GraphicsDevice.Viewport = sideViewport; //GraphicsDevice.Clear(Color.Black); DrawModel(model, world, sideView, projection); graphics.GraphicsDevice.Viewport = frontViewport; //GraphicsDevice.Clear(Color.Black); DrawModel(model, world, frontView, projection); graphics.GraphicsDevice.Viewport = perspectiveViewport; //GraphicsDevice.Clear(Color.Black); DrawModel(model, world, perspectiveView, projection); GraphicsDevice.Viewport = original; base.Draw(gameTime); }
  • 101. Viewports & Split Screen Games • “App2-ViewportsFinished”
  • 105. Picking Objects public Ray CalculateRay(Vector2 mouseLocation, Matrix view, Matrix projection, Viewport viewport) { Vector3 nearPoint = viewport.Unproject( new Vector3(mouseLocation.X, mouseLocation.Y, 0.0f), projection, view, Matrix.Identity); Vector3 farPoint = viewport.Unproject( new Vector3(mouseLocation.X, mouseLocation.Y, 1.0f), projection, view, Matrix.Identity); Vector3 direction = farPoint - nearPoint; direction.Normalize(); return new Ray(nearPoint, direction); }
  • 106. Picking Objects public bool Intersects(Vector2 mouseLocation, Model model, Matrix world, Matrix view, Matrix projection, Viewport viewport) { for (int index = 0; index < model.Meshes.Count; index++) { BoundingSphere sphere = model.Meshes[index].BoundingSphere; sphere = sphere.Transform(world); float? distance = IntersectDistance(sphere, mouseLocation, view, projection, viewport); if (distance != null) { return true; } } return false; }
  • 107. Picking Objects public float? IntersectDistance(BoundingSphere sphere, Vector2 mouseLocation, Matrix view, Matrix projection, Viewport viewport) { Ray mouseRay = CalculateRay(mouseLocation, view, projection, viewport); return mouseRay.Intersects(sphere); }
  • 109. Take a Look on my other courses @ http://www.slideshare.net/ZGTRZGTR Available courses to the date of this slide: