The New NxOgre RenderSystems with Irrlicht proof of concept!

betajaen

29-11-2007 19:40:48

I've decided to divert the future of NxOgre every so slightly. I love Ogre to pieces, I really do. But I think it's time NxOgre should reign over other rendering and game engines, not only that I don't think NxOgre should say how things should be rendered.

Inheritable Actors was the big thing of 3rd generation of NxOgre, but I don't feel it's enough. Today we have instancing and render call optimisation which can't fit into the Inheritable actor model, and what happens if you don't want to use a Node. Or you do, but you want to use your own SceneNode wrapper? You can't. Then you have specific things like cloth, or wheels which you have no control over.

So I introduce "Renderables"; NodeRenderable, AnimatedRenderable, MeshRenderable, VoxelRenderable and SpriteRenderable, small neat abstract classes which anything that needs to be rendered uses one of those. The implementation of those aren't up to NxOgre. NxOgre just uses them an expects them to be complete.

Sounds good so far? How do we control these Renderables, and how do make sure the Renderable I want is the one that the Actor uses? We use RenderSystems. They don't have to be as grand as a complete wrapper to a rendering engine, they can just be a simple wrapper for your special node class. Infact they don't even have to render, NodeRenderable could just append the position of the Actor to disk, or better still to a network library!

You with me so far? No? http://www.nxogre.org/NxOgreUML1.jpg

Anyway. With these new wonderful wrapped classes to handle the render specific things, what happens to Ogre? Well by the time NxOgre 1.5 is around, I wish to be able to compile NxOgre without a single reference to a Ogre header file or library, not have it in the linker settings. But replace it with a DLL; just like DirectX and OpenGL RenderSystems are with Ogre. Just think you could have NxOgre working with Gamebyro, or a little closer to home with NeoAxis.

For clarification, I am not "dropping" Ogre. I'm merley moving it aside a little so other rendering and game engines can have a go too. Ogre will always be the number one rendering engine for me, and the default Rendering System for NxOgre.

For a proof of concept, and to show it is going forward. In 20 minutes, I wrote a simple and very quick SceneRenderer and NodeRenderable for Irrlicht; the unspellable, games engine which many people compare Ogre to.

If you don't believe me; scroll down.

#include "Cake2Frosting.h"
#include <math.h>

#include <irrlicht.h>


using namespace NxOgre;
using namespace Ogre;
using namespace std;
using namespace irr;

IrrlichtDevice *device;
video::IVideoDriver* driver;
scene::ISceneManager* scenemgr;
scene::ICameraSceneNode* cameranode;

class ISceneRenderer;

class INodeRenderable : public NodeRenderable {

public:

INodeRenderable(NodeRenderableParams params, SceneRenderer* renderer)
: NodeRenderable(params, renderer) {

mNode = scenemgr->addAnimatedMeshSceneNode(scenemgr->getMesh(params.GraphicsModel.c_str()));

if (params.GraphicsModelMaterial.size() >= 1)
{
mNode->setMaterialTexture(0, driver->getTexture(params.GraphicsModelMaterial.c_str()));
mNode->setMaterialFlag(video::EMF_LIGHTING, false);
}

if (params.GraphicsModelScale != NxVec3(1,1,1))
{
mNode->setScale(core::vector3df(params.GraphicsModelScale.x, params.GraphicsModelScale.y, params.GraphicsModelScale.z));
}

}

~INodeRenderable() {

}

void setPose(const NxOgre::Pose& p) {
mNode->setPosition(core::vector3df(p.v.x, p.v.y, p.v.z));
}

NxOgre::Pose getPose() const {
NxOgre::Pose p;
core::vector3df np = mNode->getPosition();
p.v.x = np.X;
p.v.y = np.Y;
p.v.z = np.Z;

core::vector3df nr = mNode->getRotation();
Ogre::Vector3 v(nr.X, nr.Y, nr.Z);

p.q = NxConvert<NxQuat, Ogre::Quaternion>(Ogre::Quaternion(&v));
return p;
}

void setMaterial(const NxString&) {}
NxString getMaterial() const {return "";}

void setScale(const Ogre::Vector3&) {}
void setScale(const NxVec3&) {}
Ogre::Vector3 getScale() const {return Vector3(0,0,0);}
NxVec3 getScaleAsNxVec3() const {return NxVec3(0,0,0);}

void setOffset(const NxOgre::Pose&) {}
NxOgre::Pose getOffset() const {return NxOgre::Pose();}

NxString getType() {return "Irrlicht-NodeRenderable";}
NxShortHashIdentifier getHashType() const {return 51418;}


protected:

scene::IAnimatedMeshSceneNode* mNode;
irr::scene::ISceneManager* mSceneMgr;

private:


};

