Posted: Fri Jul 04, 2008 12:59 pm
yes, yes, we all know you're a genius blindside
Official forum of the Irrlicht Engine
https://irrlicht.sourceforge.io/forum/
Pah! They're not even animated!dlangdev wrote:"I know Ogre has an instacing demo and Ogre like Irrlicht uses scene nodes and a scenemanager."
This is what he was talking about. Definitely GPU assisted instancing.
http://www.ogre3d.org/phpBB2/viewtopic.php?t=20193
The actual crowd demo is animated.sio2 wrote:Pah! They're not even animated!dlangdev wrote:"I know Ogre has an instacing demo and Ogre like Irrlicht uses scene nodes and a scenemanager."
This is what he was talking about. Definitely GPU assisted instancing.
http://www.ogre3d.org/phpBB2/viewtopic.php?t=20193
Code: Select all
for( u8 i = 0; i< MAX_NUM_BOXPROJECTILES; i++ )
{
m_ppBoxProjectiles[ i ] = new SProjectile();
m_ppBoxProjectiles[ i ]->Direction = vector3df( 0.0f, 0.0f, 0.0f );
m_ppBoxProjectiles[ i ]->pMesh = NULL;
m_ppBoxProjectiles[ i ]->pNode = pScene->addCubeSceneNode( 5.0f );
m_ppBoxProjectiles[ i ]->Position = vector3df( 0.0f, 0.0f, 0.0f );
m_ppBoxProjectiles[ i ]->Roration = Tmp;
m_ppBoxProjectiles[ i ]->Speed = 300.0f;
m_ppBoxProjectiles[ i ]->TimeToImpact = 0.0f;
m_ppBoxProjectiles[ i ]->pNode->setVisible( false );
}
There is no hard limit, and a crash generally indicates user error. If you post a test case that reproduces the behaviour, I'm sure that we can find the problem.}{ermanssoN wrote:But initializing 400 boxes was not an good idea. The program won't even start. I managed to create up to 250. but more just makes the program crash.
Code: Select all
#ifndef _PROJECTILEMANAGER_CPP
#define _PROJECTILEMANAGER_CPP
#include "globals.h"
ProjectileManager::ProjectileManager( void )
{
m_ppBoxProjectiles = NULL;
m_NumFired = 0;
}
ProjectileManager::~ProjectileManager( void )
{
}
bool
ProjectileManager::InitializeManager( void )
{
ISceneManager* pScene = g_pApp->GetSceneManager();
m_ppBoxProjectiles = new SProjectile*[ MAX_NUM_BOXPROJECTILES ];
memset( m_ppBoxProjectiles, 0, sizeof(SProjectile**) * MAX_NUM_BOXPROJECTILES );
SRotation Tmp;
Tmp.X = 0.0f;
Tmp.Y = 0.0f;
Tmp.Y = 0.0f;
for( u8 i = 0; i< MAX_NUM_BOXPROJECTILES; i++ )
{
m_ppBoxProjectiles[ i ] = new SProjectile();
m_ppBoxProjectiles[ i ]->Direction = vector3df( 0.0f, 0.0f, 0.0f );
m_ppBoxProjectiles[ i ]->pMesh = NULL;
m_ppBoxProjectiles[ i ]->pNode = pScene->addCubeSceneNode( 5.0f );
m_ppBoxProjectiles[ i ]->Position = vector3df( 0.0f, 0.0f, 0.0f );
m_ppBoxProjectiles[ i ]->Roration = Tmp;
m_ppBoxProjectiles[ i ]->Speed = 300.0f;
m_ppBoxProjectiles[ i ]->TimeToImpact = 0.0f;
m_ppBoxProjectiles[ i ]->pNode->setVisible( false );
}
SWorld* pWorld = g_pApp->GetWorldManager()->GetActiveWorld();
m_pTringleSelector = pScene->createOctTreeTriangleSelector( pWorld->pWorldMesh->getMesh( 0 ), pWorld->pWorldNode, 128 );
return true;
}
bool
ProjectileManager::DestroyManager( void )
{
if( m_ppBoxProjectiles )
{
for( u8 i = 0; i< MAX_NUM_BOXPROJECTILES; i++ )
{
if( m_ppBoxProjectiles [ i ] && m_ppBoxProjectiles [ i ]->pNode )
m_ppBoxProjectiles[ i ]->pNode->remove();
}
delete [] m_ppBoxProjectiles;
}
return true;
}
void
ProjectileManager::FireProjectile(irr::core::vector3df Direction, irr::core::vector3df StartPosition)
{
for( u8 i = 0; i< MAX_NUM_BOXPROJECTILES; i++ )
{
SProjectile* pProjectile = m_ppBoxProjectiles[ i ];
if( pProjectile && !pProjectile->pNode->isVisible() )
{
MathManager* pMath = g_pApp->GetMathManager();
ISceneCollisionManager* pCollision = g_pApp->GetSceneManager()->getSceneCollisionManager();
vector3df TravelVec,Intersection;
triangle3df Trinagle;
if( pCollision->getCollisionPoint( pMath->GetLineOfFire( StartPosition, Direction, 2000.0f ), m_pTringleSelector, Intersection, Trinagle ))
TravelVec = Intersection - StartPosition;
pProjectile->Direction = Direction;
pProjectile->Position = StartPosition;
pProjectile->pNode->setVisible( true );
pProjectile->TimeToImpact = pMath->CalculateTimeToIntersection( TravelVec.getLength(), pProjectile->Speed );
pProjectile->pNode->setPosition( StartPosition );
pProjectile->pNode->updateAbsolutePosition();
m_NumFired ++;
g_pApp->GetIrrDevice()->getLogger()->log( "Projectile fired\n" );
return;
}
}
}
void
ProjectileManager::Update( void )
{
f32 DeltaTime = g_pApp->GetTimeManager()->GetDeltaTime();
for( u8 i = 0; i< MAX_NUM_BOXPROJECTILES; i++ )
{
SProjectile* pProjectile = m_ppBoxProjectiles[ i ];
if( pProjectile && pProjectile->pNode->isVisible() )
{
if( pProjectile->TimeToImpact > 0.0f )
{
pProjectile->Position += pProjectile->Direction * ( DeltaTime * pProjectile->Speed );
pProjectile->pNode->setPosition( pProjectile->Position );
pProjectile->pNode->updateAbsolutePosition();
pProjectile->TimeToImpact -= DeltaTime;
}
else
{
g_pApp->GetIrrDevice()->getLogger()->log( "Prijectile hit\n" );
pProjectile->pNode->setVisible( false );
pProjectile->TimeToImpact = 0.0f;
}
}
}
}
SProjectile*
ProjectileManager::GetProjectile( u8 Index )
{
if( m_ppBoxProjectiles[ Index ] && Index <= MAX_NUM_BOXPROJECTILES )
return m_ppBoxProjectiles[ Index ];
else
return NULL;
}
vector3df
ProjectileManager::GetProjectilePosition( u8 Index )
{
if( m_ppBoxProjectiles[ Index ] && Index <= MAX_NUM_BOXPROJECTILES )
return m_ppBoxProjectiles[ Index ]->Position;
else
return vector3df( 0.0f, 0.0f, 0.0f );
}
#endif //_PROJECTILEMANAGER_CPP
Code: Select all
for( u8 i = 0; i< MAX_NUM_BOXPROJECTILES; i++ )