[bleeding] Demo_nxogre-0.1 (beginners example)

luis

01-06-2008 16:06:07

Hello people,

I've been doing a very small app to easily test new NxOgre versions and fix those small bugs that some (most of the) times comes with new NxOgre versions...

This example was made to work with NxOgre 1.0-18 the version i'm using and the version I submited the jittering patch.
This example uses Ogre's media files and two .png images that will automatically copied during the postbuild step so you dont need to copy anything nor modify resources.cfg in Ogre directory.

Prerequisites:
- Ogre sources (not precompiled Ogre binaries).
- know basic Ogre setup and framelisteners logic
- know how to program in C++, build and fix any compiler error found because I'll not give any support with compiler errors! so don't come here crying because it isn't compiling. I'll give support only for missing files in this example.

What is in the example:
- setup world and nxogre scene using class params
- heightmap physics and heightmap graphics and how to correctly scale it.
- delete and create spheres boxes (dynamic and static)
- NxOgre manually stepping
- by using NxOgre 1.0-18 plus jittering patch you can see objects moving at FPS independent (all bodies are created with linear interpolation)

How to build it:
- Download the code
- unzip the file it will create a directory, something like this:
c:\src\Demo_nxogre\
- edit setenv.bat and replace all paths with your paths. Don't put any space between the VARNAME and '=' sign or it will not work.
- run Open_Solution.bat it will open the solution using the environment paths defined in setenv.bat
- build the solution and see the message in the output compiler, it will tell you the path where the binary was generated and copy the necessary files to your Ogre directory.

gugus

01-06-2008 16:13:13

Cool!Downloading.

Ps:maybe you(or I) could make it for 1'21?

betajaen

01-06-2008 16:33:25

Well done Luis! If you want; I can mirror this at NxOgre.org

luis

01-06-2008 16:47:16

I'm glad you like it!

Well done Luis! If you want; I can mirror this at NxOgre.org
I preffer to have it in my own server (you can link to this file if you want) in order to upload new versions my self...
Ps:maybe you(or I) could make it for 1'21?
You can do it, if you add #ifdefs to the code I can merge it and upload the new version. I'm not going to upgrade to 1.0-21 soon...

betajaen

01-06-2008 18:05:58

No problem. I can link to this thread at NxOgre.org with a list of other tutorials and examples.

emc

05-06-2008 15:49:53

hi there,

i made a few changes and now the demo works with NxOgre 1.0.21.
i am quite new to NxOgre, so if you find any mistakes please let me know..

Instructions
  1. Download the patch: http://www.lefkos.gr/Demo_nxogre_1.0.21_patch.zip
    Replace DemoFrameListener.cpp and Globals.cpp with the files in the archive.
    Copy the .xhf files in bin\Release
    Add the NX_OGRE_1_0_21 preprocessor definition (project properties/C/C++/Preprocessor)
    Compile and link using NxOgre 1.0.21[/list:u]

qsik

14-06-2008 04:16:00

i get an assertation error

emc

14-06-2008 10:38:44

can you be more specific?
did you check the ogre and nxogre log files ?

qsik

14-06-2008 16:02:16

nevermind, i figured it out with the logs.
thnx for ur help!

xadh00m

16-06-2008 09:10:39

nevermind, i figured it out with the logs.
thnx for ur help!


If it fits in this thread you should post your assertion and solution.
Maybe this would help others with an assertion...

luis

17-06-2008 08:37:00

xadh00m is right, would be good if you post the fix or the problem you had.

I've looking the path it looks right, thanks emc.
The only thing I think you forgot to comment is the VRD connection... perhaps that was the assert/error that qsik had

L5D

17-06-2008 19:13:39

I have an error after generation, I don't know where put the file with media images.
The executable run with the image in Ogre/media, but i have this error...

xadh00m

18-06-2008 11:15:56

What does the error says? An "error" is not that selfexplaining...

L5D

18-06-2008 12:39:03

Visual say it doesn't find the image's map, but when i execute the .exe placed in Ogre, the program run correctly.

Edit: erf, it run now, but i don't know why...

xadh00m

18-06-2008 16:24:50

Insert $(OutDir) as working directory in your project property/debugging.

Than the working directory is used for relatively find the media path...

Jerdak

18-06-2008 17:26:21

I've got a small question, are the objects supposed to react with the terrain in a realistic manner? When I run the demo the pink balls do roll on the terrain but when they come up to the small hills along the edge they simply roll right on through.

*Edit: I'm using the patched code. It seems the scaling has been removed. It's not clear to me how this would be added back in.

