Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
The Monarch
Jul 8, 2006

Can anyone point me to a good, recent directX tutorial/website that won't make me pay for anything? I have a copy of visual c++ and the directx sdk, but a lot of the tutorials I'm finding are pretty out of date.

Also, does anyone know of a good website based around the quake 3 source code? I'm looking through it but most of it's flying over my head, and some good explanations about what's doing what would be nice.

Adbot
ADBOT LOVES YOU

The Monarch
Jul 8, 2006

Can someone send me a link that outlines (in a non coding language specific way) what I need to do for a first person camera? I'm just thinking about the best way to do it (I'm using XNA) but I'd like to see some other stuff and get some ideas.

Also, for anyone experienced with XNA, is there a link that explains the steps that XNA does take to render a model? I'm trying to figure out how to have my rendering in a seperate class, or at least be able to prepare the model (so my game.cs isn't filled with dozens of different model files and stuff), but all the tutorials I find are just "this is how you draw a model: copy this code in this method, this in that, and this code in the draw method and it works". I also have no idea what this does, and how I can break it apart:

code:
foreach (ModelMesh mesh in terrainModel.Meshes)
            {
                // This is where the mesh orientation is set, as well as our camera and projection.
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateRotationY(modelRotation)
                        * Matrix.CreateTranslation(modelPosition);
                    effect.View = Matrix.CreateLookAt(cameraPosition, cameraTarget, Vector3.Up);
                    effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f),
                        aspectRatio, 1.0f, 10000.0f);
                }
                // Draw the mesh, using the effects set above.
                mesh.Draw();
            }
so I basically just copy and paste that for each model that I need to draw, which I know isn't right. I'm learning a lot with XNA but my programming experience is really low so a lot of this stuff is new to me.

The Monarch fucked around with this message at 00:26 on Apr 28, 2008

The Monarch
Jul 8, 2006

Hover posted:

Alright, I'm going to try to break the code apart for you. I've never used XNA specifically but I'm learning DirectX and have a fairly good understanding of the process of rendering something in 3D, so hopefully I can give you a good head start.

XNA stuff here, but it seems like this is going through all the meshes in whatever terrainModel is, which I assume is the object you're trying to render. Then it's going through each effect, and I have no idea what that is. But moving on...

Enables default lighting. Who would have thought?

Sets the location of the object. It first applies everything from its parent, then rotates it as it needs to be rotated, then translates it to where it needs to be. However, the rotation only seems to be around the Y axis. Again, I don't know XNA, but this seems like it could be problematic.

Set the camera up. You only need to do this once, not for each model you're putting in the program, assuming XNA doesn't have some crazy thing for cameras.

Sets the perspective. Like the camera, this only needs to be done once assuming I'm not missing something.

And then it draws. Hopefully this is helpful. If I've messed up anywhere, let me know. Like I said, I'm only learning DirectX but I know graphics a bit and some of this stuff seemed familiar.

Thanks, I'm starting to get the hang of this and even though I sort of new what you're saying here already splitting it up did help. I still don't like the fact that I have to start this whole loop:

code:
foreach (ModelMesh mesh in terrainModel.Meshes) {
   foreach (BasicEffect effect in mesh.Effects) {
for each model (minus the camera and projection stuff) but I guess there's no other way.

The Monarch
Jul 8, 2006

Hover posted:

Well you could just put it in another loop that iterates through a list of models. It's far less ugly and easier to maintain, and would do the same thing. Like:
code:
foreach (Model model in myBigListOfModels) { //the other two loops here }
Otherwise, yeah, what the guy a bit higher up said or the loops. You have to go through every mesh so you have to go through the loops. But you might as well make it nice while you do it.

Yea this is what I'm doing now (a loop that goes through a list of models), I was just wondering if there were any other ways I could break it up or make it cleaner looking.

The Monarch
Jul 8, 2006

I'm having a weird issue with XNA. I'm trying to load a Texture2D, but it's not working for some reason.

creaturePath can be ignored, and ArtPath is equal to "\\Art\\Dynamic\\Creatures\\Dog\\".

code:
        public void LoadAnimations(ContentManager content, String creaturePath)
        {

            // Load paths to animation
            String[] filelist = Directory.GetFiles(content.RootDirectory + ArtPath);

            // Add animations to animation dictionary
            foreach (String animationPath in filelist)
            {
                // Get file name
                String animationName = System.Text.RegularExpressions.Regex.Replace
                    (animationPath, @"\\", ",");
                animationName = System.Text.RegularExpressions.Regex.Split
                    (animationName, ",")[5];

                animationName = System.Text.RegularExpressions.Regex.Split
                    (animationName, ".xnb")[0];

                String path = ArtPath + animationName;
                // Load animation texture
                Texture2D animationTexture = content.Load<Texture2D>(path); // <--Error

                // Get frame count
                int frameCount = Convert.ToInt16
                    (animationName[creaturePath.Length].ToString());

                // Get frame width and height
                int frameWidth = (int)(animationTexture.Width / frameCount);
                int frameHeight = (int)(animationTexture.Height);

                // Load the animation
                Animation creatureAnimation = new Animation();
                creatureAnimation.Initialize(animationTexture, Position, frameWidth,
                    frameHeight, frameCount, AnimationSpeed, Color.White, 
                    AnimationScale, true);

                // Add animation to animation dictionary
                // Convert name to dictionary key
                animationName = System.Text.RegularExpressions.Regex.Split
                    (animationName, frameCount.ToString())[1];
                CreatureAnimations.Add(animationName, creatureAnimation);
            }
        }
The specific error I'm getting is this:

Error loading "\Art\Dynamic\Creatures\Dog\dog3_idle_n". Cannot open file.

I've added the file through Visual studio and if I remove the files and re-add them the proper .xnb files are created. Can anyone tell me what's up?

Edit: Nevermind. I did more reading about how content managers and stuff work so now It's working fine. I'm just passing the content service provider from the main "Game1.cs" class to my creature class, and making a new content manager there.

The Monarch fucked around with this message at 05:22 on Oct 11, 2011

The Monarch
Jul 8, 2006

This isn't a programming question, but I was wondering if someone could help me out with importing a rigged mesh into UE4 from 3ds max. I can't figure out what I'm doing wrong and I'm kinda stuck on step zero.

I have a basic character with a simple rig, and as far as I can tell I have the root bone set up properly at the origin (like in this tutorial). In 3ds max, skinning and animating and everything works fine.



I go to import it into UE4, and I don't get any errors or warnings (apart from the one about smoothing groups). However the skeleton comes out wrong:



For some reason the pelvis bone takes up the space between the root and where the pelvis should start, and all the other bones filter back. They're still weighted properly, so moving the bone marked larm.r moves the vertices on the lower arm and everything. As far as I can tell I'm doing exactly what that tutorial does (and a few other ones I've looked at), and after a day of googling I'm at a loss. Anyone know what's up?

Adbot
ADBOT LOVES YOU

The Monarch
Jul 8, 2006


Hey thanks. I see now that everything's actually fine with the skeleton. My animations weren't importing correctly from Blender and I guess I assumed it was a problem with the skeleton.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply