2 Replies - 916 Views - Last Post: 25 February 2016 - 07:44 PM

#1 football1994  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 30
  • Joined: 01-July 13

Terrain scaling not matching up with boundary data

Posted 23 February 2016 - 06:19 AM

Hi guys



Ive been experimenting with a terrain from riemers xna tutorial website( link below) and came

across a problem with scaling the terrain, in my draw method(code below) I added Matrix.CreateScale and the

terrain looks to be scaled but when begin to move across the terrain I get an out of bounds exception

and I think the problem is even though the terrain is scaled visually it still seems to reading the boundary data

from the original size of the terrain,so I was hoping if anyone had any tips on how to help me solve the

problem






Thank you


riemers link

http://www.riemers.n...e_floorplan.php





code

 private void DrawCity(string technique)
        {



            effect1.CurrentTechnique = effect1.Techniques[technique];
            

            effect1.Parameters["xTexture"].SetValue(sceneryTexture);
            effect1.Parameters["xWorld"].SetValue(Matrix.Identity );
            effect1.Parameters["xLightPower"].SetValue(lightPower);
            effect1.Parameters["xWorldViewProjection"].SetValue(Matrix.Identity *Matrix.CreateScale(10) * view * proj * Matrix.CreateTranslation(0,0,0));
            effect1.Parameters["xLightPosition"].SetValue(position );
            effect1.Parameters["xAmbient"].SetValue(ambientPower);
            effect1.Parameters["xlightsWorld"].SetValue(Matrix.Identity * lightsViewProjectionMatrix);
            effect1.Parameters["xShadowMap"].SetValue(shadowMap);



            effect1.Begin();
            foreach (EffectPass pass in effect1.CurrentTechnique.Passes)
            {
                pass.Begin();

                device.VertexDeclaration = new VertexDeclaration(device, VertexPositionNormalTexture.VertexElements);

                device.Vertices[0].SetSource(cityVertexBuffer, 0, VertexPositionNormalTexture.SizeInBytes);
                device.DrawPrimitives(PrimitiveType.TriangleList, 0, cityVertexBuffer.SizeInBytes / 3);
                pass.End();
            }
            effect1.End();


Is This A Good Question/Topic? 0
  • +

Replies To: Terrain scaling not matching up with boundary data

#2 BBeck  Icon User is offline

  • Here to help.
  • member icon


Reputation: 792
  • View blog
  • Posts: 1,886
  • Joined: 24-April 12

Re: Terrain scaling not matching up with boundary data

Posted 24 February 2016 - 12:25 PM

The best thing is probably to step through it with the debugger and watch the values change to see what is changing unexpectedly or what never changes that you do expect.

Scaling a WVP matrix sounds like a mistake to me, but then Riemer is far more experienced than me. But by doing that, you are inherently creating an optical illusion. Then again all computer graphics is an optical illusion. So there is that. But then you have to match any calculations to that change.

It appears that you are scaling by 10 in all 3 dimensions.

At the very least, scaling the WVP matrix is confusing, in my opinion. Also, I don't like ever scaling anything. I tend to avoid scaling like the plague. I'm generally of the opinion that models should be properly scaled before they are imported. There's several problems that scaling potentially introduces. And if you don't scale properly, you can get skewing. So, I save scaling for rare occasions.

In my tiling and quaternions example I have a grid going on, but I think it was all 1 to 1. In my Interiors example, it gets a lot more complex, but I have two different coordinate systems going on simultaneously, which sounds kind of like what you are trying to do. I had a hotkey to put up an onscreen display of both sets of coordinates so that I could see how they were matching up.

Anyway, to scale a terrain, I would prefer to move the actual vertices of the terrain, rather than scaling the WVP to make it look like they have moved when they have not.

Sorry that that may not be much help on your current problem. Without going through it with a debugger, I'm not sure what's going on there.
Was This Post Helpful? 0
  • +
  • -

#3 football1994  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 30
  • Joined: 01-July 13

Re: Terrain scaling not matching up with boundary data

Posted 25 February 2016 - 07:44 PM

View PostBBeck, on 24 February 2016 - 12:25 PM, said:

I don't like ever scaling anything. I tend to avoid scaling like the plague. I'm generally of the opinion that models should be properly scaled before they are imported.



Thanks for responding to my post BBeck, during my experimentation I felt kind of uneasy about the XNA scaling process myself,so Ive decided to just try to rescale my character model to a smaller size in blender and just work with the terrain as it is, while making the adjustments with the camera settings in XNA.


Thanks Again :)/>
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1