*Edit2: After playing around with the code and searching through the forums I discovered the post on the changes between 0.9 and Bleeding with regards to Terrain. The patched code posted in this thread still doesn't seem to work for me. What I'm having problems with is aligning the terrain in Ogre with the physics terrain. I looked at the RemoteDebugger output and things seem to be working just fine. My problem is that some of the balls roll a hair off the surface and some roll just under the surface(like at hills). I've been messing with MaxHeight but that doesn't seem to fix all of my problems.

*Edit3: Fixed my problem... well maybe. In Globals::_loadOgreTerrain() I changed:

//cfg += "PageWorldX=" + pageWorldX + "\n";
//cfg += "PageWorldZ=" + pageWorldX + "\n";
cfg += "PageWorldX=128\n";
cfg += "PageWorldZ=128\n";
//cfg += "MaxHeight=" + Ogre::StringConverter::toString( Globals::TERRAIN_MAXHEIGHT ) + "\n";
cfg += "MaxHeight=10.0\n";


And in Globals::_loadNxOgreTerrain() I changed the following:

/* NxOgre::Terrain* terrain = new NxOgre::Terrain(
hf,
NxOgre::float3(128,4,128),
sp,
"centering: xz-above, hole-material: 65535");

mTerrainCollision = mNxScene->createActor(Globals::TERRAIN_ACTOR_NAME, terrain,
Ogre::Vector3(64, 4, 64),
"static: yes");
*/
NxOgre::Terrain* terrain = new NxOgre::Terrain(
hf,
NxOgre::float3(128,4,128),
sp,
"centering: xz-above, hole-material: 65535");

mTerrainCollision = mNxScene->createActor(Globals::TERRAIN_ACTOR_NAME, terrain,
Ogre::Vector3(64, 1, 64),
"static: yes");


This seems to have fixed my problem. I'm not sure if I just kludged myself in to a temporary fix or if this really does mitigate the problem but it seems to work so far.

L5D

18-06-2008 20:47:08

I'd like link keys to move a sphere , but I don't know how to apply a force (I prefer it rather than change its position abruptly), and I don't know how to retrieve the body of the sphere.

Knowing that I try to do that since FrameListener my program with this code:
"If (mKeyboard-> isKeyDown (OIS: KC_W))
(
???
) "

xadh00m

19-06-2008 11:07:11

NxOgre 0.9 code:

if(mInUseMode)
{
Vector3 horizontalForceDirection = getCamera()->getDerivedRight()*mouseState.X.rel;
Vector3 verticalForceDirection = getCamera()->getDirection()*(-mouseState.Y.rel);
mCurrentReachableActor->addForceAtPos((horizontalForceDirection+verticalForceDirection).normalisedCopy() * 200, mRayCaster->getClosestRaycastHit().mWorldImpact);
}


This code adds a force at a position evaluated with a raycaster on a given
actor. This actor was also found with the raycaster in another method.
The force direction is calculated via camera position. The whole code is used
for opening doors and windows if the mouse is moved.

If you don´t want to use a raycaster you have to remind your actor somehow and
can add a force like above on a predefined position/direction.

emc

23-06-2008 12:23:12

Jerdak you are right,

the collision object for the terrain does not match the visual object.
something went wrong with the baking process, i 'll post a fix

George

aoos

07-07-2008 12:21:27

after i applied the patch and compile the code i get a project error at linking:

Demo_nxogre : error PRJ0007 : Could not create output directory 'D:\auxi\c\apis\ogre\ogre-win32-v1-4-7\ogrenew\Samples\Common\bin\Debug'.


What's wrong here?

aoos

07-07-2008 14:12:11

Ok,i changed the output directory so that my project can build but i get an error again:
Project : error PRJ0019: A tool returned an error code from "Performing Post-Build Event..."

althought i get the error the exe is builded but when i run it i get an Debug Assertion failed message!

http://img530.imageshack.us/img530/1722 ... leddm6.jpg

luis

08-07-2008 08:35:06

Demo_nxogre : error PRJ0007 : Could not create output directory 'D:\auxi\c\apis\ogre\ogre-win32-v1-4-7\ogrenew\Samples\Common\bin\Debug'.
That is the directory i have in my PC....
undo all your changes in this demo and please read again compiling instructions in the first post, you're not editing setenv.bat ;)

aoos

09-07-2008 23:16:40

Yes you are right i was very careless! but i still get the same error! after it gives the place to run my app it says that it cant find "..\media\Demo_nxogre_heightmap1.png"
Project : error PRJ0019: A tool returned an error code from "Performing Post-Build Event..."
the point is that i just placed a folder "media" with the jpeg image exactly a folder before the folder which contains my exe but it cant find it! :cry: :cry: :cry: what im doing wrong again?

ciderbarrel

10-07-2008 09:47:46

