I'm encoutering a problem with position of billboards. They are not displayed at the correct position
that is defined randomly. Insteed, the points are displayed following a diagonal...
Can you tell me what I'm missing?
I initialize the arrays with the following code:
Code: Select all
//
// Starfield
//
#define NBR_STARS 500
ITexture *image;
IBillboardSceneNode *star;
array<IBillboardSceneNode*>stars(NBR_STARS);
array<vector3df>starPos(NBR_STARS)
void initLevel()
{
srand((unsigned int) time(NULL));
for (int i = 0; i < NBR_STARS; ++i)
{
f32 n = -.5f + (f32(rand()) / RAND_MAX);
starPos[i].X = n * 40.f;
starPos[i].Y = n * 30.f;
starPos[i].Z = -50.f + n * 25.f;
}
star = smgr->addBillboardSceneNode();
image = driver->getTexture("data\\particle.png");
star->setMaterialTexture(0, image);
star->setMaterialType(EMT_TRANSPARENT_ADD_COLOR);
star->setMaterialFlag(EMF_LIGHTING, false);
star->setMaterialFlag(EMF_ZBUFFER, false);
for (int i = 0; i < NBR_STARS; ++i)
{
stars[i] = (IBillboardSceneNode*) star->clone();
stars[i]->setPosition(starPos[i]);
stars[i]->updateAbsolutePosition();
}
}
Code: Select all
(...)
// Create Scene Manager.
smgr = device->getSceneManager();
// Create main camera.
camera = smgr->addCameraSceneNode(0, camPos, camDir);
// Initialize the level.
initLevel();
// Main loop.
while (device->run())
{
driver->beginScene();
smgr->drawAll();
driver->endScene();
updateFPS();
}
(...)