Culling Problem

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
giulioz
Posts: 8
Joined: Mon Jun 24, 2013 2:21 pm

Culling Problem

Post by giulioz »

Hello everyone.
I'm using Irrlicht with C# to develop an isometric RPG game.
I've got a big problem with sprites and isometric camera.
When the camera moves sprites disappears gradually like in these shoots:
Image
Image

I create the sprites with this code:

Code: Select all

float halfWidth = size.Width / 2;
            MeshBuffer buff = MeshBuffer.Create(VertexType.Standard, IndexType._32Bit);
            buff.Append(new Vertex3D[]{
                new Vertex3D(new Vector3Df(-halfWidth, 0, 0), new Vector3Df(0, 0, 0), Color.OpaqueWhite, new Vector2Df(0,1)),
                new Vertex3D(new Vector3Df(halfWidth, 0, 0), new Vector3Df(0, 0, 0), Color.OpaqueWhite, new Vector2Df(1,1)),
                new Vertex3D(new Vector3Df(-halfWidth, size.Height, 0), new Vector3Df(0, 0, 0), Color.OpaqueWhite, new Vector2Df(0,0)),
                new Vertex3D(new Vector3Df(halfWidth, size.Height, 0), new Vector3Df(0, 0, 0), Color.OpaqueWhite, new Vector2Df(1,0))},
                new uint[] { 1, 0, 2, 1, 2, 3 });
            buff.RecalculateBoundingBox();
            Mesh mesh = Mesh.Create();
            mesh.AddMeshBuffer(buff);
            buff.Drop();
            mesh.RecalculateBoundingBox();
 
            sceneNode = Engine.device.SceneManager.AddMeshSceneNode(mesh, null, -1, position);
            sceneNode.SetMaterialTexture(0, Engine.device.VideoDriver.GetTexture("data/spritesheets/" + name + ".png"));
            sceneNode.SetMaterialFlag(MaterialFlag.Lighting, false);
            sceneNode.SetMaterialType(MaterialType.TransparentAlphaChannelRef);
            sceneNode.SetMaterialFlag(MaterialFlag.BilinearFilter, false);
            sceneNode.SetMaterialFlag(MaterialFlag.BackFaceCulling, false);
            sceneNode.AutomaticCulling = CullingType.Off;
How I can solve this problem?
Thank you. :)

EDIT: OpenGL Works properly... but I need it in DX9 :(
Foaly
Posts: 142
Joined: Tue Apr 15, 2014 8:45 am
Location: Germany

Re: Culling Problem

Post by Foaly »

Maybe it's a Z-Buffer problem. If you draw the nodes on your own in the right order you could disable it.
Could you show more? How do you place the nodes?
How do you move the camera?
When the camera flies toward the nodes, maybe the near plane of your camera is too small / big. You could try to set it to a lower value.
mnunesvsc
Posts: 22
Joined: Sun May 28, 2006 9:04 pm
Contact:

Re: Culling Problem

Post by mnunesvsc »

Nice iso, how do you configured the cam ?
CuteAlien
Admin
Posts: 9651
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Culling Problem

Post by CuteAlien »

This thread is 5 years old :-) And with sprites it's probably not an iso camera. Thought Irrlicht has some support for that. You can use buildProjectionMatrixOrthoLH and set the resulting matrix in the camera (ICamerScenenode:: setProjectionMatrix).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply