<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2528585379972323177</id><updated>2011-11-27T16:16:43.907-08:00</updated><title type='text'>Efron's XNA journey</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://efron-xna.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2528585379972323177/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://efron-xna.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>efron</name><uri>http://www.blogger.com/profile/03400714319445274705</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2528585379972323177.post-1398264991339356993</id><published>2006-11-28T15:58:00.000-08:00</published><updated>2006-11-28T16:49:58.547-08:00</updated><title type='text'>Rendering a textured cube</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger2/5993/308665207516152/1600/colored-cube.0.jpg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="http://photos1.blogger.com/blogger2/5993/308665207516152/200/colored-cube.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;XNA Game Studio Express provides a number of helpful how-to guides. One such guide demonstrates the use of the framework's default material class "BasicEffect" to render a cube using 3D primitives.&lt;br /&gt;&lt;br /&gt;When you run the sample code, you will see a colored cube rendered on screen (seen on the right).&lt;br /&gt;&lt;br /&gt;That great. So now how do you render a bitmap textured cube?&lt;br /&gt;&lt;br /&gt;Initially, I got a black cube instead of the expected rendered one. After tinkering around, I have managed to load a bitmap and assigned it to the basic effect material.&lt;br /&gt;&lt;br /&gt;Here are a couple of learning points:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;To use bitmap textures, you need to :&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Assign a &lt;span style="font-weight: bold; font-style: italic;"&gt;loaded &lt;/span&gt;texture to the BasicEffect.Texture property&lt;/li&gt;&lt;li&gt;Enable texture rendering, set BasicEffect.TextureEnabled to true&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;The framework calls Initialize() &lt;span style="font-weight: bold; font-style: italic;"&gt;before &lt;/span&gt;LoadGraphicsContent(). Hence you should only assign your texture reference to the basic-effect material &lt;span style="font-weight: bold; font-style: italic;"&gt;after &lt;/span&gt;you have loaded the bitmap.&lt;/li&gt;&lt;/ol&gt;Here is a screenshot of modded cube on the right. You can also download the project files here&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger2/5993/308665207516152/1600/textured-cube.jpg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="http://photos1.blogger.com/blogger2/5993/308665207516152/200/textured-cube.jpg" alt="" border="0" /&gt;&lt;/a&gt; &lt;a href="http://files.filefront.com/UseBasicEffectzip/;6264570;;/fileinfo.html"&gt;(UseBasicEffect.zip)&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Please let me know if the link works and other comments.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2528585379972323177-1398264991339356993?l=efron-xna.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://efron-xna.blogspot.com/feeds/1398264991339356993/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2528585379972323177&amp;postID=1398264991339356993' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2528585379972323177/posts/default/1398264991339356993'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2528585379972323177/posts/default/1398264991339356993'/><link rel='alternate' type='text/html' href='http://efron-xna.blogspot.com/2006/11/rendering-textured-cube.html' title='Rendering a textured cube'/><author><name>efron</name><uri>http://www.blogger.com/profile/03400714319445274705</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2528585379972323177.post-2438804723676368608</id><published>2006-11-20T16:06:00.001-08:00</published><updated>2006-11-20T17:07:21.217-08:00</updated><title type='text'>Getting Mouse Input for the XNA 3D Tutorial</title><content type='html'>As mentioned in my previous post, there is support for mouse input in the XNA framework. I have added code to check for mouse input in the UpdateInput() method of Game1.cs as shown below:&lt;br /&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; UpdateInput()&lt;br /&gt;{&lt;br /&gt;    &lt;span class="rem"&gt;//get the gamepad state&lt;/span&gt;&lt;br /&gt;    GamePadState current_state = GamePad.GetState(PlayerIndex.One);&lt;br /&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (current_state.IsConnected)&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="rem"&gt;//original gamepad checking goes here&lt;/span&gt;&lt;br /&gt;    }&lt;br /&gt;    &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;br /&gt;    {&lt;br /&gt;        MouseState mouseState = Mouse.GetState();&lt;br /&gt;        Rectangle rt = &lt;span class="kwrd"&gt;this&lt;/span&gt;.Window.ClientBounds;&lt;br /&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (mouseState.LeftButton == ButtonState.Pressed)&lt;br /&gt;        {&lt;br /&gt;            modelrotation -= (mouseState.X - rt.Width/2) * 0.01f;&lt;br /&gt;             &lt;span class="rem"&gt;//create some velocity if the right trigger is down&lt;/span&gt;&lt;br /&gt;            Vector3 modelvelocity_add = Vector3.Zero;&lt;br /&gt;             &lt;span class="rem"&gt;//find out what direction we should be thrusting, using rotation&lt;/span&gt;&lt;br /&gt;            modelvelocity_add.X = -(&lt;span class="kwrd"&gt;float&lt;/span&gt;)Math.Sin(modelrotation);&lt;br /&gt;            modelvelocity_add.Z = -(&lt;span class="kwrd"&gt;float&lt;/span&gt;)Math.Cos(modelrotation);&lt;br /&gt;             &lt;span class="rem"&gt;//finally, add this vector to our velocity.&lt;/span&gt;&lt;br /&gt;            modelvelocity += modelvelocity_add;&lt;br /&gt;        }&lt;br /&gt;        &lt;span class="rem"&gt;//in case you get lost, warp back to the center&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (mouseState.RightButton == ButtonState.Pressed)&lt;br /&gt;        {&lt;br /&gt;            modelposition = Vector3.Zero;&lt;br /&gt;            modelvelocity = Vector3.Zero;&lt;br /&gt;            modelrotation = 0.0f;&lt;br /&gt;        }&lt;br /&gt;         &lt;span class="rem"&gt;//set some audio based on whether we're pressing trigger&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (mouseState.LeftButton == ButtonState.Pressed)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (engine_sound == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;            {&lt;br /&gt;                engine_sound = sound_bank.GetCue(&lt;span class="str"&gt;"engine_2"&lt;/span&gt;);&lt;br /&gt;                engine_sound.Play();&lt;br /&gt;            }&lt;br /&gt;             &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (engine_sound.IsPaused)&lt;br /&gt;            {&lt;br /&gt;                engine_sound.Resume();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (engine_sound != &lt;span class="kwrd"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; engine_sound.IsPlaying)&lt;br /&gt;            {&lt;br /&gt;                engine_sound.Pause();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;         &lt;span class="rem"&gt;//in case you get lost, press A to warp back to the center&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (mouseState.RightButton == ButtonState.Pressed)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="rem"&gt;//make a sound when we warp&lt;/span&gt;&lt;br /&gt;            sound_bank.PlayCue(&lt;span class="str"&gt;"hyperspace_activate"&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;         Mouse.SetPosition(rt.Width / 2, rt.Height / 2);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Hold down the left button of the mouse adds thrust to the space ship. Turning the mouse while holding down the left button rotates the ship. Right click to warp the ship back to the center of the screen.&lt;br /&gt;&lt;br /&gt;The first part of the code computes the ship's velocity based on the mouse's position and button states. The second added the appropriate audio cues based on the mouse events.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2528585379972323177-2438804723676368608?l=efron-xna.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://efron-xna.blogspot.com/feeds/2438804723676368608/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2528585379972323177&amp;postID=2438804723676368608' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2528585379972323177/posts/default/2438804723676368608'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2528585379972323177/posts/default/2438804723676368608'/><link rel='alternate' type='text/html' href='http://efron-xna.blogspot.com/2006/11/getting-mouse-input-for-xna-3d-tutorial_20.html' title='Getting Mouse Input for the XNA 3D Tutorial'/><author><name>efron</name><uri>http://www.blogger.com/profile/03400714319445274705</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2528585379972323177.post-578970676723516832</id><published>2006-11-19T20:00:00.000-08:00</published><updated>2006-11-20T16:06:30.944-08:00</updated><title type='text'>Getting Keyboard Input for the XNA 3D Tutorial</title><content type='html'>If you tried out the 3D tutorial, you will notice that it is geared towards the Xbox. The tutorial introduces the framework's support for Xbox controllers.&lt;br /&gt;&lt;br /&gt;That's ok, except that I am trying to learn how to use XNA to develop Windows games and applications. It turns out that there is support for keyboard and mouse as well.&lt;br /&gt;&lt;br /&gt;I have added the following lines of code into the beginning of the &lt;span style="color: rgb(0, 153, 0);"&gt;Update()&lt;/span&gt; method of the &lt;span style="color: rgb(0, 153, 0);"&gt;Game1.cs&lt;/span&gt; class file.&lt;br /&gt;&lt;br /&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;   KeyboardState keyState = Keyboard.GetState();&lt;br /&gt;   &lt;span class="kwrd"&gt;if&lt;/span&gt; (keyState.IsKeyDown(Keys.Escape))&lt;br /&gt;      &lt;span class="kwrd"&gt;this&lt;/span&gt;.Exit();&lt;br /&gt;      &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now, you can terminate the runtime window by hitting the Escape key.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2528585379972323177-578970676723516832?l=efron-xna.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://efron-xna.blogspot.com/feeds/578970676723516832/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2528585379972323177&amp;postID=578970676723516832' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2528585379972323177/posts/default/578970676723516832'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2528585379972323177/posts/default/578970676723516832'/><link rel='alternate' type='text/html' href='http://efron-xna.blogspot.com/2006/11/getting-keyboard-input-for-xna-3d.html' title='Getting Keyboard Input for the XNA 3D Tutorial'/><author><name>efron</name><uri>http://www.blogger.com/profile/03400714319445274705</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2528585379972323177.post-14096370943250986</id><published>2006-11-19T16:31:00.000-08:00</published><updated>2006-11-20T15:49:47.692-08:00</updated><title type='text'>Spacewar (Windows) Full Screen Tip</title><content type='html'>Just a tip, you can toggle between full screen and windowed mode of the Spacewar demo by hitting the Alt-Enter combo.&lt;br /&gt;&lt;br /&gt;Don't think there is any help documentation published but you can figure this out by looking at the following code fragment from &lt;span style="color: rgb(0, 153, 0);"&gt;SpacewarGame.cs&lt;/span&gt;:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(0, 102, 0);font-family:courier new;" &gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Update(GameTime gameTime)&lt;br /&gt;{&lt;br /&gt;   keyState = Keyboard.GetState();&lt;br /&gt;   XInputHelper.Update(keyState);&lt;br /&gt;&lt;br /&gt;   &lt;span class="kwrd"&gt;if&lt;/span&gt; ((keyState.IsKeyDown(Keys.RightAlt) ||&lt;br /&gt;        keyState.IsKeyDown(Keys.LeftAlt)) &amp;amp;&amp;amp;&lt;br /&gt;        keyState.IsKeyDown(Keys.Enter) &amp;amp;&amp;amp;&lt;br /&gt;        !justWentFullScreen)&lt;br /&gt;   {&lt;br /&gt;      ToggleFullScreen();&lt;br /&gt;      justWentFullScreen = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;br /&gt;   }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Btw, I am looking at the windows code for Spacewar. So whatever Spacewar post will refer to just that.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2528585379972323177-14096370943250986?l=efron-xna.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://efron-xna.blogspot.com/feeds/14096370943250986/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2528585379972323177&amp;postID=14096370943250986' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2528585379972323177/posts/default/14096370943250986'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2528585379972323177/posts/default/14096370943250986'/><link rel='alternate' type='text/html' href='http://efron-xna.blogspot.com/2006/11/spacewar-windows-full-screen-tip.html' title='Spacewar (Windows) Full Screen Tip'/><author><name>efron</name><uri>http://www.blogger.com/profile/03400714319445274705</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2528585379972323177.post-8841859222907319327</id><published>2006-11-16T16:41:00.000-08:00</published><updated>2006-11-16T17:09:00.880-08:00</updated><title type='text'>Space War Class Relationship Diagram</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger2/5993/308665207516152/1600/SpaceWarObjectModel.jpg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="http://photos1.blogger.com/blogger2/5993/308665207516152/320/SpaceWarObjectModel.jpg" alt="" border="0" /&gt;&lt;/a&gt;I was pleasantly suprised that Microsoft has released such a complete example to illustrate the capability of the XNA framework. Enuff said.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;As my first look at the Space War example, I have mapped out the class relationships. Specifically, the inheritance relationships between the classes. I have outlined a few 'containment' relationships as well where they don't clutter up the diagram.&lt;br /&gt;&lt;br /&gt;Let me know if it is of any help to you.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2528585379972323177-8841859222907319327?l=efron-xna.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://efron-xna.blogspot.com/feeds/8841859222907319327/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2528585379972323177&amp;postID=8841859222907319327' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2528585379972323177/posts/default/8841859222907319327'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2528585379972323177/posts/default/8841859222907319327'/><link rel='alternate' type='text/html' href='http://efron-xna.blogspot.com/2006/11/space-war-class-relationship-diagram.html' title='Space War Class Relationship Diagram'/><author><name>efron</name><uri>http://www.blogger.com/profile/03400714319445274705</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry></feed>
