clipping problem

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
gavicus
Posts: 16
Joined: Fri Aug 25, 2006 2:19 pm

clipping problem

Post by gavicus »

I created a sphere and wrapped it with a map of the earth. I then gave the user the power to control the camera such that it moves around the globe and can zoom in and out.

The problem comes when I try to zoom close enough that the globe takes up more space than the window size. The edges of my globe get clipped off before I can zoom in far enough not to see the clipping. When I get close enough, All I can see is one triangle. For this app, I want to be able to zoom in really close.

I've played with camera->setNear() and ->setFOV() to no avail.

What do you recommend?
juliusctw
Posts: 392
Joined: Fri Apr 21, 2006 6:56 am
Contact:

here

Post by juliusctw »

camera->setNearValue(number)

player with the numbers
gavicus
Posts: 16
Joined: Fri Aug 25, 2006 2:19 pm

Post by gavicus »

Yeah, when I said setNear() above, I meant setNearValue(). Changing it tends to fish-eye the view and doesn't stop the clipping problem. Any other ideas out there? How do you zoom in really close to the face of a large sphere without clipping the sphere out before you can get close enough?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Zoom in/out with camera->setFOV().
gavicus
Posts: 16
Joined: Fri Aug 25, 2006 2:19 pm

Post by gavicus »

I hadn't tried setFOV but I just did and it clips my sphere out at the edges before I can get close enough.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Move the camera back away from the object by a bit, or set the near plane to some small value like 0.f.

Travis
gavicus
Posts: 16
Joined: Fri Aug 25, 2006 2:19 pm

Post by gavicus »

Still clips. Dang. Thanks for your help, though.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The view will not clip if you are just changing the field of view. It will clip if you move the camera to close to the object. The following testcase works just fine for me with the software, d3d and ogl drivers. It will not work with the old software driver because that driver clips polys that aren't completely on screen.

Press the +/- keys to zoom in and out. You can move around with the normal camera controls, but if you use them and get to close you will see clipping. If you get very close and zoom in/out with +/-, you will see that the sphere is not clipped when you just apply a zoom.

Code: Select all

#include <irrlicht.h>
#pragma comment(lib, "Irrlicht.lib")

using namespace irr;

class MyEventReceiver : public IEventReceiver
{
public:
   MyEventReceiver(scene::ICameraSceneNode* cam)
      : Camera(cam)
   {
      Camera->grab();
   }

   virtual ~MyEventReceiver()
   {
      Camera->drop();
   }

   virtual bool OnEvent(const SEvent& event)
   {
      if (event.EventType == EET_KEY_INPUT_EVENT)
      {
         f32 fov = Camera->getFOV();
         switch(event.KeyInput.Key)
         {
            case irr::KEY_PLUS:
               fov -= (core::DEGTORAD * 1.f);
               break;
            case irr::KEY_MINUS:
               fov += (core::DEGTORAD * 1.f);
               break;
            default:
               return false;
         }

         static const f32 minFOV = core::DEGTORAD * 0.f;
         static const f32 maxFOV = core::DEGTORAD * 90.f;
         if (minFOV <= fov && fov <= maxFOV)
            Camera->setFOV(fov);

         return true;
      }

      return false;
   }

private:
   scene::ICameraSceneNode* Camera;
};

int main()
{
   // ask user for driver

   video::E_DRIVER_TYPE driverType = video::EDT_DIRECT3D9;

   // create device and exit if creation failed

   IrrlichtDevice* device =
      createDevice(driverType, core::dimension2d<s32>(800, 600));

   if (device == 0)
      return 1; // could not create selected driver.

   video::IVideoDriver* driver = device->getVideoDriver();
   scene::ISceneManager* smgr = device->getSceneManager();

   scene::ICameraSceneNode* cam = smgr->addCameraSceneNodeMaya();

   MyEventReceiver receiver(cam);
   device->setEventReceiver(&receiver);

   scene::ISceneNode* node = smgr->addSphereSceneNode(10.f, 32);
   node->setMaterialTexture(0, driver->getTexture("../../media/stones.jpg"));
   node->setMaterialFlag(video::EMF_LIGHTING, false);

   u32 now = 0;
   while(device->run())
   {
      if (device->isWindowActive())
      {
         if (driver->beginScene(true, true, video::SColor(0,100,100,100)))
         {
            smgr->drawAll();

            driver->endScene();
         }
      }
   }

   device->drop();
   
   return 0;
}
CodeDog
Posts: 106
Joined: Sat Oct 07, 2006 8:00 pm
Location: CA. USA
Contact:

Post by CodeDog »

You could try using setScale to increase the size of the globe without changing the distance to the camera. This will give the illusion of zooming in on the globe.
roguelike
Posts: 14
Joined: Tue May 30, 2006 11:03 am

Post by roguelike »

I get a similar problem with sections of floor in my level. (not the walls though), when I tilt the camera up and down. It displays then doesn't display, then displays again as I tilt the camera.

If i raise the camera further fom the ground it solves the problem, but am about 50ft tall, so is impracticle

Its an .x mesh and happens in DirectX, and OpenGL mode. Ive tried adjusting setNearValue but still happens.

Any ideas?
________
Mercedes-Benz 200 History
Last edited by roguelike on Tue Feb 22, 2011 10:49 pm, edited 1 time in total.
area51
Posts: 338
Joined: Thu Mar 18, 2004 10:20 pm
Location: UK
Contact:

Post by area51 »

@rogue Thats a 1.1 bug with the .X file format. Try using the previous version, 1.0. Remember that version only supports text not binary .X files

Alternativly use .3ds format
________
MARIJUANA CARD
Post Reply