Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[xna 4]Rendering problem
#1
Hello,

i'm making a small game and i have a problem when i want to render a ground made with multiple cubes. see the images:
[Image: 2pjn.jpg]

and

[Image: cod6.jpg]

The 2 images are taken with different yaw.

When i render only one cube, all the faces are correctly rendered...
Someone has an idea about this problem?

Thank you for your help
Reply

#2
You have problems with CullFace. (You see another object through other)
Google it.
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#3
Hello SailorMoon!

Thanks a lot for you help!
I'll check on google about CullFace!

thx a lot
Reply

#4
hello,

I have found that i need to set

CSHARP Code
  1. RasterizerState stat = new RasterizerState();
  2. stat.CullMode = CullMode.CullCounterClockwiseFace;
  3. GraphicsDevice.RasterizerState = stat;


I tried to put it in maybe every functions in Game1.cs as Initialize, load, update, draw... nothing changed.

I also tried with 'CullMode.CullClockwiseFace' and 'CullMode.None' but i got the same result.

Maybe i'm wrong in an other part of the code...

I'll copy the only used things into a new empty project and i'll post the source code, maybe it will be simpler for you to see the error in my code than with my bad explenations.

Thx in advance for the time you take to read my posts.
Reply

#5
Hi,

The new project is in attachment.
Thank you


Attached Files
.zip   3DDebug.zip (Size: 79.85 KB / Downloads: 12)
Reply

#6
(07-02-2013, 18:48)narkos Wrote: Hi,

The new project is in attachment.
Thank you

I think it's easier if you would post a screenshot.
Reply

#7
I will post some code from my old XNA project there. Wait.

It won't work because you need to end cullface rendering.

I mean something like this

cullmode state set to show

your code ----

cull mode state set to hidden


The problem could be in SpriteBatch also.


EDIT:
Found it at old my old HDD Big Grin


First:
Code:
public static RasterizerState gRasterizerState;
        public static BlendState gBlendState;
        public static DepthStencilState gDepthStencilState;

Then initialize it:
Code:
gRasterizerState = new RasterizerState();
            gBlendState = new BlendState();
            gDepthStencilState = new DepthStencilState();

Render:
Code:
public static void RenderLevel(Vector3 cameraPosition, Matrix viewMatrix, Matrix projMatrix, uint gameTime, GraphicsDevice graphics)
        {
            // -------------
            // reset and set the rasterizer states
            gRasterizerState = new RasterizerState();
            gRasterizerState.CullMode = CullMode.CullCounterClockwiseFace;
            gRasterizerState.FillMode = FillMode.Solid;

            Renderer.Device.RasterizerState = gRasterizerState;

            // reset the blend and depth states
            Renderer.Device.BlendState = BlendState.Opaque;

            // reset and set the depthstencil states
            gDepthStencilState = new DepthStencilState();
            gDepthStencilState.DepthBufferEnable = true;
            Renderer.Device.DepthStencilState = gDepthStencilState;
            // -------------
            YOUR CODE THERE


            // -------------
            gRasterizerState = new RasterizerState();
            gRasterizerState.FillMode = FillMode.Solid;
            Renderer.Device.RasterizerState = gRasterizerState;
            // -------------
        }


Also if it won't work, check it - there's good blog with useful stuff.
http://blogs.msdn.com/b/shawnhar/archive...o-4-0.aspx

Edit 3:

Oh yeah, as i see, in your code spritebatch.begin is before scene render... it can f*ck up your scene. Do something like this:

Code:
renderscene();

spritebatch.begin();
drawtext;
spritebatch.end();
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#8
Hello,

@surtek i posted screenshots in my first post.
@SailorMoon thx a lot for your help and the code!

You help me a lot! Thank you so much man!
I'll play with it tonight!
Again thx!
Reply

#9
Awesome!
It works just great!!!!!!

Thx a lot!
Reply

#10
(07-03-2013, 18:51)narkos Wrote: Awesome!
It works just great!!!!!!

Thx a lot!

Thanks for the answer.
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Help Android problem Yamato 12 8,194 04-25-2014, 04:49
Last Post: ScHmIdTy56789
  Problem with Rain Effects on Maps mitchhacker 5 4,868 10-22-2013, 00:46
Last Post: mitchhacker
  Help Liberation Problem Yamato 27 24,967 07-17-2013, 19:54
Last Post: feature
  Help Problem God plugin v4.0 4nonymous 1 2,730 06-22-2013, 23:25
Last Post: 8q4s8
  Help Infected Shop Plugin Problem Hallla 2 3,161 05-06-2013, 18:29
Last Post: Hallla
  problem with gsc code CheGuevara 5 5,621 04-20-2013, 15:06
Last Post: Nekochan
  problem to connect to server s.j-rez 0 2,236 04-17-2013, 18:18
Last Post: s.j-rez
  warning problem AndEEDJay 0 2,111 04-08-2013, 09:54
Last Post: AndEEDJay
  Help ADDON,PROBLEM HACK emilioxativa 5 4,836 04-03-2013, 08:16
Last Post: narkos
  Help Problem unlimited ammo plugin 4nonymous 2 3,113 03-10-2013, 20:14
Last Post: hillbilly

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.