Using bleeding, has anyone else have this crash?

Unless BOXES_NBR and SPHERES_NBR are both set to 1 in void Globals::createAllObjects(), it will crash on startup and it will crash on exit unless I have the entire function commented out (no boxes nor spheres are spawned, just the terrain).

Something in createBox() or createSphere() is causing a runtime error for me. I haven't been able to figure it out yet.

luis

10-07-2008 10:54:00

@aoos
you're still with the patch applied, at least in the media folder...
- clean all your Demo_nxogre directory
- donwload the original demo
- follow all the steps "in how to compile"
- apply the patch given in this thread
- compile
- go to ogremain/samples/common/bin/release and run the demo right there

if it doesnt work read ogre.log and see what is going on....

@ciderbarrel

to both of you... sorry but i use 1.0-19 and my plan is to stay with that version for a while or even backport my code and my patchs to 0.9 :(

betajaen

10-07-2008 11:20:45

my plan is to stay with that version for a while or even backport my code and my patchs to 0.9 :(

Why? What's wrong now?

aoos

10-07-2008 13:31:24

:mrgreen: :mrgreen: :mrgreen: it runs fine now thanks!!!

luis

10-07-2008 14:58:33

i'm glad it works aoos!


Why? What's wrong now?


Well, i'm not really sure about those things in 1.0-21 (please correct me i'm wrong):
- You cannot load a .mesh file directly and use it as a convex mesh. I really need it since i'm allowing user created content in the game so the use of these assets has to be in one step.
- I will have to apply the jittering patch again because the current implementation isn't correct
- there is no support for metal cloth... ?

Those are my pre-concepts about 1.0-21 since I didnt try it I just read the post and change list....

betajaen

10-07-2008 15:08:00

1. You can borrow the code from Flour to convert a mesh into a NXS one, and convert within the game. You don't even need to save it to disk. It can be read from memory.

2. I'm pretty sure, I've implemented everything you told me to do with the jittering - including the patch.

3. Working on cloth right now.

luis

10-07-2008 15:33:32


1. You can borrow the code from Flour to convert a mesh into a NXS one, and convert within the game. You don't even need to save it to disk. It can be read from memory.

If it can be read from memory then it is ok, I just wonder if it works with submeshes...

2. I'm pretty sure, I've implemented everything you told me to do with the jittering - including the patch.

almost everything, remember i told you about the error... see my post here:
http://www.ogre3d.org/phpBB2addons/view ... 0344#40344

3. Working on cloth right now.

Great then!

If I upgrade to 1.0-21 i'll do it using this demo first and evaluate the cost.... i dont have many time to develop my own game so I dont want to re-apply patchs or implementing workarounds (like nsx/.mesh loader for convexes and releasing heightfields manually etc)....
In the other hand I hate to use hacked old versions of any lib..... and Physx 2.8 support plus metal cloth are good features.

betajaen

10-07-2008 16:04:38

1. Yep. Works with submeshes, it's based on the code from the wiki, and it's always worked in the past.

2. Everything you've said about the jittering. I've implemented into NxOgre, including the post you said.

A copy of them is here:
http://www.ogre3d.org/phpBB2addons/view ... 4398#44398

3. Indeed. I notice Mesh and Heightfield in '21 aren't release themselves after used and allow them be release by PhysX. This was a design decision back then, but now will release them on the destructor of Mesh and Heightfield; since there is tracking of resources.

luis

10-07-2008 16:36:48

oh I didn't see the thread about jittering... I hope it gets solved finally ;)

about point 1, I had to modify the code in 1.0-19 to make it work with submesh, as you said the code "was based" on the code from the wiki but it wasn't exactly the same, it had a bug....
http://www.ogre3d.org/phpBB2addons/view ... 1056#41056

If 1.0-21 uses exactly the same code (and i think you tested it with sub-meshes) then it should work ;)

betajaen

10-07-2008 16:44:26

Ahh. Well Flour may contain the sub-mesh bug. If it does, it's easy to fix.

mcaden

13-07-2008 12:19:12

Crashing...
This is the last entry in "Ogre.log":

19:03:44: TerrainSceneManager: Registered a new PageSource for type Heightmap


It doesn't tell me why it crashes. So far as I can tell it's breaking:


if (reading) {
fseek(mFile, 0, SEEK_END);
mSize = ftell(mFile); // << HERE
fseek(mFile, 0, SEEK_SET);
}


I'm using release so can I can't really step through it...debug for some reason won't run for me...that's another problem I'm trying to fix. I downloaded one of the SDKs and that's what I've been using. I'm gonna try downloading from SVN and building from source. one of the debug DLLs just doesn't like me.

