Jump to content
  • Advertisement

iEat_Babies

Member
  • Content Count

    51
  • Joined

  • Last visited

Community Reputation

102 Neutral

About iEat_Babies

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. iEat_Babies

    [XNA 4] Isometric block placement issue

    What did you do to get to the last screenshot... what "caused" it?
  2. iEat_Babies

    Combining Normals

    Oh wow! Thank you very much!!!! Just want y'all to know that I really appreciate this
  3. iEat_Babies

    Combining Normals

    You'll find source code on the internet to calculate the tangents and bitangents for each vertex. It can be done on vertex shader too under some circumstances or on geometry shader. The normal way is to calculate them on CPU and make them part of the vertex data. Cheers! [/quote] So now I got that code written, but there is another problem..... this is being done on a model, and I can't seem to get tangent or binormal data in the model. My shader is expecting normal, tangent, and binormal data..... and apparently its not getting it! The current vertex declaration does not include all the elements required by the current vertex shader. Tangent0 is missing. I am using 3DS Max 3012 and exporting as a FBX.... could someone please give me some help with exporting the tangent and binormal data from 3DS Max and importing it in my game? Thanks!
  4. iEat_Babies

    Combining Normals

    Yes I see, but would you please give me some code for doing this in HLSL. Actually how to do the math is what confuses me. Thanks!
  5. iEat_Babies

    Combining Normals

    Hello! I have a surface that has normals defined for it and is receiving lighting. Now I wish to add on normal mapping from a texture to that effect. I know how to do normal mapping on a flat surface, but not how to do it on a surface that is not flat and already has normal defined. So, how do I "combine" the surface normals from what is sampled in the texture? Thanks!
  6. iEat_Babies

    [XNA 4.0] Limiting Mipmap Levels

    HA! Thanks for that I completely missed the meaning of an 's'!!!
  7. iEat_Babies

    [XNA 4.0] Limiting Mipmap Levels

    I looked at the SamplerState class before and I saw that along with other interesting settings, but I saw no way to set it to the GraphicsDevice. I assumed that it would be like setting the RasterizerState; you make a new RasterizerState, set your options for it, then set it with GraphicsDevice.RasterizerState. But GraphicsDevice.SamplerStates is read-only.....?
  8. How can I limit the number of mipmap levels used for a texture? I feel like all 11? of the default mipmaps are a little too much and are cause a bit too much blur. I tried doing this: Texture2D tempTexture = Content.Load<Texture2D>("Maps\\Textures\\RoadTextures\\Road"); Texture2D newTexture = new Texture2D(device, tempTexture.Width, tempTexture.Height, true, SurfaceFormat.Color); Color[][] data = new Color[8][]; for(int i = 0; i < data.Length; i++) { int size = (tempTexture.Width / (int)Math.Pow(2, i)) * (tempTexture.Height / (int)Math.Pow(2, i)); data = new Color[size]; tempTexture.GetData(i, null, data, 0, size); } for (int i = 0; i < data.Length; i++) { int size = (tempTexture.Width / (int)Math.Pow(2, i)) * (tempTexture.Height / (int)Math.Pow(2, i)); newTexture.SetData(i, null, data, 0, size); } roadTexture = newTexture; where roadTexture is the final texture that I end up with and will render. It is working fine except for the issue that it is rendering black where those later mipmaps towards the end should be are not. So how can I do this?
  9. iEat_Babies

    CPU Time in XNA

    I noticed this too, one of my cores on my CPU would be close or at 100% even though the game was hardly doing anything. Also I noticed that when I played Terraria, which uses XNA, I would also get 100%-ish usage on one of my cores. So then I googled the problem and a few other people mentioned that this was happening to them, but no fix though. So I just accepted it and knew it would probably run just fine on other computers, hah. Edit: This doesn't happen when playing XNA games for the windows phone, though. [/quote] I just read an article about power usage on the Windows Phone. There is this section that applies to what you are discussing: [color="#333333"][font="Arial"]On Windows or Xbox, battery life is irrelevant. The machine has a certain amount of power available, and you might as well use all of it. If your Update and Draw methods take less than 1/60 second to execute, that means you are wasting processing power that could be used to add more funky effects.[/font] [color="#333333"] [color="#333333"][font="Arial"]Pedantic readers may wish to point out that battery life does matter for Windows laptops. True, but there's not much you can do about it. If a Windows game has spare CPU cycles the XNA Framework just busy-waits until the next tick time. We have to do that because the Windows task scheduler has a rather coarse time granularity. If we put the CPU to sleep, there is no guarantee it will wake up exactly when we want. So on Windows, if you add sleep calls in the interests of power efficiency, you can no longer guarantee a steady framerate. [/font] [color="#333333"][font="Arial"]Not so on Zune, which has the ability to sleep for tiny and exact periods of time. So on Zune, if your game uses fixed timestep mode and Update plus Draw finish in less than the allotted time, the framework works out when the next tick is due, then puts the CPU to sleep for exactly the right period. In other words, the less work your code does, the less battery it will use.[/font][/quote] Here is a link for the whole article: http://blogs.msdn.co...efficiency.aspx
  10. iEat_Babies

    Calculating normals in a spline

    Ok I see what your saying about Normals and tangents being in the same plane, I misunderstood your last post. Thanks for that pseudo-code, it really helps out alot!
  11. iEat_Babies

    Calculating normals in a spline

    I don't see how the normal is in the same plane as the tangent..... shouldn't it be perpendicular to the tangent? Also I tried reading the article, it seems really complicated and over my head.... I just tried that and it seems to work great..... but I think the real problem is before the normals would often be upside down, so I did "normal.Y = Math.Abs(normal.Y)", when I should have done "Vector3.Negate(normal)"...... But it is now working well with tangents, bitangents, and normals! Thanks for the help! But now one more question: Which is the "right" way to calculate the tangents? Option 1: Vector3 tangent = Vector3.Normalize(points - points[i - 1]); Option 2: Vector3 tangent = Vector3.Normalize(points[i + 1] - points); Option 3: Vector3 tangent1 = Vector3.Normalize(points - points[i - 1]); Vector3 tangent2 = Vector3.Normalize(points[i + 1] - points); Vector3 tangent = Vector3.Lerp(tangent1, tangent2, 0,5f); I am currently using "option 1" and it seems fine, but I am asking if it is correct. Thanks!
  12. iEat_Babies

    Calculating normals in a spline

    I switched the tangent vectors with Vector3.Negate.... and it certainly switched them, but the results for the normals aren't any better.... Here is my code for the tangent generation, in case I'm doing something wrong there: // I have a list of points..... // And this would be in a for loop Vector3 currentPos = interpolatedVertices.ElementAt(i).Position; Vector3 nextPos = interpolatedVertices.ElementAt(i + 1).Position; Vector3 tangent = nextPos - currentPos; tangent.Normalize(); tangents.Add(Vector3.Negate(tangent));
  13. [font="Arial"]Hello![/font] [font="Arial"]I have a spline with a bunch of points...... I am calculating tangent and normal data for each point / vertex. Right now the tangents seem fine, but I just can't quite get the normal data right.[/font] [font="Arial"]Check out this picture:[/font] [font="Arial"] [/font] [font="Arial"]Red is geometry, green is tangent data and yellow is normal data. In the above image the tangents and the normal seem fine![/font] [font="Arial"]But here:[/font] [font="Arial"] [/font] [font="Arial"]the normals should[/font][font="Arial"] be tilted back more so they are perpendicular to the slope, but they are not.[/font] [font="Arial"]How I am calculating the normals right now is the cross product of the tangent and the geometric line for each vertex.[/font][font="Arial"]In pseudo-code:[/font] [font="Arial"][source lang="csharp"][/font] // I have a List of points // and a List of tangents.... // This is in a for loop... Vector3 currentLine = points.ElementAt(i + 1) - points.ElementAt(i); currentLine.Normalize(); Vector3 tangent = tangents.ElementAt(i); tangent.Normalize(); Vector3 normal = Vector3.Cross(currentLine, tangent); [/source] [font="Arial"]Some help would really be appreciated.[/font][font="Arial"]Thanks![/font]
  14. Problem is solved...... I didn't realize that I needed to call AddTriangleVertex to actually add in the geometric data.
  15. Taking the vertices apart is only done once in LoadContent, so performance isn't really an issue. The purpose is for me to have a simple model that just contains points. Then I load this data and import it as a Model. Then all the points in the model will be smoothly interpolated and more new vertices will be created, defining a track for a racing game. Then I will be able to make nice tracks with models that have very few vertices. I see what your saying that I need to put the data into MeshParts.... but I don't see how I can actually do that.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!