Picking object after rotation

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
mgs_oleg
Gnoblar
Posts: 20
Joined: Fri Mar 30, 2018 8:24 pm
x 1

Picking object after rotation

Post by mgs_oleg » Sat Mar 31, 2018 8:35 pm

Hi All,

I've created necessary object and rotated it by 30 degree on each of the

Code: Select all

ogreNode->rotate(Ogre::Quaternion(Ogre::Degree(30), Ogre::Vector3(1, 1, 1)), Ogre::Node::TransformSpace::TS_WORLD);
Then my picking logic is

Code: Select all

MouseClicky(unsigned int absoluteX, unsigned int absoluteY) {
	
	
	float width = (float) this->cam->getViewport()->getActualWidth(); // viewport width
	float height = (float) this->cam->getViewport()->getActualHeight(); // viewport height

	Ray ray = this->cam->getCameraToViewportRay((float)absoluteX / width, (float)absoluteY / height);

	// Set up the ray query - you will probably not want to create this every time
	RaySceneQuery * rq = this->scnMgr->createRayQuery(ray);

	// Sort by distance, and say we're only interested in the first hit; also, only pick entities
	rq->setSortByDistance(true, 1);
	

	// Execute
	RaySceneQueryResult res = rq->execute();
	RaySceneQueryResult::iterator it = res.begin();

	// these two things should probably be encapsulated in their own class/struct

	if (it != res.end())
	{
		
		printf("clicked: %s\n",it->movable->getName().c_str());
	}
	else
	{
		printf("cleared selection.\n");
	}

	this->scnMgr->destroyQuery(rq);
}
This logic trigerred on each of the moseMove event using native Ogre mouse event. But issues that selection is much wider than rotated object. See screenshot (area of selection dotted by red line )
Image

Does anyone has any idea what is the issues ?
0 x

mgs_oleg
Gnoblar
Posts: 20
Joined: Fri Mar 30, 2018 8:24 pm
x 1

Re: Picking object after rotation

Post by mgs_oleg » Sat Mar 31, 2018 9:09 pm

May assume that issue is with Scene Manager.I am using default.
0 x


mgs_oleg
Gnoblar
Posts: 20
Joined: Fri Mar 30, 2018 8:24 pm
x 1

Re: Picking object after rotation

Post by mgs_oleg » Sun Apr 01, 2018 12:32 pm

Thanks.
do you have some expirience of picking object by means of bullet physics integrated into Ogre ?
maybe you know some other solution in ogre ?
0 x

Post Reply