Fix object in the terrain, what's wrong??

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
angel80
Posts: 22
Joined: Mon Feb 07, 2005 1:37 pm
Location: Paris (France)

Fix object in the terrain, what's wrong??

Post by angel80 »

Hi everybody,

I have set up an function to set all my objects load in the irrlicht engine in the ground

Code: Select all



void ECSS_StaticObject::fixGround(void)
{
	
	f32 middleObject = (objectMeshNode->getTransformedBoundingBox().MaxEdge.Y) - (objectMeshNode->getTransformedBoundingBox().getCenter().Y);
	vector3df start = objectMeshNode->getPosition();
	vector3df end = start;
	cout << "Start  " << start.Y  << endl;
	end.Y=end.Y- 20000.0;
	cout << "End  " << end.Y  << endl;
	triangle3df triangle;
	line3d<f32> line(start, end);
	device->getSceneManager()->getSceneCollisionManager()->getCollisionPoint(line, terrainSelector, end, triangle);
	cout << "Collision at   " << end.Y << endl;
	f32 distance = (start.Y-end.Y);
	
	start.Y = start.Y - distance;
	cout << "Distance height" << start.Y << endl;
	objectMeshNode->setPosition(start);
	objectMeshNode->setDebugDataVisible(true); 
}

some object are well fixed but some other not. What's wrong in my code.
It's just doing a collision bettwen the object and the ground and set the position to the meshNode.
Is it becase setPosition is setting the relative position??? how to do because there aren't setAbsolutePosition function

Thank for help!!
.: Franck :.
Guest

Post by Guest »

Judging from your remark, apparently you set every object's position relative to the ground, whether or not it is attached to a parent object.

Question is: why? A child object (whether that is a gun in a player's hand, a turret on a tank, or whatever) is something you normally want to place relative to the parent object.
angel80
Posts: 22
Joined: Mon Feb 07, 2005 1:37 pm
Location: Paris (France)

Thank for your help

Post by angel80 »

Hi Guest,
I fixed all objects to the ground and everything is ok now. Thank a lot
.: Franck :.
kostas

Post by kostas »

Hi angel80,could you post your working code about the problem you had mentioned in this thread?
Thanks!!! :lol:
Post Reply