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
MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
After about a day of trying to get skinned meshes in HLSL working I learned about PIX and discovered that you do in fact need to set vertex declarations (heh). This is what I have so far:



That's supposed to be a man-shaped figure, so something's off, and I assume it's my bone transforms. They should be matrices that transform the bone from bone space to world space, correct?

edit: reading this paper shows me this equation:


I'm assuming that the first matrix is one that transforms a bone from bind-pose to world, but I don't know what the second matrix represents.

MasterSlowPoke fucked around with this message at 13:03 on Jul 24, 2008

Adbot
ADBOT LOVES YOU

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
Actually, that is an MD5 model, but I am computing a base pose and base model at load time as I've never seen any other description on how to do it. I'm also want to preform this on the graphics card, not the cpu. I've actually done it on the cpu before and for some reason it worked a lot easier there.

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
After a lot of teaking, I've got it pretty much working! My only hangup? It's flipped!


In engine, In editor

I've been messing around but I can't seem to get it to flip back around.

edit: Im at my wit's end with this, I can't get the model to flip back, the only way to get it to display right it to flip everything in the editor.

MasterSlowPoke fucked around with this message at 23:04 on Jul 25, 2008

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through


Yeah, it was definitely the projection that caused the error.

midnite posted:

Does the editor work in the same handedness and coordinate system you are? You might have to do some conversion on export to convert from right-handed to left-handed or vice-versa. Does the positive X, Y and Z axis go in the same directions are in your engine? If not you'll have to flip the necessary coordinates in your verts, normals and rotations.

I'm not sure what handedness Blender uses, but I guess Doom 3 uses a left handed system as that was what the MD5 exporter used. Either that, or when I changed the model componets from z-up to y-up that also changed the handedness. Either way I finally figured out where to transform the model with a -1 scale on the X axis: in the middle of the bone-to-world transform.

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
In my Quake 3 BSP loader I'm trying to get frustum culling to work but the results are far too overzealous. For example, take this window:

http://www.craigsniffen.com/bsp/asintended.png

When I alter my view a little bit, the U shaped frame is culled.

http://www.craigsniffen.com/bsp/malculling.png

At first I thought that I was computing the bounding boxes wrong, so I decided to draw them to the screen. Suprisingly the boxes appear to be in the right place (the box that I believe houses the U frame is highlighted in red). If that bounding box wasn't on the screen, I shouldn't be able to see it when I draw it, correct? Here's the relevant code in case there is a dumb error:

code:
public void RenderLevel(Vector3 cameraPosition, Matrix viewMatrix, Matrix projMatrix, GameTime gameTime, GraphicsDevice graphics) 
{ 
   BoundingFrustum frustum = new BoundingFrustum(viewMatrix * projMatrix); 
 
   BasicEffect beffect = new BasicEffect(graphics, null); 
   beffect.VertexColorEnabled = true; 
   beffect.World = Matrix.Identity; 
   beffect.View = viewMatrix; 
   beffect.Projection = projMatrix; 
 
   foreach(Q3BSP leaf in leafs) 
   { 
      if (!frustum.Intersects(leaf.Bounds)) 
      { 
         RenderBoundingBox(leaf.Bounds, beffect, graphics); 
         continue; 
      } 
       
      // add leaf to render list 
    } 
}

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
I'm trying to figure out the best process to use to render a BSP with DirectX. The traditional way to render a BSP is the find what polygons (leafs) are visible from the camera and render them as you find them. This works fine and dandy with OpenGL, but the relatively high cost of Draw calls with DirectX makes me weary.

I'm thinking that I should instead store each polygon in a buffer (delineated by the texture used) when visible leafs are found, then render each buffer at the end. Still, this seems to be a lot of work for the CPU to do each frame.

I'm also thinking of just making static buffers for each texture and rendering them all each frame, letting giving the hardware the task of culling nonvisible leaves in the vertex shader. I'm having troubles determining what to do with the lightmaps in that process. I suppose I could stitch all of the lightmaps into one large map, but them I'm limiting the number of lightmaps I could have (probably about 16 128x128 maps).