I'm using the bleeding 1.0-21 with PhysX 2.8 and I'm compiling with that patch for 1.0-21 that was posted here earlier.

mcaden

15-07-2008 17:20:15

Ok, so I was misreading things and thought I had SP1 for VS 2005...turns out I didn't... Fixes the debug issue and I feel dumb.


Okay, getting down to trying to fix it...

The assertion was in the resource manager. It couldn't find the .xhf demo terrain files so it was giving an assertion... silly me, I forgot to copy them to the new ogre directory after changing from one of the prebuilt SDK to using pure source (this was right before I realized that I wasn't using SP1).

So I copy it to the media folder...and I still get the same assertion. Guess I have to put it in resources.cfg? But oh well, I copy it to the same dir as the exe and it gets past that assertion and I get an exception...grr..

Again, silly me, I forgot to copy the png terrain files (I thought that the .xhf files replaced them? )

So I put them in media and it runs past that exception to the newest one:

First-chance exception at 0x7d4e2366 in Demo_nxogre.exe: Microsoft C++ exception: OIS::Exception at memory location 0x0012f434..


...after looking at it, it's the try/catch block on the joystick in exampleframelistener...peachy, I continue...

Yay it runs!

I hit escape...and oh noes!

First-chance exception at 0x008b9f96 (NxOgre_d.dll) in Demo_nxogre.exe: 0xC0000005: Access violation reading location 0x06a38150.


Which happens here:


BETAJAEN_CC_INLINE void _delete_range(Iterator begin, Iterator end)
{
for (; begin != end; ++begin) {
BETAJAEN_CC_DELETE(*begin); ///<<< exception
}
}



So yay, I got it umm..."working", but I'm not familiar enough to figure out what the last error is off the top of my head, will take a little looking. I just wanted to say that the probs I was having in my last post are solved.






EDIT: I'm noticing I'm not having that last problem if I'm not attached to the debugger so I'm not sure what's going on, I don't see a try/catch block that could be fooling the debugger anywhere.

I'm also noticing after testing a bit more...some of the balls are going through the terrain, but not falling completely.

I'm also noticing that if I'm running the exe compiled in debug I'm getting 5-6 FPS vs 59-60 if I'm in release. I know there's a speed difference in debug/release compilation, but isn't that a bit ridiculous?

NOT NXOGRE RELATED: ALSO, I'm having a prob...I assumed with my video card where all the graphics moved in a very choppy or jumpy fashion. I haven't found a solution for this no matter how much I search, HOWEVER, I noticed that in the balls moved by physics it's incredibly smooth, BUT the camera is still choppy if I'm moving it. Does anybody know anything about this? In my code it does it. I have a char and if he's walking or even just breathing (whether the camera is moving or not), he moves very jerkily, but I know it's not just my code, because I'm having the same problem with every single one of the samples, debug or release, but it obviously doesn't affect the balls or blocks moving in the nxogre_demo, only the camera in that demo and it also doesn't exist if I run the CEGUI mesh viewer. I suppose this prob is best left for the general ogre help forums, but I've searched and searched and there's no solution posted, and no reply to my posts. It happens on D3dx or OpenGL, 30FPS or 600FPS, no matter the resolution or any of the other settings. Any help would be appreciated.

mcaden

17-07-2008 04:40:26

These forums don't seem very lively... :?

Any insight on the problems with the framerate? Balls falling through the terrain?

You think this would be a prob with nxogre or just with the demo?

luis

17-07-2008 08:35:43

I made this demo but since I'm not using 1.0-21 I can't give you any support.... sorry. 1.0-19 doesn't have any "resource manager"

leonardoaraujo.santos

29-07-2008 13:03:53

Hi Luis does the Demo_NxOgre run with NxOgre 10-21
If not ...
Do you know how I can get
NxOgre 1.0-18 (w/ jittering patch)

I´ve tried to get working with NxOgre 0.9 but no success (The objects does not appear)

mcaden

29-07-2008 13:09:01

I got it working with NxOgre 1.0'21, only a couple problems I mentioned in my previous post that I'm not sure what's going on.


I'm also noticing after testing a bit more...some of the balls are going through the terrain, but not falling completely.

I'm also noticing that if I'm running the exe compiled in debug I'm getting 5-6 FPS vs 59-60 if I'm in release. I know there's a speed difference in debug/release compilation, but isn't that a bit ridiculous?

luis

29-07-2008 13:10:43

this is very easy, with Tortoise SVN use the option: "Update to revision..." and choose revision 19.

Then download the patch (read my first post):
http://www.ogre3d.org/phpBB2addons/view ... ring+patch

again with Tortoise use: "Apply patch..." open the .patch file and apply it to your working copy and compile (using Physx 2.7).
good luck!