class ISceneRenderer : public SceneRenderer {

friend class Scene;

public:

ISceneRenderer(Scene* s) : SceneRenderer(s) {
}

~ISceneRenderer() {
}

NodeRenderable* createNodeRenderable(NodeRenderableParams params) {
INodeRenderable* renderable = new INodeRenderable(params, this);
return renderable;
}
private:
};

class Sponge_Cake : public Cake {
public:
World* mWorld;
Scene* mScene;

void createPhysics() {

// start up the engine
device = createDevice(video::EDT_DIRECT3D8, core::dimension2d<s32>(640,480));
driver = device->getVideoDriver();
scenemgr = device->getSceneManager();
device->setWindowCaption(L"Cake2 Irrlicht Version Powered by NxOgre");
cameranode = scenemgr->addCameraSceneNode();


mWorld = new World("log: html");
mScene = mWorld->createScene("Main", mSceneMgr, "gravity: yes, floor: yes, controller: fixed, renderer: null");//, time-step-method: async");

mScene->setSceneRenderer(new ISceneRenderer(mScene));

for (int i=0;i < 16;i++)
Body* b = mScene->createBody("cube", new CubeShape(1), Vector3(0,5 + i,float(i) * 0.01f), "model: cube.1m.mesh, material: sphere.jpg", "mass: 10");

}

void destroyPhysics() {
// delete device
device->drop();
delete mWorld;
}

void onFrame(float deltaTime) {

cameranode->setPosition(core::vector3df(mCamera->getPosition().x, mCamera->getPosition().y, mCamera->getPosition().z));
cameranode->setTarget(core::vector3df(0,2,0));
mCamera->lookAt(0,2,0);

driver->beginScene(true, true, video::SColor(255,0,0,255));
scenemgr->drawAll();
driver->endScene();


if (mKeyboard->isKeyDown(mKeys[AC_OPTION_1]) && mTargetActor) {
Actor* a = mTargetActor;
unselectTargetActor();
mTargetActor = 0;
mScene->destroyActor(a->getName());
}


}

BakeMyCake();
};






Questions, Comments? Complaints can be handed to NULL. And before anyone asks; The original body constructor remains, and always works with the default rendering system.

Caphalor

29-11-2007 20:38:42

On the one hand, I really understand your decision, the new concept sounds great and ist must be very interesting to implement it. On the other hand, for me personally I can't see an advantage, because I use only Ogre and I'm afraid that regular content updates will be done later.
But that's only my personal opinion and in general, I think it's a very good idea. ;)

betajaen

29-11-2007 20:48:34

The change will only affect some people, mainly who expand NxOgre with their own classes or who have specific needs, or for people who don't like how I implemented NxOgre in Ogre and prefer their own system of naming nodes, what nodes need to be attached to what and so on, or perhaps they want a kick-ass PhysX wrapper for Irrlicht ;)

Caphalor

29-11-2007 21:02:58

or for people who don't like how I implemented NxOgre in Ogre and prefer their own system of naming nodes, what nodes need to be attached to what and so on

For these things I changed the body construktor a bit. But you convinced me that the new solution for that is much more elegant. ;)

twilight17

30-11-2007 00:36:40

wow sweet, that is awesome, now NxOgre can be used with Irrlicht!, thats cool. (Not saying the Irrlicht is better :oops:) lol, great job, so now people can have a great physics system with ANY rendering engine... :!: :!: :!:

betajaen

30-11-2007 00:39:41

Well sort of.

You'll still need Ogre included/linked and of course running as a separate window with the minimum amount of plugin's loaded, and you can only use Actors, but sure yeah. ;)

twilight17

30-11-2007 02:28:07

Well sort of.

You'll still need Ogre included/linked and of course running as a separate window with the minimum amount of plugin's loaded, and you can only use Actors, but sure yeah. ;)


Is there a way to hide the Ogre render window? and does Ogre still use resources? Like the GPU and such. Or is it all to the "new" renderer?

NickM

30-11-2007 06:29:41

