PointStarfield does not display

Sep

01-04-2009 02:53:37

I've been struggling with PointStarfields for a while. I can't get the stars to display. What am I doing wrong?

My code:

mCaelumSys = new Caelum::CaelumSystem(mRoot, mSceneMgr, Caelum::CaelumSystem::CAELUM_COMPONENT_POINT_STARFIELD);
mCaelumSys->setAutoNotifyCameraChanged(false);
mCaelumSys->getPointStarfield()->addRandomStars(100000);
mCaelumSys->getPointStarfield()->setMag0PixelSize(100);
mCaelumSys->getPointStarfield()->setMinPixelSize(10);
mCaelumSys->getPointStarfield()->setMaxPixelSize(15);
mCaelumSys->getPointStarfield()->addBrightStarCatalogue(100);
mCaelumSys->setJulianDay(2451544.5);
mWindow->addListener(mCaelumSys);


By the way, a quick suggestion: instead of using the limited set of CaelumSystem::CaelumComponent enumeration values in the CaelumSystem componentsToCreate argument, why not use a bitfield style argument? For example, CAELUM_COMPONENT_CLOUDS = 1, CAELUM_COMPONENT_SUN = 2, CAELUM_COMPONENT_MOON = 4, etc. In the constructor, you can pass CAELUM_COMPONENT_CLOUDS | CAELUM_COMPONENT_SUN to initialize both the clouds and the sun.

nargil

01-04-2009 07:16:19

Check openGL mode. If it displays there, and not in DX you need to update the latest version of caelum from svn, because it already has been fixed.

cdleonard

01-04-2009 07:55:14

I've been struggling with PointStarfields for a while. I can't get the stars to display. What am I doing wrong?

My code:

mCaelumSys = new Caelum::CaelumSystem(mRoot, mSceneMgr, Caelum::CaelumSystem::CAELUM_COMPONENT_POINT_STARFIELD);
mCaelumSys->setAutoNotifyCameraChanged(false);
mCaelumSys->getPointStarfield()->addRandomStars(100000);
mCaelumSys->getPointStarfield()->setMag0PixelSize(100);
mCaelumSys->getPointStarfield()->setMinPixelSize(10);
mCaelumSys->getPointStarfield()->setMaxPixelSize(15);
mCaelumSys->getPointStarfield()->addBrightStarCatalogue(100);
mCaelumSys->setJulianDay(2451544.5);
mWindow->addListener(mCaelumSys);

That seems wrong; perhaps you want setAutoNotifyCameraChange(true);? Setting that to false means you will call notifyCameraChanged at the correct time by yourself. Updating is complicated; read this for more info.

By the way, a quick suggestion: instead of using the limited set of CaelumSystem::CaelumComponent enumeration values in the CaelumSystem componentsToCreate argument, why not use a bitfield style argument? For example, CAELUM_COMPONENT_CLOUDS = 1, CAELUM_COMPONENT_SUN = 2, CAELUM_COMPONENT_MOON = 4, etc. In the constructor, you can pass CAELUM_COMPONENT_CLOUDS | CAELUM_COMPONENT_SUN to initialize both the clouds and the sun.
CaelumComponent is already a bitfield style argument; and you CAN create multiple components at once.

Sep

02-04-2009 00:05:34

Thanks for the help.

Silly me, I set notifyCameraChanged to false and tried to initialize Caelum before creating the camera. I changed my code so that I inisitialise the CaelumSystem after creating the Camera, but now the program does not even run. There is an error in my call to addRandomStars. According to the stack trace, the StarVector hits a seg fault when it calls the size method in order to determine wether it has to enlarge the buffer. (That's a strange error!) I tried changing the addRandomStars(100000) to addRandomStars(1) in case I was breaking the vector with an excessively large number, but I still got the same error. I tried deleting the call alltogether, and I simply got another access violation on the next call to Caelum. I'm ussing exactly the same code as before, but for some reason, it doesn't work correctly if I initialize Caelum after creating the camera.

cdleonard

02-04-2009 07:23:17

There's something horribly wrong here. Creating CaelumSystem before or after your camera should make no difference.

If you're hitting a segfault in addRandomStars perhaps PointStarfield is not actually created; and getPointStarfield returns null? When creating components via CaelumSystem params then "unsupported" exceptions are caught and swallowed. One reason that might happen is if you're trying to create CaelumSystem before loading resources or before creating a RenderSystem.