Serialising inherited actors

xadh00m

28-04-2008 09:23:03

Hi!

I currently have some doors and windows in my scene besides the static geometry, which need additional information like: locked/unlocked etc.
I plan to derive the doors and windows form the NxBody class, but I´m wondering how it fits in my current scene management. The problem is, that
It should be possible to create door and window information without actually creating them in a scene and do physx and rendering stuff. I just want to use them for
serialisation and maybe create "real" physic objects of them later. I know the Blurprint classes, but I´m not sure if its a good way to inherit from actor blueprint to solve this issue.
I´ve read the new article about the TestActor inheritance on the NxOgre site which looks promising in some ways, but unfortunately I´ve to use NxOgre
0.9 because of the character system...

betajaen

28-04-2008 09:57:35

Sad thing is. I'm working on the Serialisation system right now in 1.0'22 and the code I'm currently writing is importing serialised Actor and Inherited Actors. If you didn't need the Character System you could of migrated over when '22 comes out.

But that doesn't help you. I remember adding something in NxOgre 0.9 to deal with things like this; It's called the saveCustom/restoreCustom functions used in Inherited Actors during Serialization/Unserialisation of the Actor Blueprint.

StringPairList IActor::saveCustom() {

// Required...
StringPairList l;
l.insert("ActorType", "IActor"); // IActor or the name of your class; *Not* Actor or Body.
l.insert("Key", "Value");
// You can have multiple keys with the same name.
}

void IActor::restoreCustom(StringPairList spl) {

for (StringPairList::StringPair sp = spl.begin();spl.hasNext();) {
sp = spl.next();

NxString key = sp.first;
NxString value = sp.second;
Ogre::StringUtil::toLowerCase(key);

if (key == "x") {
mY = value;
}
}


It's a short term solution. But a better one would be to switch over to Bleeding when the Character system is written again, and take advantage of the Prototype namespace in NxOgre, and use any fileformat and data structure you wish to serialize to. ;)

xadh00m

28-04-2008 10:31:52

Ok, thank you for your very fast repsonse. :D

How do you think about using bleeding with custom character code (I tink I could use the character tut from PhysX to get started) until the NxOgre
character suppport is ready? I´ve never tried to use "manual" PhysX code with NxOgre. Maybe this way would mean a smaller refactoring impact if I
went to '23 in a few weeks/months.

betajaen

28-04-2008 10:39:40

If you want to. There is some version of the CharacterSystem in Bleeding. It just doesn't have a proper collision detection system or some of the major features. In a sense your just moving a Kinematic Actor around directly.

xadh00m

28-04-2008 12:11:45

Ok, I have discussed this issue with my chef and we came to the agreement to wait for bleeding until it supports characters.

I will use a workaround which means, that I use a class which owns the door/window NxBody. With this solution I can prevent the generation of physX
objects on construction and maintain serialisation within this wrapper classes...

Normally I would dislike to use a "third party" scene management as you implemented in bleeding,
but your tutorial about the TestActor class looks really promising.
:)

If you need help some day e.g. for documentation issues. I think there could be some help out here... 8)

betajaen

28-04-2008 12:26:34

but your tutorial about the TestActor class looks really promising.

Thankyou. When I designed it. I tried to make NxOgre not to favour a particular library or piece of code, but to make it fairly concrete and organized on how things should be.

I think it's turned out well, and I would love to see peoples implementations of an InheritedActor to see how they got on.

Additionally, I shall be writing and publishing another article on the Wiki; Describing in great detail on how to create a render system and make Body class use it. It may involve using a sound library. ;)