Instancing
Ok I'm not gonna post anymore.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
-
- Posts: 37
- Joined: Mon May 26, 2008 7:39 pm
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
100 skinned meshes:
Irrlicht Demos: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=6&t=45781
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
-
- Posts: 37
- Joined: Mon May 26, 2008 7:39 pm
Well, having a lot of nodes seems to be heavy. I used boxnodes as bullets. I started to make an array of 25 boxesfor just one player.
This works perfectly, If you only have one player, or even two.
But i figured that the maximum amount of players should be 16, and every player shouls have 25 projectiles, so theoreticly we could hav as much as 400 projectiles in the air.
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. And a CubeSceneNode must be much "simpler" than an IAnimatedMeshSceneNode.
One thiing is strange, 25 nodes or 250 nodes make no difference on the fps. Is there a maximum number of nodes that a scenemanager can handle??
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 );
}
But i figured that the maximum amount of players should be 16, and every player shouls have 25 projectiles, so theoreticly we could hav as much as 400 projectiles in the air.
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. And a CubeSceneNode must be much "simpler" than an IAnimatedMeshSceneNode.
One thiing is strange, 25 nodes or 250 nodes make no difference on the fps. Is there a maximum number of nodes that a scenemanager can handle??
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
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.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
-
- Posts: 37
- Joined: Mon May 26, 2008 7:39 pm
there is no error message, windows just complains that the application don't respond and i end it with the taskmanager.
MAX_NUM_BOXPROJECTILES is set to 25, it starts and exits with out problem.
if BOXPROJECTILES is sett to high, around 300 it's forces a crash.
but i'l post the whole class:
MAX_NUM_BOXPROJECTILES is set to 25, it starts and exits with out problem.
if BOXPROJECTILES is sett to high, around 300 it's forces a crash.
but i'l post the whole class:
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
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
Code: Select all
for( u8 i = 0; i< MAX_NUM_BOXPROJECTILES; i++ )
Sew-crates has a method he'd like me to try out.
What's the maximum value that a u8 can hold?
What happens when you increment a u8 that's already at its maximum value?
Sew-creates thinks that it's important to identify the problem before coming up with a solution.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
You should know that on a 32-bit system using a u8 is infact a tiny bit slower than a u32.
(So basically, I have no idea why the hell you did that.)
(So basically, I have no idea why the hell you did that.)
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
-
- Posts: 37
- Joined: Mon May 26, 2008 7:39 pm
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
A 32 bit CPU has 32 bit registers.
Moving a 32 bit value to or from a 32 bit register is generally a faster operation than moving an 8 bit value to or from a 32 bit register, as doing so requires padding or truncating it.
Moving a 32 bit value to or from a 32 bit register is generally a faster operation than moving an 8 bit value to or from a 32 bit register, as doing so requires padding or truncating it.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way