On the one hand, I really understand your decision, the new concept sounds great and ist must be very interesting to implement it. On the other hand, for me personally I can't see an advantage, because I use only Ogre and I'm afraid that regular content updates will be done later.
But that's only my personal opinion and in general, I think it's a very good idea. ;)


I must admit Caphalor summed up my thoughts pretty well. I'm side-lining parts of my coding while I wait for different things to be finished in NxOgre and I'm worried that my wait for these may be even longer now, it makes me consider dropping NxOgre (which I really don't want to do).
Having said all that, NxOgre is your baby betajaen and you are free to do whatever you want with it, I'll always appreciate the amount of work you have put into this for us all, thanks.

alienskull

30-11-2007 06:55:56

Does this mean you will be renaming the project? NxOgre sounds silly if you are using it in Irrlicht without any ogre in it at all.

Also since this has (in the past) always been an ogre project, would you be willing to provide the default renderSystem implementations for ogre?

I love the idea of being able to write directly to my network library (RakNet). I may be able to drop Ogre completely as a dependency for my server. That would be amazing!! I would be willing to write and share the renderSystem implementation for RakNet once this becomes available.

P.S. What font are you using in your IDE? I like it a bit more than mine(Lucida Console)

betajaen

30-11-2007 09:34:00

Is there a way to hide the Ogre render window? and does Ogre still use resources? Like the GPU and such. Or is it all to the "new" renderer?

At the moment you need Ogre installed and linked to your projects and NxOgre needs a copy. Same business as usual. Eventually though, you'll be able to compile NxOgre without Ogre even being on your machine; That will be in the 1.5 release, but for now Ogre all the way.

I must admit Caphalor summed up my thoughts pretty well. I'm side-lining parts of my coding while I wait for different things to be finished in NxOgre and I'm worried that my wait for these may be even longer now, it makes me consider dropping NxOgre (which I really don't want to do).
Having said all that, NxOgre is your baby betajaen and you are free to do whatever you want with it, I'll always appreciate the amount of work you have put into this for us all, thanks.


Well that is your choice, but the NxOgre your using right now (0.9), is pretty filled out and probably the best NxOgre there is at the moment.

However once I've finished a modest amount of the new RenderSystem stuff and finished of the ResourceSystem code (which gets triangle meshes working again), I'll release a copy of my code. Probably on a second SVN server, for people to catch up. Then after a little while everything will be merged again.

Does this mean you will be renaming the project? NxOgre sounds silly if you are using it in Irrlicht without any ogre in it at all.

Also since this has (in the past) always been an ogre project, would you be willing to provide the default renderSystem implementations for ogre?

I love the idea of being able to write directly to my network library (RakNet). I may be able to drop Ogre completely as a dependency for my server. That would be amazing!! I would be willing to write and share the renderSystem implementation for RakNet once this becomes available.

P.S. What font are you using in your IDE? I like it a bit more than mine(Lucida Console)


I have thought about toying the idea of "NxAny" but it sounds like everyone needs to get the inside joke first before actually laughing at it, then again I thought about calling it "Cheese". I'll stick with NxOgre for now.

Of course I'll be supplying the Ogre RenderSystem code. However if you don't like it, or have a specific implementation you want done then you can write your own.

Irrlicht was just a quick example that I pulled up in 30 minutes, I wanted do it in OpenGL but Da Cracker said it would be more dramatic if I went with the competitor. ;)

Not only you will be able to write to a network library, but theoretically with the new "SceneSource" class concept I came up, you'll be able to get something back. I intended it so you could share things with scenes; mixing hardware and software things together, but then I thought you could open it up even more.

The colours I used; I posted a copy here -> http://www.ogre3d.org/phpBB2addons/view ... 1263#31263

And the font I use is called Inconsolata, I use it because I love the anti-aliasing effect it gives out, reminds me of TextMate.

twilight17

30-11-2007 23:03:18


The colours I used; I posted a copy here -> http://www.ogre3d.org/phpBB2addons/view ... 1263#31263

And the font I use is called Inconsolata, I use it because I love the anti-aliasing effect it gives out, reminds me of TextMate.

THANKS! those colors and that font are awesome :D :shock:

alienskull

01-12-2007 01:21:54

ha.. cheese.. i get it now.. only took me a day to get it... need more sleep


cheese[cake]

dbrock

01-12-2007 07:49:06

I like your visual studio text colors! care to share? P.S. great work on Cake2 so far, I support your choice for Irrlicht

alienskull

01-12-2007 11:48:38

@dbrock -- open your eyes man, a link to the exported colors has been posted in this very thread at least twice already.

well lets hope third time is a charm here is a direct link http://www.betajaen.com/monokai.vssettings

dbrock

01-12-2007 21:46:25

@dbrock -- open your eyes man, a link to the exported colors has been posted in this very thread at least twice already.

well lets hope third time is a charm here is a direct link http://www.betajaen.com/monokai.vssettings


Appreciate it!

DieHard

03-12-2007 19:47:07


Anyway. With these new wonderful wrapped classes to handle the render specific things, what happens to Ogre? Well by the time NxOgre 1.5 is around, I wish to be able to compile NxOgre without a single reference to a Ogre header file or library, not have it in the linker settings. But replace it with a DLL; just like DirectX and OpenGL RenderSystems are with Ogre. Just think you could have NxOgre working with Gamebyro, or a little closer to home with NeoAxis.


But, the Ageia PhysX itself has DLL's and it is interoperability to all engines (and commercial engines too). The hardest part is integrating into the engine and then reinventing the wheel (basics), thus all of this taken care by the NxOgre wrapper (aka framework). Which I greatly appreciate your contribution "betajaen" to the Ogre community: the ease of programming and rapid development. You're the best. :)

