[Bleeding] 1.0'22T2 (Unstable) - Take Two!

betajaen

03-10-2008 12:44:02

Here we go (again)

This is the take two of NxOgre 1.0'22, with most of the changes of the previous release minus the map changes. Of course; I've worked with this code for under 24 hours, so I declare it unstable.

However; not to confuse the newbies I won't be placing it on the SVN straight away, until I am satisfied that it actually works with the masses - due to the changes of the core parts.

If you have been using NxOgre for less than two weeks, and even attempt to download this file - I WILL LAUGH AT YOU.

Release Notes

1.0 '22T2
~ SharedList class update.
~ Rewrote the Raycaster class.
+ Added Prototype system
~ Changed Scene to use RenderableActorFactory
+ Added RenderableActorFactory and BodyFactory class.
~ Resource System improvements
+ Added support for Memory Macros changes in Ogre 1.6.0
+ Updated ActorParams to new Params style.
+ Moved to it's own header and source file.
~ Mass default is now 1.0f
+ BodyFlag struct to replace most of the BodyFlags (see FreezeFlag)
+ FreezeFlag struct to replace the NX_BF_FROZEN enum applied to the BodyFlags
~ When setting mass, the density is set to zero and vice versa.

Deprecation notice
------------------

ActorParams class in NxOgreActor.h/NxOgreActor.cpp
--------------------------------------------------

1. String parameters in ActorParams that are form of lineardamping, angulardamping, etc. are
now in the new form of linear-damping, angular-damping, etc.

2. Parameters that have two types of inputs; i.e. groups or materials now share the
same param name, and use a DualIdentifier<> class to represent them.

group: 1 (integer id)
group: red (string id)


------------------------------------------------------------------------------------------
To support your migration over to the new standards set. NxOgre will keep the old system
and the new system running until NxOgre 1.0'24. From that time onwards the new code will
exist and the old code will be removed.




Download

http://get.nxogre.org/releases/NxOgre.1.0.22T2.zip (396kb)

All problems, compile errors and thumbs up in this thread only.
If I see any posts outside this thread - I WILL DELETE THEM.

betajaen

03-10-2008 13:05:12

Scene::createBody changes, and how I learned to love the new Body template system

To use the createBody function in Scene, you now have to specify which Actor derived class you want to use. This is supplied as a single template argument. I've provided a BodyFactory and adjusted the NxOgre body class to be part of this to.

So to create a NxOgre body we do:

mScene->createBody<Body>(..)

How you you use your own inherited actors, and what to change is explained in full in Inheriting the Actor and RenderableFactory.

mcaden

03-10-2008 18:00:53

Woot!

I've been working on a website for my game all day. I'll hop on testing '22T2 tomorrow.

Caphalor

04-10-2008 01:35:27

It seems to work without problems. Thanks! :D

mcaden

04-10-2008 09:12:48

setting groups in ActorParams


actorParams.mGroup = "player";



Error 1 error C2679: binary '=' : no operator found which takes a right-hand operand of type 'const char [7]' (or there is no acceptable conversion) c:\ogre\Samples\Hellhound\Source\src\DotSceneLoader.cpp 26


What's the correct way to set it? Or do I have to wait till after the actor is created and use myActor->setGroup(...);?



EDIT: Everything else seems to work peachy...about to work on inheriting actor and using my own body class...we'll see how well it works.

betajaen

04-10-2008 10:41:21

I must of missed the assignment operators for that.

I believe it goes (for now):

actorParams.mGroup.mSecond = "player";

It may be second instead of "mSecond" though.

mcaden

04-10-2008 11:06:17

I got my player class revamped to be a body now and I got it to compile and everything using the new system. I've got an exception happening and I'm about to debug it.





One difficulty I've had is that the wiki has issues. The example is not complete (like that it needs an overloaded constructor for visualIdentifier) and there's a parentheses that isn't supposed to be there.

EDIT:

Exception happened here:


void Actor::setGroup(ActorGroup* ag) {
mActor->setGroup(ag->getGroupID());
}

from call:

mPlayer = (Player*)mScene->createBody<Player>(renderParams.mIdentifier,
collisionShape, actorPose, renderParams, actorParams);
mPlayer->setGroup( mScene->getActorGroup( "player" ) );//<< crashed in this function

Judging from the variables I have no idea why it crashed...it's acting like it's a bad pointer...but ag has all it's variables intact (groupID of 1, group name of "player", etc...)

