XNA Game Development Forums
2012/05/21 20:05:21 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Calendar Login Register  
Pages: [1]
  Print  
Author Topic: XNA Editor Load while already running  (Read 4759 times)
Mike2
Newbie
*
Offline Offline

Posts: 16


View Profile
« on: 2007/08/18 11:26:44 »

Hey Guys,

First of all, I followed/reading the build up of the XNA engine with close attention.
I'm building my own engine (not as good as this one, more like comparing a Ferrari with a cheap japanees brand-car).

The thing I was wondering was, I have my own scene graph lay-out, and while the editor is running I want to insert a fully new object... How can I (as LoadGraphicsContent already passed), load the new object into play?

I think I'm missing out a piece that I'm overlooking, but if so, you are definitly the ones who can help me out with this problem.
Perhaps explained with so visuals (code etc. if possible)? may also be pseudo code, just to set me back on track.

Greetz
Mike
Logged
Nemo Krad
Global Moderator
Hero Member
*****
Offline Offline

Posts: 512


I have seen the fnords


View Profile WWW
« Reply #1 on: 2007/08/18 12:26:18 »

Well not knowing your engine mate, this is a tough one to answer...

Within the HM framework I guess you could a a method to the engine class to accept a new object. As this class has both GraphicsDevice and ContentmentManager objects you can pass these to the LoadGraphicsContent of the new object and so get the object loaded at any time.

Logged
Mike2
Newbie
*
Offline Offline

Posts: 16


View Profile
« Reply #2 on: 2007/08/18 12:35:46 »

Lets say, if I have a Scenemanager-sort like this set up, where you can add and delete object in the scene... after in the open-windows the user click "ok" at that instance I add the object to the scene. And then???
I think its not a case off how your "engine" looks like in my humble opinion, just to let XNA a know he has to load or re-initialise the loadgraphicscontent, no?

Already much thanks for your quick reply, but still it's a black matter for me :S

Greetz
Mike

<Edit>
After reading your post once again...
Do you mean, after the adding of the object I just have to call

"IceSetup.Root.LoadGraphicsContent(graphics.GraphicsDevice, content);"

and everything already added to the scene is "re-loaded" at that moment? Is it that simple or what? Cheesy

Once again
Greetz
Mike
</edit>
« Last Edit: 2007/08/18 12:39:59 by Mike2 » Logged
Mike2
Newbie
*
Offline Offline

Posts: 16


View Profile
« Reply #3 on: 2007/08/18 12:59:10 »

Nemo Krad,

Thx dude, the thing you said or I think you meant, worked Cheesy
I just "re-boot" the scene with a call to the loadgraphicxscontent and it works!!!!

great!!!!

cheers
Mike
Logged
Nemo Krad
Global Moderator
Hero Member
*****
Offline Offline

Posts: 512


I have seen the fnords


View Profile WWW
« Reply #4 on: 2007/08/18 13:16:00 »

Hey Mike2,

Well I was not thinking of reloading the whole scene rather just the object you have just added...

But if that works for you and you don't get a performance hit then great! Smiley
Logged
Mike2
Newbie
*
Offline Offline

Posts: 16


View Profile
« Reply #5 on: 2007/08/18 15:07:58 »

Hey Nemo,

Performance hit in a editor-envirment??? Tongue
In the editor bits and pieces can be added or deleted, in game they shall be visible or non visible...

Logged
Chr0n1x
Global Moderator
Sr. Member
*****
Offline Offline

Posts: 307


View Profile WWW
« Reply #6 on: 2007/08/18 18:25:06 »

