Lots of errors
Funny. The code works correctly for me.
The above code produces the following...
Travis
Code: Select all
#include <string.h> // for strcmp
#include <stdlib.h> // for rand
#include <irrlicht.h>
using namespace irr;
#ifdef _IRR_WINDOWS_
# pragma comment(lib, "Irrlicht.lib")
#endif
f32 random_f32(f32 n, f32 x)
{
const f32 r = 1.f * ::rand() / RAND_MAX; // 0 to 1
return ((x - n) * r) + n;
}
int main()
{
IrrlichtDevice *device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640, 480), 16);
if (!device)
return 1;
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
scene::ISceneNode* player = smgr->addSphereSceneNode(10.f);
player->setPosition(core::vector3df(100.f, 10.f, -70.f));
player->updateAbsolutePosition();
scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();
camera->setTarget(player->getAbsolutePosition());
struct Zombie
{
scene::ISceneNode* Node;
};
#define ZOMBIE_COUNT 400
Zombie tZombies[ZOMBIE_COUNT];
for (u32 i = 0; i < ZOMBIE_COUNT; ++i)
{
tZombies [i].Node = smgr->addCubeSceneNode();
tZombies [i].Node->setMaterialFlag(video::EMF_LIGHTING, false);
}
for (u32 nZombie_counter = 0; nZombie_counter < ZOMBIE_COUNT; ++nZombie_counter)
{
scene::ISceneNode* zombie = tZombies [nZombie_counter].Node;
core::vector3df rot (0.f, random_f32(0.f, 360.f), 0.f);
zombie->setRotation(rot);
zombie->updateAbsolutePosition();
core::vector3df pos (0.f, 0.f, random_f32 (100.f, 200.f));
zombie->getAbsoluteTransformation().rotateVect(pos);
// assumes that zombie nodes are not children of some other node
zombie->setPosition(player->getAbsolutePosition() - pos);
}
while(device->run())
{
if (driver->beginScene(true, true, video::SColor(0,200,200,200)))
{
smgr->drawAll();
driver->endScene();
}
}
device->drop();
return 0;
}
Travis
its wierd because when i run ur code it works but when i run that same code, but in the update method with my other code, it doesn't
this is my update method(with your code):
this is what it looks like from my perspective:
this is my update method(with your code):
Code: Select all
void api::C_MainController::Update()
{
if(nZombie_counter >= MAX_ZOMBIES)
nZombie_counter = 0;
//if((int(api::uElapsedTime) % 100) == 0)
//{
if(!tZombies[nZombie_counter]->GetNode()->isVisible()
/*&& tZombies[nZombie_counter]->ShouldSpawnAgain()*/)
{
/*tZombies[nZombie_counter]->GetNode()->setPosition(api::camera->getPosition());
tZombies[nZombie_counter]->GetNode()->setRotation(vec_t(0,0,0));
tZombies[nZombie_counter]->GetNode()->setRotation(vec_t(
tZombies[nZombie_counter]->GetNode()->getRotation().X,
randint(0,360),
tZombies[nZombie_counter]->GetNode()->getRotation().Z));
tZombies[nZombie_counter]->GetNode()->setPosition(vec_t(
tZombies[nZombie_counter]->GetNode()->getPosition().X,
tZombies[nZombie_counter]->GetNode()->getPosition().Y,
randint(100, 200)) + tZombies[nZombie_counter]->GetNode()->getRotation());
tZombies[nZombie_counter]->Spawn();
nZombie_counter++;*/
scene::ISceneNode* zombie = tZombies [nZombie_counter]->GetNode();
core::vector3df rot (0.f, random_f32(0.f, 360.f), 0.f);
zombie->setRotation(rot);
zombie->updateAbsolutePosition();
core::vector3df pos (0.f, 0.f, random_f32 (100.f, 200.f));
zombie->getAbsoluteTransformation().rotateVect(pos);
// assumes that zombie nodes are not children of some other node
zombie->setPosition(api::camera->getAbsolutePosition() - pos);
tZombies[nZombie_counter]->Spawn();
nZombie_counter++;
// }
}
for(int i=0;i<MAX_ZOMBIES;i++)
if(tZombies[i]->GetNode()->isVisible())
tZombies[i]->Update();
}
#1 Most Common Error:
Reality Error: Object behind keyboard cannot program.
Reality Error: Object behind keyboard cannot program.
yeah, the camera is moving around because im controlling it, ill try to fix the problem now
EDIT:
I fixed it, instead of using
tZombies[nZombie_counter]->Spawn()
I used
tZombies[nZombie_counter]->Spawn(tZombies[nZombie_counter]->GetNode()->getPosition(),vec_t(0,0,0));
thanks for ur help : ): )
EDIT:
I fixed it, instead of using
tZombies[nZombie_counter]->Spawn()
I used
tZombies[nZombie_counter]->Spawn(tZombies[nZombie_counter]->GetNode()->getPosition(),vec_t(0,0,0));
thanks for ur help : ): )
#1 Most Common Error:
Reality Error: Object behind keyboard cannot program.
Reality Error: Object behind keyboard cannot program.