MOC - Minimal Ogre Collision 1.0 - [Update 03.May.2009]

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!

Postby nikki » Sat Dec 06, 2008 4:49 pm

I have an Entity as a 'ground' mesh, and a little player object in my demo. I'm trying to make the player stick to the ground using calculateY, by doing this every frame (I don't use TSM or ETM):-
Code: Select all
collisionMgr->calculateY(mNode, false, true, 2);

But, it always gives me a vector with y=0. Did I miss something?
User avatar
nikki
Old One
 
Posts: 2730
Kudos: 13
Joined: 17 Sep 2005
Location: Princeton, New Jersey, USA

Postby Nauk » Sat Dec 06, 2008 5:07 pm

If you just want to check against another ground-mesh without TSM or ETM, you would have to set a querymask for that mesh and then pass the querymask as last parameter. The groundmesh you check against, shouldn't be static-geometry because that is not supported (yet).

Code: Select all
collisionMgr->calculateY(mNode, false, true, 2, WHATEVER_GROUND_MASK);


Hope that helped :)

/Nauk
User avatar
Nauk
Gnoll
 
Posts: 647
Kudos: 25
Joined: 11 May 2006
Location: Bavaria

Postby nikki » Sat Dec 06, 2008 6:29 pm

Hmm... I tried that just now, it still gives me an (x,0,z) vector.
User avatar
nikki
Old One
 
Posts: 2730
Kudos: 13
Joined: 17 Sep 2005
Location: Princeton, New Jersey, USA

Postby Nauk » Sat Dec 06, 2008 7:12 pm

I just checked it again, using the MOC Demo:
http://downloads.sourceforge.net/moc-co ... g_mirror=0

I commented out the terrain loading in the ArtifexLoader.cpp line 57 to 63:
Code: Select all
   /*
   initETM();      
   
   createColourLayer();   
   setupTextures();
   loadTerrain(mZoneName);
   */


Then in the SampleApp.cpp I placed the mCamNode manually to be certainly above the waterplane for testing now, SampleApp.cpp line 79:
Code: Select all
   mCamNode->setPosition(mCamNode->getPosition().x,10000,mCamNode->getPosition().z);
   // place the camera node on the ground
   //mCollisionTools->calculateY(mCamNode);


And then I changed the calculateY in line 114 to ...
Code: Select all
         mCollisionTools->calculateY(mCamNode,false,true,2.0f,WATER_MASK | ENTITY_MASK);
...so it does check against whatever objects and the waterplane as collision object and it works just fine as intended.

Maybe you can try that too and see if you can get it to work with the demo just like I did it now. That could shed some light why your code is not working. Otherwise I can't say much more without seeing your code.

Edit: Oh and have you tried debugging into the calculateY? Should be easiest to find out why you dont get a response to the check.
User avatar
Nauk
Gnoll
 
Posts: 647
Kudos: 25
Joined: 11 May 2006
Location: Bavaria

Postby nikki » Sat Dec 06, 2008 9:55 pm

Its ok now, I got it to work somehow. :roll:
User avatar
nikki
Old One
 
Posts: 2730
Kudos: 13
Joined: 17 Sep 2005
Location: Princeton, New Jersey, USA


Postby Beauty » Fri Dec 12, 2008 11:18 am

This looks interesting :)

Now there even is a port for Mogre: www.ogre3d.org/phpBB2addons/viewtopic.php?t=8615

Also I created a stub in the wiki.
Now I have less time. Later I can fill it with information.
Or somebody else does it ...

www.ogre3d.org/wiki/index.php/Minimal_Ogre_Collision
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
 
Posts: 767
Kudos: 40
Joined: 10 Oct 2007
Location: Germany

Postby Nauk » Fri Dec 12, 2008 2:28 pm

Now that is nice to hear :) muchas gracias for the info and the wiki entry. I'll try to fill it when I find the time, hopefully soon.
User avatar
Nauk
Gnoll
 
Posts: 647
Kudos: 25
Joined: 11 May 2006
Location: Bavaria

Re: MOC - Minimal Ogre Collision - Demo1.0 Beta [Demo+Src+Video]

Postby xabila » Wed Jan 14, 2009 1:48 pm

It's also working fine in linux.
But i have some problem, when i'm using the TSM.
Maybe it's because of the DotScene wich is loading my terrain, but it seems that the terrain mesh, is not at the right place.

The dotscene is moving the TerrainNode at a position indicated by the xml file.
Do you think it can be a problem?

And after currently to get the right elavation according the terrain, i have to compute it like that

Code: Select all