He kinda means that in a complex scene, youre going to be sitting there waiting for the scene to load every time you add something. Rather have a special method that does the same thing loadgraphicscontent does, but only the stuff for the new object.
So in pseudocode
Code:
BEGIN LoadNewObj(string path)
    Scene.Add(ContentManager.Load<Type>(path)
END

So youre writing a content loader that just does one object rather than everything all over again. You'll need to think of how youre going to determine the type for the loader, maybe a switch statement, or seperate load methods for different types, or even Generics.
Logged

muchrejoicing
Newbie
*
Offline Offline

Posts: 46


View Profile
« Reply #7 on: 2007/08/20 06:04:37 »

Unless you call UnloadGraphicsContent, you won't be reloading all your content. XNA's content manager would have to look up all the assets and return the already-loaded data, which at least won't involve going to disk for the files. You can probably get away with it on small scenes, but there's absolutely a better way; reloading the whole scene really is a big hit -- if you added 10 items to a scene one by one, you'd end up calling Load() 55 times, rather than just 10. (1 + 2 + 3 + ... + 10)

I think the point of these suggestions has been, you can easily call some sort of LoadGraphicsContent function for a single asset; so, when you hit "Add" or "Ok," your editor code can call contentManager.Load() before you even add the object to your scene.
Logged
Chr0n1x
Global Moderator
Sr. Member
*****
Offline Offline

Posts: 307


View Profile WWW
« Reply #8 on: 2007/08/22 00:28:44 »

Even if it doesnt go to disk, the ContentManager still makes a copy of the object every time, that takes time, as well as valuable memory, which can severely impact your performance. That is after all why they suggest to pass Vector3 and Matrix parameters as references so it doesnt copy them for every method.
Logged

muchrejoicing
Newbie
*
Offline Offline

Posts: 46


View Profile
« Reply #9 on: 2007/08/22 06:26:32 »

...ouch. Thanks for catching that.
Logged
Nemo Krad
Global Moderator
Hero Member
*****
Offline Offline

Posts: 512


I have seen the fnords


View Profile WWW
« Reply #10 on: 2007/08/22 06:38:32 »

Yes, Chr0n1x is pretty good isn't he Smiley

In short, just load the stuff when you add it, per item. Don't go reloading a whole scene when only one item has been added.
Logged
muchrejoicing
Newbie
*
Offline Offline

Posts: 46


View Profile
« Reply #11 on: 2007/08/22 16:10:32 »

I looked in to ContentManager.Load to see where I got the idea that it wouldn't create new instances of an asset you already loaded, and found this in the API:
Quote
Return Value
The loaded asset. Repeated calls to load the same asset will return the same object instance.

I also found a thread that went into some good detail on how to get Load to return a new instance. So, while this is computational masochism, it only goes so far as needlessly reassigning all your content pointers.

Disclaimer: This doesn't change the fact that the code which started this discussion will be much slower than it needs to. You dodged several bullets, but it's still just as stuck under the boulder.
Logged
Pages: [1]
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Hazy Mind Scene Editor Hazy Mind Scene Editor mikeschuld 5 4607 Last post 2006/11/10 23:34:51
by AndroiD
How can i edit in science editor General Discussion satsatsat 1 1621 Last post 2006/10/15 20:54:37
by mikeschuld
Tutorial 9 :: Running the Engine on the Xbox 360 Tutorial Discussion mikeschuld 6 3497 Last post 2007/03/09 23:54:35
by Tiago
Crytek Engine 2 level editor General Discussion Cdy7e 7 2651 Last post 2007/03/15 18:55:36
by Chr0n1x
XNA Animation Component Library in XNA HMEngine Hazy Mind XNA Engine dotslash 0 2621 Last post 2007/05/31 13:53:12
by dotslash
Physics simulation: BulletX (Bullet for XNA) physics and Hazy Mind Xna Engine Hazy Mind XNA Engine Yubastard 6 5561 Last post 2007/08/12 08:57:21
by Yubastard
Running Hazy Mind engine on another machine Hazy Mind XNA Engine Silvo 2 1789 Last post 2008/04/12 22:34:29
by Silvo
Powered by MySQL Powered by PHP Powered by SMF 1.1.12 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.132 seconds with 18 queries.