XNA Game Development Forums are located here: thehazymind.com/smf

Archive for February, 2006

Another V-Day down the tube

Wednesday, February 15th, 2006

Well, that’s two years in a row now that I have managed to be single on Valentine’s Day. Although it is the cheaper way to go, it is definately not the most pleasant way to spend the day. Of course, I wasn’t really all that worried about today in general. What I am worried about is what I am going to do with these reservations I have at Chico Hot Springs the first weekend of March.

It would have been a great anniversary weekend but as the song says, “but because there’s no more you, there’s no more aniversary.” You being the reason I made the reservations in the first place. I sure as hell am not spending the weekend there alone, but I don’t want to just ask some random cute girl to go with me since that will immediately sound:

  1. A little creepy
  2. A little like I am trying to get laid…
  3. A little like I am about to kidnap someone
  4. Really Pathetic
  5. Like the most elaborate pickup line ever

Regardless of how many of the above are true… I am still not going alone. I would just hate to have to cancel them as they are very difficult to get without calling insanely far in advance (at least the private cabin that I got is…) Oh, well. I guess I’ll just look for someone who won’t think it is too creepy/weird/pickupliney and hope for the best.

Giving ourselves some Objects for Play

Monday, February 6th, 2006

One thing that I have decided is missing from our HMMesh class is a way to generate simple default meshes that come with DirectX like the torus and teapot (instead of adding lines to our class everytime we want to test a shader with a round object like I had been doing.) The changes neccessary for this function are very minimal, and so this will more than likely be the shortest tutorial of the whole series, but we will probably use a lot of these objects when testing our physics later.

Step 1: Adding a Default Object Constructor

To let ourselves pick from the 5 included default meshes, I decided to simply duplicate the constructor in HMMesh and take an integer instead of a string for the first parameter. Here is the new code:

private int myType = -1; public HMMesh(int meshType, Vector3 pos, Vector3 rot, Vector3 scl, Device myDevice) { myType = meshType; myPosition = pos; myRotation = rot; myScaling = scl; ReloadResources(myDevice); myTimer = new FrameworkTimer(); myTimer.Start(); } // At the top of the old constructor myType = -1;

Now that we have our constructor set up, we will need to modify the ReloadResources() function to implement our new default object behavior. This is as simple as adding an if else with a switch inside. The top of ReloadResources now looks like this:

ExtendedMaterial[] mtrls = null; if(myType != -1) { switch(myType) { case 0: myMesh = Mesh.Box(myDevice, 1, 1, 1); break; case 1: myMesh = Mesh.Cylinder(myDevice, 1, 1, 3, 32, 1); break; case 2: myMesh = Mesh.Sphere(myDevice, 1, 32, 32); break; case 3: myMesh = Mesh.Teapot(myDevice); break; case 4: myMesh = Mesh.Torus(myDevice, 0.25f, 0.5f, 32, 32); break; default: myMesh = Mesh.Teapot(myDevice); break; } myMaterials = new Material[1]; myTextures = new Texture[1]; } else { myMesh = Mesh.FromFile(myPath, MeshFlags.Managed, myDevice, out mtrls); }

There you have it. A very simple way to add quite a few new objects to the world. Now I just have to think of a use for them!