• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

146 Neutral

About Phil_93

  • Rank
  1. Hi everyone,                    I'm working on a path finding project I have going in C#. I'm fairly new to path finding and have been following some tutorials but I'm struggling to get my head around it fully. Can anyone recommend any good tutorials or resources that would be suitable for a beginner in path finding? I do have experience in C# programming but the concept of AI such as path finding is pretty new to me.   Thanks in advance!
  2. Heightmap Problems?

    Ok great news! My car is finally sticking to the ground as it should! The frame rate is dropping a little when the car moves forward but I'm sure I can fix that somehow, it is only a minor problem after all.   Just want to say thanks to everyone that helped me out on this otherwise I'd have never got it done.   Thanks everyone! Phil_93 :D
  3. Heightmap Problems?

    Actually scratch that I've changed the camera around so I can look around and I'm actually way above my heightmap, it looks tiny from where I actually am.
  4. Heightmap Problems?

    Hey sorry I went quiet yesterday, I needed a break. Looking at it today I have actually changed the scale of the car in the properties.   I'm guessing I need to multiply or add the scale of the car to the line that changes it's Y position on the heightmap?
  5. Heightmap Problems?

    Ok, good news and bad news.   Good news is, I finally got it to work! my car is adjusting it's height according to the heightmap.   Bad news is, I'm now underneath my heightmap for some reason.
  6. Heightmap Problems?

    Thank you so much for the help. I'll go and have a try now.    I just hope I'm not being annoying or anything.
  7. Heightmap Problems?

    I feel really stupid for saying this but a lot of that just went straight over my head (It's my own fault I should have said to keep it simple, I'm fairly new to programming. Even more so to xna). My university is giving us code/tutorials that doesn't work properly and not even the tutors seem to understand their own stuff.   I've been trying to do this for about 4 weeks straight now and I'm getting to the point where I just want to give up and go home. It's starting to look like university isn't for me.
  8. Heightmap Problems?

    Yeah, I'm not too good with this and I tried a lot of different things before asking for help, I also tried changing some of the effect. lines at the bottom of the heightmap class. Oh right, so I'd be better off putting GetHeight in the actual car class rather than trying to pass it through the Update or Draw in the main game? Most of the time when I try to implement GetHeight I get errors. Thank you so much for helping out by the way.
  9. Heightmap Problems?

    Sorry about posting a link to a large file, I wasn't sure what do do because I didn't want people having to trawl though bits of code on a post.   I forgot to explain that line, I added it in because I thought it would help me sort my problem out but it just locks my car up so it will only travel in a straight line and my game crashes when the car reaches the side of the heightmap, this is why it was commented out.   I'm really stuck, sorry If I'm being a pain.
  10. Hey everyone,                        I posted a while back about having issues with heightmaps. I was on Easter break from university so I had to try and get help on-line but I couldn't really understand what I needed to do. I started back at university yesterday and asked my tutor to take a look and he couldn't make help me, he didn't seem to understand the code which is annoying being as I went off the tutorials supplied by my university which were made by said tutor. I'm still seriously stuck on this and I'm starting to run out of places to get help.    Could anyone please help me? My code is a bit long to actually put on the post, besides it's better off if someone who knows what they are doing can see the entire thing so they know exactly where I'm going wrong. I don't want people giving me code or anything like that. I just want someone to look through my program, see where I'm going wrong and talk me through how to fix it, I really want to be able to understand this better.   Any help is greatly appreciated.   Edit: Just to mention the problem I'm having is that my car in my game is just hovering at a fixed height and phasing through the high sections of the heightmap. As far as I know all the code to alter it's height etc. is there, it just isn't doing anything.   Here are just the source files instead of having to download a full program: http://www.mediafire.com/download.php?dwbh8ws11t4oys8
  11. As far as I know no I haven't. The code for the height map was supplied by my university in their tutorials, I have a feeling they may have just copied it from elsewhere. How would you suggest I change the draw? I've been trying effect.World = player.world, (Matrix.Identity); but it doesn't quite seem to like that. Also thank you for the help.
  12. HI,     I've been working on a racing game project, bear in mind I am fairly new to working with xna and have been using tutorials supplied by my university to help me, however said tutorials are extremely vague and don't explain how the code works. It's just a case of put this code here, it works. So I apologise in advance if I don't seem to know what I'm going on about. I'm using a heightmap as my terrain for my car to drive around on and I have a class set up for this. It also contains code which should in theory move the car based on how high/low the heightmap is making it look like it is actually driving on the ground. Unfortunately I cannot get this to work, there is a statement I commented out in my main games Update() method where I tried to get this to work but when it is uncommented my model disappears and my game breaks, when it is commented out my model is there and I have full control but the model stays at a fixed height and phases through the high parts of the map. I'm not asking anyone to do my work for me because that isn't what I want. But could someone please look at my work, see where I'm going wrong and help me fix it by walking me through it so I can understand what is going on?   Thank you in advance for any input.   Heightmap Class:   {     class Heightmap     {         float[,] heightData;         Vector3[,] normals;         public int terrainWidth;         public int terrainHeight;         public Vector3 heightmapPosition;         float terrainScale = 300f;         float verticalScale = 10f;         VertexPositionNormalTexture[] vertices;         int[] faces;           BasicEffect effect;         Texture2D texture;         GraphicsDevice graphics;         Matrix world;           public Heightmap(GraphicsDevice gd, Texture2D terrainTexture, Texture2D heightmap)         {             graphics = gd;             texture = terrainTexture;             terrainWidth = heightmap.Width;             terrainHeight = heightmap.Height;             faces = new int[(terrainWidth - 1) * (terrainHeight - 1) * 6];             vertices = new VertexPositionNormalTexture[terrainWidth * terrainHeight];             effect = new BasicEffect(graphics);               buildHeightmap(heightmap);             heightmapPosition.X = 0;             heightmapPosition.Y = 0;               for (int z = 0; z < terrainHeight; z++)             {                 for (int x = 0; x < terrainWidth; x++)                 {                     vertices[x + z * terrainWidth].Position.X = terrainScale * (x);                     vertices[x + z * terrainWidth].Position.Z = terrainScale * (z);                     vertices[x + z * terrainWidth].Position.Y = heightData[x, z];                     vertices[x + z * terrainWidth].Normal = Vector3.Zero;                     vertices[x + z * terrainWidth].TextureCoordinate.X = (float)x / terrainWidth;                     vertices[x + z * terrainWidth].TextureCoordinate.Y = (float)z / terrainHeight;                 }             }               int count = 0;             for (int z = 0; z < terrainHeight - 1; z++)             {                 for (int x = 0; x < terrainWidth - 1; x++)                 {                     int lowerLeft = x + z * terrainWidth;                     int lowerRight = (x + 1) + z * terrainWidth;                     int topLeft = x + (z + 1) * terrainWidth;                     int topRight = (x + 1) + (z + 1) * terrainWidth;                       faces[count++] = topLeft;                     faces[count++] = lowerRight;                     faces[count++] = lowerLeft;                     faces[count++] = topLeft;                     faces[count++] = topRight;                     faces[count++] = lowerRight;                 }             }         }           public bool BoundingTest(Vector3 position)         {             if (position.X > 0 && position.X < (heightData.GetLength(0) - 1) * terrainScale && position.Z > 0 && position.Z < (heightData.GetLength(1) - 1) * terrainScale)             {                 return true;             }             else             {                 return false;             }         }             public float GetHeight(Vector3 position)         {             //Determining the cell the player is positioned in                   int left, top;             left = (int)position.X / (int)terrainScale;             top = (int)position.Z / (int)terrainScale;               //Working out our position within the cell             float xNormalized = (position.X % terrainScale) / terrainScale;             float zNormalized = (position.Z % terrainScale) / terrainScale;               //Calculating height             float topHeight = MathHelper.Lerp(heightData[left, top],                             heightData[left + 1, top],                             xNormalized);               float bottomHeight = MathHelper.Lerp(heightData[left, top + 1],                             heightData[left + 1, top + 1],                             xNormalized);               //Finding exact height             return MathHelper.Lerp(topHeight, bottomHeight, zNormalized) * terrainHeight;         }             public void buildHeightmap(Texture2D heightMap)         {             Color[] heightmapColors = new Color[terrainWidth * terrainHeight];             heightMap.GetData(heightmapColors);               heightData = new float[terrainWidth, terrainHeight];             for (int x = 0; x < terrainWidth; x++)                 for (int y = 0; y < terrainHeight; y++)                 {                     heightData[x, y] = heightmapColors[x + y * terrainWidth].R * verticalScale;                 }         }           public void calculateNormals()         {             for (int i = 0; i < faces.Length / 3; i++)             {                 Vector3 firstvec = vertices[faces[i * 3 + 1]].Position - vertices[faces[i * 3]].Position;                 Vector3 secondvec = vertices[faces[i * 3]].Position - vertices[faces[i * 3 + 2]].Position;                 Vector3 normal = Vector3.Cross(firstvec, secondvec);                 normal.Normalize();                 vertices[faces[i * 3]].Normal += normal;                 vertices[faces[i * 3 + 1]].Normal += normal;                 vertices[faces[i * 3 + 2]].Normal += normal;             }               normals = new Vector3[terrainWidth, terrainHeight];             for (int x = 0; x < terrainWidth; x++)             {                 for (int z = 0; z < terrainHeight; z++)                 {                     normals[x, z] = vertices[x + z * terrainWidth].Normal;                 }             }         }           public Vector3 GetNormal(Vector3 position)         {             int left, top;             left = (int)position.X / (int)terrainScale;             top = (int)position.Z / (int)terrainScale;               float xNormalized = (position.X % terrainScale) / terrainScale;             float zNormalized = (position.Z % terrainScale) / terrainScale;               Vector3 topNormal = Vector3.Lerp(normals[left, top],                           normals[left + 1, top],                           xNormalized);               Vector3 bottomNormal = Vector3.Lerp(normals[left, top + 1],                           normals[left + 1, top + 1],                           xNormalized);               Vector3 normal = Vector3.Lerp(topNormal, bottomNormal, zNormalized);             normal.Normalize();             return (normal);         }           public void Draw(Matrix projection, Matrix view)         {             effect.Texture = texture;             effect.TextureEnabled = true;             effect.EnableDefaultLighting();             effect.DirectionalLight0.Direction = new Vector3(1, -1, 1);             effect.DirectionalLight0.Enabled = true;             effect.DirectionalLight1.Enabled = false;             effect.DirectionalLight2.Enabled = false;             effect.AmbientLightColor = new Vector3(0.8f, 0.8f, 0.8f);             effect.SpecularColor = new Vector3(0, 0, 0);             effect.Projection = projection;             effect.World = Matrix.Identity;             effect.View = view;               foreach (EffectPass pass in effect.CurrentTechnique.Passes)             {                 pass.Apply();                 {                     graphics.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, vertices, 0, vertices.Length, faces, 0, faces.Length / 3);                 }             }               RasterizerState rs = new RasterizerState();             rs.FillMode = FillMode.Solid;             rs.CullMode = CullMode.None;             graphics.RasterizerState = rs;         }     } }   Game Update() Method:   protected override void Update(GameTime gameTime)         {             // Allows the game to exit             if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)                 this.Exit();               player1 = GamePad.GetState(PlayerIndex.One);               player.InputDrive(player1);             player.UpdateDrive();             camera.update(player.world);                      sky.update(player.position);               //player.world = Matrix.CreateTranslation(player.yaw, terrain.GetHeight(player.position), player.pitch);               base.Update(gameTime);         }  
  13. 3Ds Max 7 Issues

    Thanks for the heads up :) just to ask what is your opinion on the model. It's my first 3ds max project and I've had no prior 3d modelling experience...
  14. 3Ds Max 7 Issues

    Any chance of some help? I'm still really struggling to put my model right. I don't want anyone to do this for me, just let me know where I'm going wrong/give advice. I was thinking it might be to do with the resolution I was saving the texture as but no matter what resolution I save it as it always looks the same on the sheet and bugs out when I make changes.
  15. 3Ds Max 7 Issues

    Hey everyone, I've been struggling for a while now to finish my 3d model that I was making for a game project. The model itself is finished, however I can't seem to texture the body of the car at all, the wheels worked fine but the body didn't want to texture properly (I used an unwrapping plugin and it didn't match up plus the slightest change to the texture would colour the entire body). I also can't get the hang of rigging the car so I can animate it when I put it into xna. I'm not asking anyone to do my work for me I'm just asking for help because I really can't get this done and I've been trying for weeks to get this working properly with no success.   Oh I know 3ds max 7 is awkward but it's the only version my university has so unfortunately I was stuck with it.   Thanks in advance. (model is attached)
  • Advertisement