I have to go to dinner. When I get back I'll start putting in breakpoints and track down what's going on.

betajaen

04-10-2008 11:46:05

It's the same bug as last time regarding the groups.

I'll find out what I did to fix it, and post up a new copy.

mcaden

04-10-2008 12:36:37

K, I forgot about other plans happening tonight so it'll be a few hours before I can get back to coding.

I'll sit tight till your update I suppose.

I remember there being a bug related to setting groups...but I don't remember it causing an exception though.

mcaden

04-10-2008 17:25:08

As I suspected, the crash wasn't anything to do with the groups.

It was actually in the code I was using from the wiki. In following that code the function createRendereredActor(...) always returned NULL so when the setActor(...) function was called from mActor, mActor was NULL so there was an access violation.

After I corrected the various issues with the wiki code everything worked great. I really like this system. It seems very stable/clean with the way I have my game set up. I like it where my player class "is a" body rather than "has a" body.

My player is now made using createBody<Player>(...) and fully reacts to forces and callbacks.


EDIT:

Wiki issues -

mScene->registerRenderableActorFactory(TestActor::FactoryIdentifier, new TestFactory)(), true);

has an extra closing parentheses...it should be

mScene->registerRenderableActorFactory(TestActor::FactoryIdentifier, new TestFactory(), true);


the renderableFactory code should be

class TestFactory : public NxOgre::RenderableActorFactory {

public:

~TestFactory() {}

// For Bodies that use the VisualIdentifier (body;body.mesh).
Actor* createRendereredActor(
Scene* scene, const VisualIdentifier& vi,
const ActorParams& a_params, const NxOgre::Pose& pose,
Shape* shape, unsigned int FactoryIdentifier
)
{
// Using the FactoryIdentifier as a point of reference, this class can be registered
// multiple times as a RenderableActorFactory, without the need for one factory for one body.
if (FactoryIdentifier == TestActor::FactoryIdentifier)
{
TestActor* actor = new TestActor(vi, pose, shape, scene, ar_params); //<<Correction: I swapped "pose" and "scene"
mTestActors.Insert(actor); // We manage the pointers for inherited Actors. So the SharedList which
// uses garbage collection is a nice container to use.
return actor; //<<Correction: Add this
}

return NULL; // Whoops, somebody registered this Factory with the wrong FactoryIdentifier.

}

// For Bodies that use the NodeRenderableParams.
Actor* createRendereredActor(
Scene*, const NxString& identifier,
const ActorParams& a_params, const NodeRenderableParams& nr_params,
const NxOgre::Pose& pose, Shape* shape,
unsigned int FactoryIdentifier)
{
// Again the FactoryIdentifier as a point of reference, we can work with many
// different types of inherited Actors with one class.
if (FactoryIdentifier == TestActor::FactoryIdentifier)
{
TestActor* actor = new TestActor(identifier, pose, shape, scene, nr_params, a_params); //<<Correction: I swapped "pose" and "scene"
mTestActors.Insert(actor); // We manage the pointers for inherited Actors. So the SharedList which
// uses garbage collection is a nice container to use.
return actor; //<<Correction: Add this
}

return NULL;
}

Betajaen::SharedList<TestActor> mTestActors;

};

(the 4 corrections made above are marked in the comments...simple return statements added and incorrect variable order passed to the TestActor constructor)

And lastly: TestActor needs another constructor for using the VisualIdentifier method.

betajaen

07-10-2008 20:36:23

Thanks. I was editing that within the webpage, the editor is a bit of a pain and doesn't highlight code for me.

buckEd

09-11-2008 16:13:26

I found something which is quite confusing.
When deriving my own Factoryclass as desribed above I stumbled across an error, which stated that this Factory was an abstract class and could not be initialised.
The solution:
I tiped TestFactory::createRenderedactor(), whereas in the RenderableActorFactory.h file it is called createRendereredactor().
Note that there is one "er" too much in the word renderered. Thus the two methods were not overridden and my derived class was abstract.
I don't know if this was intended or if it is a typo, but the eye always only sees what it wants to see, and I am almost sure I am not the only person to have made this mistake. So if anyone ever wonders why his factory is abstract even though he tiped all the code from the examples (I do never copy and paste cause by tiping it you learn quite something) that is the reason why.
On the NxOgre page it is the same thing.

So was it intended or did it happen accidently?

mcaden

10-11-2008 10:38:49

I noticed it, programmed around it, and forgot about it.