ManualObject bug in 1.8.1?

Problems building or running the engine, queries about how to use features etc.
mude
Halfling
Posts: 47
Joined: Tue Dec 21, 2010 1:46 pm

ManualObject bug in 1.8.1?

Post by mude »

I used manual objects in Ogre 1.7.? without any problem. When I ported the project to Byatis I saw that the manuaobjects I were using (3 lines for a gizmo) were not present and but the resto of the object in thqat classe were in their regular position and working fine.

Code: Select all

lineX = mSceneMgr->createManualObject("lineX");
	lineY = mSceneMgr->createManualObject("lineY");
	lineZ = mSceneMgr->createManualObject("lineZ");

	lineX->setCastShadows(false);
	lineY->setCastShadows(false);
	lineZ->setCastShadows(false);
	
	objX->setRenderQueueGroup(Ogre::RenderQueueGroupID::RENDER_QUEUE_OVERLAY);
	objY->setRenderQueueGroup(Ogre::RenderQueueGroupID::RENDER_QUEUE_OVERLAY);
	objZ->setRenderQueueGroup(Ogre::RenderQueueGroupID::RENDER_QUEUE_OVERLAY);
	lineX->setRenderQueueGroup(Ogre::RenderQueueGroupID::RENDER_QUEUE_OVERLAY);
	lineY->setRenderQueueGroup(Ogre::RenderQueueGroupID::RENDER_QUEUE_OVERLAY);
	lineZ->setRenderQueueGroup(Ogre::RenderQueueGroupID::RENDER_QUEUE_OVERLAY);
	
	gizmoNode = mSceneMgr->createSceneNode();
	gizmoNode->setPosition(0,0,0);
	nodeX = gizmoNode->createChildSceneNode();
	nodeY = gizmoNode->createChildSceneNode();
	nodeZ = gizmoNode->createChildSceneNode();
	
	nodeX->attachObject(lineX);
	nodeY->attachObject(lineY);
	nodeZ->attachObject(lineZ);

	nodeX->attachObject(objX);
	nodeY->attachObject(objY);
	nodeZ->attachObject(objZ);
	
	nodeX->setVisible(true);
	nodeY->setVisible(true);
	nodeZ->setVisible(true);


	initLineMaterial(0);
	initLineMaterial(1);
	initLineMaterial(2);

	lineX->setDynamic(true);
	lineX->setDebugDisplayEnabled(true);

	lineX->clear();
lineX->begin("linematx", Ogre::RenderOperation::OT_LINE_LIST);
lineX->colour(Ogre::ColourValue::Red);
lineX->position(gizmoNode->getPosition().x-translation/2,nodeX->getPosition().y,nodeX->getPosition().z); 
lineX->position(nodeX->getPosition()); 
lineX->end(); 

int n = lineX->getCurrentVertexCount();  
	n;
in this case n is 0 but is supposed to be two? what happened?I think to have followed the tutorial correctly.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 538

Re: ManualObject bug in 1.8.1?

Post by Kojack »

Code: Select all

lineX->colour(Ogre::ColourValue::Red);
lineX->position(gizmoNode->getPosition().x-translation/2,nodeX->getPosition().y,nodeX->getPosition().z); 
lineX->position(nodeX->getPosition()); 
Calling position starts a new vertex. It must always be the first element used. Calling colour first means it is trying to set colour before a vertex has been made.
(Order of all the other elements doesn't matter, but position must always be the first element of each vertex).

Try this:

Code: Select all

lineX->position(gizmoNode->getPosition().x-translation/2,nodeX->getPosition().y,nodeX->getPosition().z); 
lineX->colour(Ogre::ColourValue::Red);
lineX->position(nodeX->getPosition());
lineX->colour(Ogre::ColourValue::Red); 
(The second colour isn't technically needed, each vertex copies the values from the previous one if they are missing. I just prefer being explicit here)

linex is attached to nodex. But one of linex's vertices has been given nodex's position. The position of a manual object vertex is added to the node position, so if the node was at [100,0,0] then the vertex would end up at [200,0,0] (it's position plus the node's position).
If the node's are left at the origin then you'll never notice (0+0=0) but it's still wrong and will cause a problem if you move them later.


If you aren't doing anything different to each axis, you could just put all three lines in one manual object. Less code, less nodes, less manualobjects to render, but the same result.
mude
Halfling
Posts: 47
Joined: Tue Dec 21, 2010 1:46 pm

Re: ManualObject bug in 1.8.1?

Post by mude »

Kojack wrote:

Code: Select all

lineX->colour(Ogre::ColourValue::Red);
lineX->position(gizmoNode->getPosition().x-translation/2,nodeX->getPosition().y,nodeX->getPosition().z); 
lineX->position(nodeX->getPosition()); 
Calling position starts a new vertex. It must always be the first element used. Calling colour first means it is trying to set colour before a vertex has been made.
(Order of all the other elements doesn't matter, but position must always be the first element of each vertex).

Try this:

Code: Select all

lineX->position(gizmoNode->getPosition().x-translation/2,nodeX->getPosition().y,nodeX->getPosition().z); 
lineX->colour(Ogre::ColourValue::Red);
lineX->position(nodeX->getPosition());
lineX->colour(Ogre::ColourValue::Red); 
(The second colour isn't technically needed, each vertex copies the values from the previous one if they are missing. I just prefer being explicit here)

linex is attached to nodex. But one of linex's vertices has been given nodex's position. The position of a manual object vertex is added to the node position, so if the node was at [100,0,0] then the vertex would end up at [200,0,0] (it's position plus the node's position).
If the node's are left at the origin then you'll never notice (0+0=0) but it's still wrong and will cause a problem if you move them later.


If you aren't doing anything different to each axis, you could just put all three lines in one manual object. Less code, less nodes, less manualobjects to render, but the same result.

thanks, but it doesn't work, I can't see the lines. The translation is correct, I want the line to start from the gizmonode and goes towards one of the three cubes(nodeX etc.)

I don't know what to try, they were working but when I updated to 1.8.1 they disappeared :?
User avatar
Xavyiy
OGRE Expert User
OGRE Expert User
Posts: 847
Joined: Tue Apr 12, 2005 2:35 pm
Location: Albacete - Spain
x 87

Re: ManualObject bug in 1.8.1?

Post by Xavyiy »

4 months later. I think this is the solution to your problem: https://ogre3d.atlassian.net/browse/OGRE-150