Any thoughts on how I should go about this? Also, do anyone find that GameDev.net's forums are absolutely worthless for getting help?

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through

Entheogen posted:

How do I reject by polygon? Am I just missing some simple OpenGL call?

I think me means not worrying about what way the polygons face and setting a CullMode, as the graphics card is faster than however you'd determine front facing polygons.

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
don't give dwarf fortress graphics or I might get sucked into playing it forever

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
If you already know C, Frank Luna's "Introduction to 3D Game Programming with DirectX 9.0c: A Shader Approach" is probably the best graphics introduction I've read. Even though I'm using XNA now I still refer to it all the time.

http://www.amazon.com/Introduction-Game-Programming-Direct-9-0c/dp/1598220160/ref=sr_1_1?ie=UTF8&s=books&qid=1226473567&sr=1-1

Actually looking online I see he's got a DX10 book out now, anyone checked it out yet?

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
What version of OpenGL are you using? From this table it looks like the hardware only supports OpenGl 1.4.

http://en.wikipedia.org/wiki/Intel_GMA#Table_of_GMA_graphics_cores_and_chipsets

I've never used OpenGL or the FFP so maybe this has nothing to do with your problem, though.

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
If you learn Blender it's really powerful but if you ever want to learn another modeler you're have to forget everything you know. The UI is completely different from anything else.

It's probably my favorite modeler, although I am a programmer so my opinion isn't all that useful.

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through

not a dinosaur posted:

Yeah, this answers my question. Sounds like a custom format is the way to go. Thanks everyone :)

If you've never imported a 3D model format before you might want to go with someone else's proprietary format to learn the ropes. Id's MD5 is a pretty good place to start - it's fairly simple but still modern.

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
Just make a 1024x1024 texture, and draw just set the UV coodinates on your 1024x768 quad to keep from stretching. You don't have to utilize the whole thing texture.

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through

Avenging Dentist posted:

Savagely optimize it and put other (small) textures in the space that would be offscreen for the overlay. :colbert:

or split your overlay into multiple pieces, compact the texture to as small as it can go, and draw multiple quads per pass

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
just keep cutting stuff until the framerate goes over 1fps

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
I've got a model that rotates along the Y axis and that model has a bounding box defined by a maximum and minimum point that I would like to follow it. I thought that simply transforming the two points by the same rotation matrix would do it but apparently it doesn't work that way.

Bounding box without rotation:

After rotation:


Any ideas on what I actually need to transform it by to keep it inline?

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
The bounding box is already computed per-frame and is interpolated inbetween. I'm simply performing a rotation about the Y axis on the model's world matrix. In fact, this method does in fact work when I transform the bounding box's physical geometry, but I need to get the actual values for my collision testing.

edit: I suppose I might as well provide some code. This is the code that sets the position of each of the drawn bounding box's positions:
code:
            bounds = animationController.GetMaximumBounds();

            //bounds.Minimum = Vector3.Transform(bounds.Minimum, Matrix.CreateRotationY(rotation));
            //bounds.Maximum = Vector3.Transform(bounds.Maximum, Matrix.CreateRotationY(rotation));

            boundingBoxVertices[0].Position = bounds.Maximum;
            boundingBoxVertices[1].Position = new Vector3(bounds.Maximum.X, bounds.Maximum.Y, bounds.Minimum.Z);
            boundingBoxVertices[2].Position = new Vector3(bounds.Minimum.X, bounds.Maximum.Y, bounds.Minimum.Z);
            boundingBoxVertices[3].Position = new Vector3(bounds.Minimum.X, bounds.Maximum.Y, bounds.Maximum.Z);

            boundingBoxVertices[4].Position = new Vector3(bounds.Maximum.X, bounds.Minimum.Y, bounds.Maximum.Z);
            boundingBoxVertices[5].Position = new Vector3(bounds.Maximum.X, bounds.Minimum.Y, bounds.Minimum.Z);
            boundingBoxVertices[6].Position = bounds.Minimum;
            boundingBoxVertices[7].Position = new Vector3(bounds.Minimum.X, bounds.Minimum.Y, bounds.Maximum.Z);

            boundingBoxVertexBuffer.SetData<VertexPositionColor>(boundingBoxVertices);
