Code: Select all
../../../irrlicht-1.3/lib/Win32-gcc/libIrrlicht.a
D:\game!\irrNewt-0.3\source\Makefile.win [Build Error] [IrrNewt.dll] Error 1
Using Dev-C++
Code: Select all
../../../irrlicht-1.3/lib/Win32-gcc/libIrrlicht.a
D:\game!\irrNewt-0.3\source\Makefile.win [Build Error] [IrrNewt.dll] Error 1
Code: Select all
p1node = gameManager->getSceneManager()->
addOctTreeSceneNode(planemesh);
if(p1node)
{
p1node->setMaterialFlag(EMF_LIGHTING, false);
p1node->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);
p1node->setMaterialTexture(0, gameManager->getDriver()->getTexture("media/logo.png"));
}
floornode = gameManager->getSceneManager()->
addOctTreeSceneNode(planemesh);
if (floornode)
{
floornode->setMaterialFlag(EMF_LIGHTING, false);
floornode->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);
floornode->setMaterialTexture(0, gameManager->getDriver()->getTexture("media/logo.png"));
floornode->setScale(vector3df(1,15,1));
floornode->setPosition(vector3df(200, -10, 0));
floornode->setRotation(vector3df(0, 0, 90));
}
SBodyFromNode mapdata;
mapdata.Node=floornode;
mapdata.Mesh=planemesh;
floorbody=gameManager->getPhysicsEngine()->createBody(mapdata);
SBodyFromNode p1data;
p1data.Type = EBT_PRIMITIVE_CAPSULE;
p1data.Node=p1node;
p1data.Mesh=planemesh;
p1body=gameManager->getPhysicsEngine()->createCharacterController(
gameManager->getPhysicsEngine()->createBody(p1data));
p1body->setRotationUpdate(false);
p1body->setContinuousCollisionMode(true);
gameManager->getPhysicsEngine()->getUtils()->avoidRotationOnAllAxis(p1body);
IMaterial* p1material;
IMaterial* floormaterial;
p1material=gameManager->getPhysicsEngine()->createMaterial();
floormaterial=gameManager->getPhysicsEngine()->createMaterial();
p1body->setMaterial(p1material);
floorbody->setMaterial(floormaterial);
p1material->setElasticity(floormaterial,0.0f);
p1material->setFriction(floormaterial,0.0f,0.0f);
p1material->setSoftness(floormaterial,0.0f);
p1body->addForceContinuous(vector3df(0, -30.0f, 0));
camera = gameManager->getSceneManager()->addCameraSceneNode(0,
vector3df(60,40,-100), vector3df(60,40,0));
but why you execute twice the code? this create 2 bodies and not only 1, the 2 bodies are linked to the same node and this can cause strange behaviourI've also noticed every time this code is executed TWICE the other node isn't visible...
I run it twice when the game throws back to the main menu and then is restarted. I never thought about having two bodies. I altered my code to use a new physics device each time, and now the floor disappearing issue has been solved. Thanks for pointing this out XD.white tiger wrote:
but why you execute twice the code? this create 2 bodies and not only 1, the 2 bodies are linked to the same node and this can cause strange behaviour
The floor's debug info is clearly not scaled or rotated to match the floor node. What can I do to make it match up? Setting the scale of floorbody just crashes my app...white tiger wrote: also, insert
gameManager->getPhysicsEngine()->drawAllDebugInfos()
after smgr->drawAll() and before driver->endScene() and seee what happen and why it falls trought the wall. however you can't create 2 bodies wich is linked to the same node and in irrnewt character controller example the character doesn't fall trought the wall
yeswhite tiger wrote: another question: how you update irrnewt? do you put the update() call at the begin of the main loop?
in my FPS i have the restart function. i destroy the old world, create a new one and all works ok so the bug would be in your code.I run it twice when the game throws back to the main menu and then is restarted.
but does it happen only when the game restart (2nd time the code is executed) or also when the game start normally (1st time it is executed) ?The floor's debug info is clearly not scaled or rotated to match the floor node. What can I do to make it match up? Setting the scale of floorbody just crashes my app...
As I said the disappearing node is gone now so I think the bug isn't here.in my FPS i have the restart function. i destroy the old world, create a new one and all works ok so the bug would be in your code.
you should post the code wich destroy the old world and create a new one when restarting, i'll check it
It has this problem both the first and all other times now.but does it happen only when the game restart (2nd time the code is executed) or also when the game start normally (1st time it is executed) ?
Code: Select all
#include "irrlicht.h"
#include "gspgame.h"
#include "gmanager.h"
#include <irrnewt.hpp>
using namespace core;
using namespace irr;
using namespace newton;
spgame::spgame(manager* passedManager)
{
gameManager = passedManager;
gameManager->resetKeys();
planemesh = 0;
p1node = 0;
floornode = 0;
camera = 0;
p1body = 0;
pworld = createPhysicsWorld(gameManager->getDevice());
pworld->setFrictionModel(EOM_FAST);
planemesh = gameManager->getSceneManager()->getMesh("media/models/plane.3ds")->getMesh(0);
p1node = gameManager->getSceneManager()->
addOctTreeSceneNode(planemesh);
if(p1node)
{
p1node->setMaterialFlag(EMF_LIGHTING, false);
p1node->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);
p1node->setMaterialTexture(0, gameManager->getDriver()->getTexture("media/logo.png"));
}
floornode = gameManager->getSceneManager()->
addOctTreeSceneNode(planemesh);
if (floornode)
{
floornode->setMaterialFlag(EMF_LIGHTING, false);
floornode->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);
floornode->setMaterialTexture(0, gameManager->getDriver()->getTexture("media/logo.png"));
floornode->setScale(vector3df(1,15,1));
floornode->setPosition(vector3df(200, -10, 0));
floornode->setRotation(vector3df(0, 0, 90));
}
SBodyFromNode mapdata;
mapdata.Node=floornode;
mapdata.Mesh=planemesh;
floorbody=pworld->createBody(mapdata);
SBodyFromNode p1data;
p1data.Type = EBT_PRIMITIVE_CAPSULE;
p1data.Node=p1node;
p1data.Mesh=planemesh;
p1body=pworld->createCharacterController(pworld->createBody(p1data));
p1body->setRotationUpdate(false);
p1body->setContinuousCollisionMode(true);
pworld->getUtils()->avoidRotationOnAllAxis(p1body);
IMaterial* p1material;
IMaterial* floormaterial;
p1material=pworld->createMaterial();
floormaterial=pworld->createMaterial();
p1body->setMaterial(p1material);
floorbody->setMaterial(floormaterial);
p1material->setElasticity(floormaterial,0.0f);
p1material->setFriction(floormaterial,5.0f,5.0f);
p1material->setSoftness(floormaterial,0.0f);
//p1body->addForceContinuous(0,-30.0f,0);
camera = gameManager->getSceneManager()->addCameraSceneNode(0,
vector3df(60,40,-100), vector3df(60,40,0));
}
void spgame::handleKeys()
{
if(gameManager->getEscapeKey())
{
gameManager->stopMusic();
gameManager->resetPause();
gameManager->setGameState(1);
}
if(gameManager->getPKey())
gameManager->togglePause();
if(gameManager->getRightKey())
{
p1body->setVelocity(vector3df(2.0f,0,0));
}
if(gameManager->getLeftKey())
{
p1body->setVelocity(vector3df(-2.0f,0,0));
}
if(gameManager->getDecimalKey())
p1body->jump(10);
if(gameManager->getDownKey())
{
if(p1body->crouch(0.5))
pworld->getUtils()->avoidRotationOnAllAxis(p1body);
}
else
if(p1body->stand(6))
pworld->getUtils()->avoidRotationOnAllAxis(p1body);
}
void spgame::updatePhysics()
{
pworld->update();
if(p1node->getPosition().X > camera->getPosition().X + 20)
{
camera->setPosition(vector3df(camera->getPosition().X+1,camera->getPosition().Y,camera->getPosition().Z));
camera->setTarget(vector3df(camera->getPosition().X,camera->getPosition().Y,0));
}
else if(p1node->getPosition().X < camera->getPosition().X - 75)
{
p1node->setPosition(vector3df(camera->getPosition().X-75,p1node->getPosition().Y,p1node->getPosition().Z));
p1body->setPosition(vector3df(camera->getPosition().X-75,p1node->getPosition().Y,p1node->getPosition().Z));
}
}
void spgame::drawDebugInfo()
{
pworld->drawAllDebugInfos();
}
spgame::~spgame()
{
pworld->destroyWorld();
}
Code: Select all
floornode->setScale(vector3df(1,15,1));