Page 2 of 8

Posted: Sat Dec 06, 2008 4:49 pm
by nikki
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?

Posted: Sat Dec 06, 2008 5:07 pm
by Nauk
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

Posted: Sat Dec 06, 2008 6:29 pm
by nikki
Hmm... I tried that just now, it still gives me an (x,0,z) vector.

Posted: Sat Dec 06, 2008 7:12 pm
by Nauk
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.

Posted: Sat Dec 06, 2008 9:55 pm
by nikki
Its ok now, I got it to work somehow. :roll:

Posted: Sat Dec 06, 2008 10:02 pm
by Nauk
Good news :D

Posted: Fri Dec 12, 2008 11:18 am
by Beauty
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

Posted: Fri Dec 12, 2008 2:28 pm
by Nauk
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.

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

Posted: Wed Jan 14, 2009 1:48 pm
by xabila
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.

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

Posted: Fri Jan 16, 2009 1:42 pm
by Nauk
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.

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

Posted: Fri Jan 16, 2009 2:16 pm
by xabila
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...

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

Posted: Fri Jan 16, 2009 2:24 pm
by Nauk
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/

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

Posted: Sun Jan 18, 2009 12:42 pm
by xadhoom
Do you plan a non-Beta release soon?

Thanks, xad

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

Posted: Mon Jan 19, 2009 10:13 am
by xabila
SO actually, the getTSMHeight always retun 0 on my scene :(

Do we need to set a QueryFlag on the terrain?
Thanks

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

Posted: Mon Jan 19, 2009 1:48 pm
by Nauk
@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.

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

Posted: Mon Jan 19, 2009 1:50 pm
by xabila
Yes i allready did that, so why not try whith your test app...
Thanks.

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

Posted: Wed Jan 21, 2009 7:46 am
by mickeyren
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?

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

Posted: Wed Jan 21, 2009 10:17 am
by Nauk
No clue tbh, but it will be interesting to find out :)

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

Posted: Wed Jan 21, 2009 5:31 pm
by Beauty
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).

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

Posted: Wed Jan 28, 2009 3:20 pm
by VileMK3
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?

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

Posted: Wed Jan 28, 2009 5:08 pm
by Nauk
There is a demo application, you can find the link just at the beginning of the post here, that should make it clear. :)

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

Posted: Wed Jan 28, 2009 5:19 pm
by VileMK3
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?

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

Posted: Wed Jan 28, 2009 8:35 pm
by Nauk
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 :) )

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

Posted: Wed Jan 28, 2009 9:14 pm
by VileMK3
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);
	}

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

Posted: Wed Jan 28, 2009 9:50 pm
by Nauk
Ok, it should work out of the box like this - going to have a look, anyway.