float HeightComputation::getHeight ( float x, float z)
{
  if (_isTerrain && !_init)
  {
    _terrainNode = _sceneMgr->getSceneNode("Terrain");
    _centerPosition = getWorldCenterPosition();
    _relativePosition = getRelativeCenterPosition();
    _init = true;
  }

  float resultat;
  if ( !_isTerrain)
    resultat = _defaultHeight;
  else
  {
    Ogre::Vector3 shiftPosition (_relativePosition - _centerPosition);
    Ogre::TerrainRenderable * pTerrainPage = ((Ogre::TerrainSceneManager *)_sceneMgr)->getTerrainTile(Ogre::Vector3(x +shiftPosition[0], shiftPosition[1], z +shiftPosition[2]));
    if (pTerrainPage != 0)
    {
      resultat = pTerrainPage->getHeightAt( x +shiftPosition[0], z +shiftPosition[2]) + _defaultHeight - shiftPosition[1];
    }
    // Si on est en dehors de la map
    else
    {
      OMERROR ( "Can't find terrainTile");
      resultat = _defaultHeight;
    }
  }
    return resultat;
}
Ogre::Vector3 HeightComputation::getRelativeCenterPosition() const
{
  assert ( _isTerrain);
  Ogre::Vector3 mapSize (((Ogre::TerrainSceneManager *)_sceneMgr)->getScale() * (((Ogre::TerrainSceneManager *)_sceneMgr)->getPageSize()-1) / 2);

  return Ogre::Vector3(mapSize.x, (((Ogre::TerrainSceneManager *)_sceneMgr)->getHeightAt(mapSize.x, mapSize.z)), mapSize.z);
}

//------------------------------------------------------------
Ogre::Vector3 HeightComputation::getWorldCenterPosition() const
{
  assert ( _isTerrain);
  Ogre::Vector3 nodePosition = _terrainNode->getPosition();
  Ogre::Vector3 mapSize (((Ogre::TerrainSceneManager *)_sceneMgr)->getScale() * (((Ogre::TerrainSceneManager *)_sceneMgr)->getPageSize()-1) / 2);

  return Ogre::Vector3(nodePosition.x + mapSize.x, nodePosition.y + (((Ogre::TerrainSceneManager *)_sceneMgr)->getHeightAt(mapSize.x, mapSize.z)), nodePosition.z + mapSize.z);
}


I guess what you have done should be the same, but maybe i'm wrong.
User avatar
xabila
Goblin
 
Posts: 225
Kudos: 0
Joined: 05 Jun 2006
Location: rennes [FR]

Re: MOC - Minimal Ogre Collision - Demo1.0 Beta [Demo+Src+Video]

Postby Nauk » Fri Jan 16, 2009 1:42 pm

Thanks Xabila, I am happy you like it :) About your problem, the Terrain Position shouldn't be a problem because the Height function is a simple Rayquery for a worldfragment intersection against it, but maybe I don't understand your question properly.
User avatar
Nauk
Gnoll
 
Posts: 647
Kudos: 25
Joined: 11 May 2006
Location: Bavaria

Re: MOC - Minimal Ogre Collision - Demo1.0 Beta [Demo+Src+Video]

Postby xabila » Fri Jan 16, 2009 2:16 pm

Well, I need first to make some debug stuff, to see if the elevation match my scene.
But actually what is make me crasy is that i've got some infinite loop on the intersectSegment or on TerrainRenderable::getHeightAt
So something seems wrong on the MOC::CollisionTools:raycast but i don't know why...
User avatar
xabila
Goblin
 
Posts: 225
Kudos: 0
Joined: 05 Jun 2006
Location: rennes [FR]

Re: MOC - Minimal Ogre Collision - Demo1.0 Beta [Demo+Src+Video]

Postby Nauk » Fri Jan 16, 2009 2:24 pm

Weird, we basically used nothing else there than in the Ogre TSM demo.

Oh while I am at it, MOC moved from sourceforge to google-code:
http://code.google.com/p/minimal-ogre-c ... n-toolkit/
User avatar
Nauk
Gnoll
 
Posts: 647
Kudos: 25
Joined: 11 May 2006
Location: Bavaria

Re: MOC - Minimal Ogre Collision - Demo1.0 Beta [Demo+Src+Video]

Postby xadhoom » Sun Jan 18, 2009 12:42 pm

Do you plan a non-Beta release soon?

Thanks, xad
User avatar
xadhoom
Minaton
 
Posts: 973
Kudos: 2
Joined: 28 Dec 2007
Location: Germany

Re: MOC - Minimal Ogre Collision - Demo1.0 Beta [Demo+Src+Video]

Postby xabila » Mon Jan 19, 2009 10:13 am

