Odd behavior when adding lots of nodes and entities.

EagleEye

16-04-2006 22:28:58

I had not encountered this behavior previously, because I had not had my network code completed... and all item data is on the server, and is sent to the client upon "entering the world".

However, now that all that's done, I'm getting packets of data really quickly (each packet defines an item in the world, in this case the ogre head, its location and orientation... each packet is only 400 bytes or so)...

All of these items are being added to the world in rapid succession... and when that happens, I can no longer change my pitch/yaw/roll of my character/camera node...

The ORIENTATION of my character changes (I know this because I send orientation update packets to the server, and I see them coming in... and it is, indeed, changing!) But the view on my screen just locks up looking at the same area...

I can still see the clouds flowing by in my skydome, so rendering isn't locked up... it's still rendering frames, hitting the "onFrameStarted" and "onFrameEnded" subs...

So I decided to remove the server stuff and test it locally...

I created a For loop that creates 200 Ogre Heads and adds them to the world.

It seems that if I add all the items BEFORE the scene renders initially, everything is fine... I get 200 ogre heads on my screen.

If I wait until the scene is rendered, THEN add them (like having the adding of the items being triggered by a mouse click), then I experience the problem.

My thinking is that somehow an internal ogre thread is being overloaded and causing it to abort... possibly having to do with scenenode updates or something... I'm not sure about the internal workings of Ogre...

Right now, I'm not creating the scenenodes separately... I"m doing:


With Item
Nodes.Add(WorldNode.CreateChildSceneNode(.Position, .Orientation), .ItemName)
Entities.Add(Scene.CreateEntity(.ItemName, .Mesh & ".mesh"), .ItemName)
Nodes.Item(.ItemName).AttachObject(Entities.Item(.ItemName))
End With


So the nodes are being created as subnodes of the main "worldnode" (which is the same as "Scene.GetRootSceneNode" in my program)...

I will TRY just creating the nodes then adding them later... but for now this is what I have.

EagleEye

16-04-2006 22:35:20

I should also mention that my CEGUI works... my mouse (when visible) moves around the screen and is able to interact with the GUI fine...

I get no errors in my log file...

In fact, I put a loop in my "onFrameStarted" to rotate each of the ogre heads a few degrees, and now I have a bunch of ogreheads around me, rotating, but I can't look around...

rastaman

16-04-2006 23:37:35

I don't have much trouble adding lots of objects after rendering starts. Just frame rate goes down and moving become a problem when there are alot of objects on screen.

Try this test press y and it will add 200 ogre heads

using System;
using System.Drawing;

using Math3D;
using OgreDotNet;

namespace ODNTester
{

class cODNTester1 : OgreDotNet.ExampleApplication
{
protected OgreDotNet.Log mLog;

protected override void CreateScene()
{
mLog = LogManager.Singleton.createLog("ODNTester.log", false, true );
mLog.LogMessage(string.Format("ODNTester log {0}" , System.DateTime.Now ) );

create4LineDebugOverLay();
Show4LineDebugOverLay();

mSceneManager.SetSkyBox(true, "Examples/CloudyNoonSkyBox" );

Entity e=null;
SceneNode n=null;

//create a ground plain
Plane plane = new Plane();
plane.Normal.x=0;
plane.Normal.y=1;
plane.Normal.z=0;
plane.D = 0;
MeshPtr m = MeshManager.GetSingleton().CreatePlane( "Ground", "General" , plane,
5000,5000,10,10,true,1,50,50,Vector3.UnitZ );
e = mSceneManager.CreateEntity( "Ground", "Ground" );
e.SetMaterialName("Examples/GrassFloor");
e.SetCastShadows(false);
mSceneManager.GetRootSceneNode().CreateChildSceneNode("Ground").AttachObject(e);
m.SetNull();
m=null;


mCamera.Move( new Vector3(0, 200, 600) );
mCamera.LookAt = new Vector3( 0, 0, 0 );
}

protected override void CreateEventHandler()
{
/** change last paramater to false to disable input **/
mEventHandler = new OgreDotNet.EventHandler( mRoot, mRenderWindow , true );
mEventHandler.SubscribeEvents();
mEventHandler.FrameStarted += new FrameEventDelegate( FrameStarted );
mEventHandler.FrameEnded += new FrameEventDelegate( FrameEnded );
mEventHandler.KeyClicked += new KeyEventDelegate( KeyClicked );
mEventHandler.KeyPressed += new KeyEventDelegate( KeyPressed );
mEventHandler.KeyReleased += new KeyEventDelegate( KeyReleased );
mEventHandler.MouseMoved += new MouseMotionEventDelegate( MouseMotion );
mEventHandler.MouseClicked += new MouseEventDelegate( MouseClick );
mEventHandler.MousePressed += new MouseEventDelegate( MousePressed );
mEventHandler.MouseReleased += new MouseEventDelegate( MouseReleased );
mEventHandler.MouseDragged += new MouseMotionEventDelegate( MouseDragged );
}

private static int zzz=0;
protected override bool FrameStarted( FrameEvent e )
{
/** for testing to close after a time, good when disabling input **
if (zzz++ > 200)
return false;
/****/

if (!base.FrameStarted( e ))
return false;

return true;
}

protected override bool FrameEnded( FrameEvent e )
{
if (!base.FrameEnded( e ))
return false;

SetDebugCaption( 0, string.Format("Camera Location: ({0}, {1}, {2}) ",
mCamera.GetPosition().x, mCamera.GetPosition().y, mCamera.GetPosition().z ));

SetDebugCaption( 1, string.Format("Camera Orientation: ({0}, {1}, {2}, {3}) ",
mCamera.GetOrientation().x, mCamera.GetOrientation().y, mCamera.GetOrientation().z, mCamera.GetOrientation().w ));

return true;
}

protected int headCount=0;
protected float rot=0.0f, rotstep=10.0f, scaleout=5.0f;

protected override void KeyClicked( KeyEvent e )
{
switch( e.KeyCode )
{
case KeyCode.Y:
for (int i=0; i<100; i++)
{
Quaternion qrot = Quaternion.FromAngleDegreeAxis(rot, Vector3.UnitY);
rot += rotstep;
if (rot>360.0f) {
rot=-360.0f;
scaleout+=5.0f;
}
Entity entity=mSceneManager.CreateEntity( "head" + headCount.ToString(), "ogrehead.mesh" );
entity.SetCastShadows(false);
Vector3 v= Vector3.UnitZ * scaleout;
v = qrot * v;
SceneNode n =mSceneManager.GetRootSceneNode().CreateChildSceneNode("head" + headCount.ToString(), v);
n.AttachObject(entity);
n.SetScale(0.25f, 0.25f, 0.25f);
headCount++;
}
break;
default:
base.KeyClicked(e);
break;
}
}

public override void Dispose()
{
mLog.Dispose();
mLog=null;
base.Dispose();
}

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
cODNTester1 app = new cODNTester1();
try
{
app.Start();
}
catch ( Exception ex)
{
Console.WriteLine( "### Exception {0}\n{1}\n{2}", ex.Message ,ex.Source , ex.StackTrace );
}
finally
{
try
{
app.Dispose();
}
catch ( Exception ex)
{
Console.WriteLine( "### Exception {0}\n{1}\n{2}", ex.Message ,ex.Source , ex.StackTrace );
}
}
}
}
}


edit: fixed code slerp not working like I thought

EagleEye

17-04-2006 01:30:29

It's odd... it's not happening anymore for me... not sure what I did to fix it.