And the code where I set the world transform in the draw stage:
code:
boundingBoxEffect.Parameters["World"].SetValue(Matrix.CreateRotationY(rotation)*Matrix.CreateTranslation(worldPosition));
//boundingBoxEffect.Parameters["World"].SetValue(Matrix.CreateTranslation(worldPosition));
bounds is just a struct that contains two 3D vectors. The way the code is written now, the bounding box looks fine. Uncommenting the commented out code in both sections gives me the problem. Normally it would be silly to transform it part way like that, but I need to do this in another section where I determine the collision boundaries. The collision boundries have to be a box in object space.

MasterSlowPoke fucked around with this message at 02:04 on Feb 13, 2009

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
Ah, of course. Rotating two points won't give me an OBB, and that wouldn't work for my collision detection regardless. Thanks.

efficiency

MasterSlowPoke fucked around with this message at 13:40 on Feb 13, 2009

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
This is how I do a FPS camera. It's in C# but you should be able to translate it.
code:
// Determine change in camera angle this frame 
cameraAngle.X += MathHelper.ToRadians((mouseState.Y - this.Window.ClientBounds.Y / 2) * rotSpeed * 0.01f); // pitch 
cameraAngle.Y += MathHelper.ToRadians((mouseState.X - this.Window.ClientBounds.X / 2) * rotSpeed * 0.01f); // yaw 
 
// Calculate what direction the camera is facing and what direction is its left for movement 
cameraForward = Vector3.Normalize(new Vector3((float)Math.Sin(-cameraAngle.Y), (float)Math.Sin(cameraAngle.X), (float)Math.Cos(-cameraAngle.Y))); 
cameraLeft = Vector3.Normalize(new Vector3((float)Math.Cos(cameraAngle.Y), 0f, (float)Math.Sin(cameraAngle.Y))); 
 
// Move along camera's forward direction 
if (keyboardState.IsKeyDown(Keys.W)) 
    cameraPosition -= speed * (float)gameTime.ElapsedGameTime.TotalSeconds * cameraForward; 
if (keyboardState.IsKeyDown(Keys.S)) 
    cameraPosition += speed * (float)gameTime.ElapsedGameTime.TotalSeconds * cameraForward; 
 
// Move along camera's side direction 
if (keyboardState.IsKeyDown(Keys.A)) 
    cameraPosition -= speed * (float)gameTime.ElapsedGameTime.TotalSeconds * cameraLeft; 
if (keyboardState.IsKeyDown(Keys.D)) 
    cameraPosition += speed * (float)gameTime.ElapsedGameTime.TotalSeconds * cameraLeft; 
 
// Move along the world's up direction - moving along camera's up would feel odd 
if (keyboardState.IsKeyDown(Keys.LeftShift)) 
    cameraPosition.Y += speed * (float)gameTime.ElapsedGameTime.TotalSeconds; 
if (keyboardState.IsKeyDown(Keys.LeftControl)) 
    cameraPosition.Y -= speed * (float)gameTime.ElapsedGameTime.TotalSeconds; 
 
// Create the view matrix   
view = Matrix.Identity; 
view *= Matrix.CreateTranslation(-cameraPosition); 
view *= Matrix.CreateRotationY(cameraAngle.Y); 
view *= Matrix.CreateRotationX(cameraAngle.X);    
 
// Reset the mouse to the center of the window so movement is never constrained 
if (this.IsActive) 
{ 
    Mouse.SetPosition(this.Window.ClientBounds.X / 2, this.Window.ClientBounds.Y / 2); 
} 

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
Looks fine to me. Why are you creating the projection matrix every frame, though?

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
Use an unprojection matrix to get the world space coordinates for your quads.

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
Rendering a heightmap would be a pretty easy way to make your own landscape.

Adbot
ADBOT LOVES YOU

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
How about you simply compile it for release and profile it there?

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