SO actually, the getTSMHeight always retun 0 on my scene :(

Do we need to set a QueryFlag on the terrain?
Thanks
User avatar
xabila
Goblin
 
Posts: 225
Kudos: 0
Joined: 05 Jun 2006
Location: rennes [FR]

Re: MOC - Minimal Ogre Collision - Demo1.0 Beta [Demo+Src+Video]

Postby Nauk » Mon Jan 19, 2009 1:48 pm

@Xadhoom: Once the next Artifex is out the door MOC will get more attention again.

@Xabila: I just looked at my TSM test-app again just to be sure, it is supposed to work out of the box. But you have to comment out the
Code: Select all
#define ETM_TERRAIN
in the header if you work with standard TSM, and use the constructor without terrainInfo. If that doesn't work I can send you my TSM test-app code.
User avatar
Nauk
Gnoll
 
Posts: 647
Kudos: 25
Joined: 11 May 2006
Location: Bavaria

Re: MOC - Minimal Ogre Collision - Demo1.0 Beta [Demo+Src+Video]

Postby xabila » Mon Jan 19, 2009 1:50 pm

Yes i allready did that, so why not try whith your test app...
Thanks.
User avatar
xabila
Goblin
 
Posts: 225
Kudos: 0
Joined: 05 Jun 2006
Location: rennes [FR]

Re: MOC - Minimal Ogre Collision - Demo1.0 Beta [Demo+Src+Video]

Postby mickeyren » Wed Jan 21, 2009 7:46 am

Hi

Does this work on manual objects or just entity?

Since its based from the wiki entry - the wiki entry needs the mesh information from the entity - i don't think manual objects returns these information?
mickeyren
Greenskin
 
Posts: 142
Kudos: 0
Joined: 18 Dec 2008


Re: MOC - Minimal Ogre Collision - Demo1.0 Beta [Demo+Src+Video]

Postby Beauty » Wed Jan 21, 2009 5:31 pm

mickeyren wrote:i don't think manual objects returns these information?


You can create a mesh instance by ManualObject::convertToMesh().
The API description is here: http://www.ogre3d.org/docs/api/html/cla ... 7f02b07efe
Maybe this helps (as alternatively way).
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
 
Posts: 767
Kudos: 40
Joined: 10 Oct 2007
Location: Germany

Re: MOC - Minimal Ogre Collision - Demo1.0 Beta [Demo+Src+Video]

Postby VileMK3 » Wed Jan 28, 2009 3:20 pm

I've taken a look at MOC and decided to use it for my small presentation but I'm having difficulties getting it implemented. Is there a small tutorial or other file with information on how to properly use the MOC?
User avatar
VileMK3
Halfling
 
Posts: 70
Kudos: 0
Joined: 28 Nov 2008
Location: Flanders, Belgium

Re: MOC - Minimal Ogre Collision - Demo1.0 Beta [Demo+Src+Video]

Postby Nauk » Wed Jan 28, 2009 5:08 pm

There is a demo application, you can find the link just at the beginning of the post here, that should make it clear. :)
User avatar
Nauk
Gnoll
 
Posts: 647
Kudos: 25
Joined: 11 May 2006
Location: Bavaria

Re: MOC - Minimal Ogre Collision - Demo1.0 Beta [Demo+Src+Video]

Postby VileMK3 » Wed Jan 28, 2009 5:19 pm

I4ve looked at it and certain parts still remained unclear but I managed to figure it out myself. One last question though, whenever I let it check if there's collision with other entities I keep ending up in an infinite loop, I believe I've seen that questrion before, any idea why this occurs?
User avatar
VileMK3
Halfling
 
Posts: 70
Kudos: 0
Joined: 28 Nov 2008
Location: Flanders, Belgium

Re: MOC - Minimal Ogre Collision - Demo1.0 Beta [Demo+Src+Video]

Postby Nauk » Wed Jan 28, 2009 8:35 pm

I can't see an inifinite loop where you could possibly end up, which one is it? (maybe I am just sitting on my cable :) )
User avatar
Nauk
Gnoll
 
Posts: 647
Kudos: 25
Joined: 11 May 2006
Location: Bavaria

Re: MOC - Minimal Ogre Collision - Demo1.0 Beta [Demo+Src+Video]

Postby VileMK3 » Wed Jan 28, 2009 9:14 pm

lol, this is the code I use:

Code: Select all
   Vector3 oldpos = m_CameraNode->getPosition();

   // Translates the camera according to the translate vector
   m_CameraNode->translate(m_CameraYawNode->getOrientation() * m_CameraPitchNode->getOrientation() * m_Direction, Ogre::SceneNode::TS_LOCAL);

   m_pCollisionTool->calculateY(m_CameraNode,true,true,2.0f);//,ENTITY_MASK);
      
   // When I leave this part uncommented my program simply freezes, can't use Escape to exit either so that's why I think it's an infinite loop or something but I have no idea what's causing it. I also
                // commented the ENTITY_MASK because I don't have any masks right now, could that be it?
   if (m_pCollisionTool->collidesWithEntity(oldpos, m_CameraNode->getPosition(), 2.5f, -1.0f))//, ENTITY_MASK))
   {
      // undo move
      m_CameraNode->setPosition(oldpos);
   }
User avatar
VileMK3
Halfling
 
Posts: 70
Kudos: 0
Joined: 28 Nov 2008
Location: Flanders, Belgium


PreviousNext

Return to Showcase

Who is online

Users browsing this forum: No registered users and 1 guest