Same with another Physics wrapper with Ogre, or any wrapper really. You'd have to write wrapping code eventually. To me it seems to be a waste of development time when there is something already there for you. There's also lots of nice bits here and there, that extend PhysX or offer new features.

There are a lot of people using it, and they claim it's very easy to use and powerful, so I must be doing something right. Which I'm sure some of them will pop in here, and give their moneys worth ;)


I'm not sure if it's time consuming and difficult to make a universal wrapper to all engines. But, my point is the attention to any specialize features from Ogre will be lacking. One example, the popular "dotscene" (xml .scene, produced from exporters: Maya, 3ds Max, Blender) which was not part of the NxOgre wrapper, luckily I found sources from "OgreNewt" and "OgreODE". And the awesome help from you to program a class to read XML using TinyXML and create collision throughout the scene (level, map).

It's not really a great example, by the way. My developments are still is at intermediate stage. But, I hope you get the point.

betajaen

03-12-2007 20:08:38

You're the best.

I am aren't I? ;)

It's not really a great example, by the way. My developments are still is at intermediate stage. But, I hope you get the point.

Ogre will be considered the de facto Rendering System for NxOgre, any features such as dot scene which can be implemented with NxOgre/Ogre but not with NxOgre/Gamebyro will be implemented. Gamebyro will just have to be left out. It's a bad example though, as NxOgre has it's own serialisation library.

Instancing it a good example, which I really want to make a big deal of in the future. I imagine some of the commercial libraries have that down to an art, with Ogre it's still a little new and not completely universal yet. In NxOgre I wish to support it (especially with the Effects System I have planned), but the theory is the same across rendering systems, so I can abstract that theory a little put it into some code, and theoretically it should be the same between both Rendering Systems.

I can see what you getting at though, I really do; But Ogre comes first, and if something magical comes out for Ogre which hasn't or cannot be implemented in other rendering/games engines, well tough luck on them.

gugus

03-12-2007 20:22:50

I am aren't I? :wink: Indeed you are :D
I think it's a great idea to have NxOgre with other engine.

especially with the Effects System I have planned
What do you mean by Effects Syteme?Explosion?I am not sure of what it is but i am sure it will be great!

Ps:thanks again for this lib!(and for your answers to our questions!)

betajaen

03-12-2007 20:24:50

Fluids, ForceFields, Particles, Large Scale effects, etc.

It's explained in the UML diagram I posted.

http://www.nxogre.org/NxOgreUML1.jpg

gugus

03-12-2007 20:53:37

Wow,sweet!

luis

04-12-2007 09:17:10

Making NxOgre 'graphics engine insensitive' is a wise move! I second your decision ;)
I think it will force NxOgre to be more open, extensible and better designed.

Vectrex

04-12-2007 17:26:58

You know.. it must be an Amiga thing because my colours are almost the same and EVERYONE that's seen them hates them :) You used AMOS right? I think that editor must have soaked into our brains

betajaen

04-12-2007 17:33:19

Could be, but AMOS didn't add colour to the language in the IDE, it was always in Yellow or Blue-White text on a blue-green background.

The Default screen colour when you ran programs was that brown though.