Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2010
    Posts
    4

    Post Another 3d Text issue and proper scaling

    Lets say for example I have 27 cubes in 3 rows x 3 cols to make a Rubic Cube... in XNA 4.0

    These are all rendering fine and have are at .5 opacity. I have single digits in each row
    and column. I have setup a free camera and control it using the typical A,W,S,D and Mouse Click Pan.

    The cubes render fine and the text renders inside of the cubes fine... HOWEVER.... when I pan out the text spills out of the cube boundaries (grows) and when I zoom in the text shrinks.

    This is not the behavior I was aiming for. I would like the text to stay a static size like each individual cube. I've looked all over google and posted other places for the answer but still come up with nothing.

    Does anyone have any idea on how to achieve this properly? It doesn't make any sense why placing text in a 3d space is such an issue. The text is the only thing that scales improperly.

    Here is a snippet for the drawing. I know it's more than likely not proper as it's been regurgitated over and over again.
    Please help.

    Code:
                Vector2 fontScale = num.MeasureString(text);
                Vector3 screenPos = GraphicsDevice.Viewport.Project(position, camera.Projection, camera.View, Matrix.Identity);
                Vector2 initOrig = Vector2.Zero;
                spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend,SamplerState.AnisotropicClamp, DepthStencilState.Default, RasterizerState.CullNone);
                DepthStencilState ds = new DepthStencilState();
                ds.DepthBufferEnable = true;
                ds.DepthBufferWriteEnable = true;
                GraphicsDevice.DepthStencilState = ds;
                spriteBatch.DrawString(num, text, new Vector2(screenPos.X, screenPos.Y), color, 0, fontScale, 1.0f, SpriteEffects.None, screenPos.Z);
                spriteBatch.End();

  2. #2
    Join Date
    Nov 2010
    Posts
    4
    Update. Still no luck cracking this. Why is this such a big deal? Everything causes the text to scale!

  3. #3
    Join Date
    Jul 2010
    Posts
    472
    From what I can see, it looks like screenPos.Z might cause it, being in the place of layerDepth. If I recall correctly, part of what layerDepth does (aside from making something show up on top or in back of other images) is that it makes things appear closer or further away, outside of the standard layer appearance. Unfortunately, I never experimented a whole lot with it; so I could very well be wrong. But it might be something to experiment with; if you replace the layerDepth with, say, 0, what happens? What if you replace it with another number? Does any other number match up to what occurs when screenPos.Z is there?
    "It's most impressive when it's least expected."

  4. #4
    Join Date
    Nov 2010
    Posts
    4
    It's not that. Thanks though.

  5. #5
    Join Date
    Jul 2010
    Posts
    472
    What exactly causes it to scale? Just zooming, or are you also trying to move the blocks? Is there any particular reason fontScale is in the place of Origin? Maybe showing the code that causes zooming and/or moving will shed some light on what's happening ... but from that bit, I can't see anything that would cause it.
    "It's most impressive when it's least expected."

  6. #6
    Join Date
    Nov 2010
    Posts
    4
    I dunno what is causing the scaling. I have tried a billion different things to keep it from scaling. If I move the cam forward toward the cubes the digits shrink. If I move it backwards (away) then the digits scale larger the farther away I get.

  7. #7
    Join Date
    Jul 2010
    Posts
    472
    Is it possible to show the code that allows movement? Could it, by any chance, have anything to do with the movement code?
    "It's most impressive when it's least expected."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •