View unanswered posts | View active topics It is currently Thu Oct 17, 2019 7:16 am



Reply to topic  [ 13 posts ]  Go to page 1, 2  Next
 primitive selection 
Author Message

Joined: Sun Jan 02, 2011 4:50 pm
Posts: 2
Post primitive selection
Dear Laumaya,

Thank you for the nice work you have done. When I go though your code. I was wondering how can I select primitives(triangle) and highlight the selection. I see in the GLC_Player you have already done a mesh patch selection, but what I need is to select in more detail. Also you said in the new features that "Add possibility to select primitives", I am a little confused about this issue. Can you show me some information? Thank you in advance. Of course, any information from anyone is highly appreciated!


Sun Jan 02, 2011 4:58 pm
Profile
Site Admin

Joined: Sun Jan 03, 2010 4:27 pm
Posts: 390
Post Re: primitive selection
Hi,
mrlanqiu wrote:
Also you said in the new features that "Add possibility to select primitives", I am a little confused about this issue. Can you show me some information? Thank you in advance. Of course, any information from anyone is highly appreciated!

Yes, there is the possibility to select "primite" of a mesh, but this feature as not been designed to select :
    each Triangles
    Vertices
The feature is designed to select faces composed of several triangles, strip or fan.

Example from GLC_lib in GLC_Cylinder::createMeshAndWire() method, the line :
Code:
addTrianglesStrip(pCylinderMaterial, circumferenceStrips);

Call the base class method :
Code:
GLC_uint GLC_Mesh::addTrianglesStrip(GLC_Material*, const IndexList&, const int lod= 0, double accuracy= 0.0);

This method return an id which is the primitive id of the added triangle strip.
Ok, now we will see how to select the primitive of a geometry :
The declaration of the selection method of your application must look like this :
Code:
void select(QMouseEvent* pMouseEvent);

To get object id :
Code:
   GLC_State::setSelectionMode(true);
   int x= pMouseEvent->x();
   int y= pMouseEvent->y();
   setAutoBufferSwap(false);
   GLC_uint selectionID= m_GlView.renderAndSelect(x, y);


   GLC_uint elementID=0;
   int bodyID=0;
   GLC_3DViewInstance* pInstance= NULL;

   if (m_World->collection()->contains(selectionID))
   {
      pInstance= m_World->collection()->instanceHandle(selectionID);
      // Render the selected instance
      QPair<int, GLC_uint> bodyPrimitive= m_GlView.selectPrimitive(pInstance, x, y);
      bodyId = bodyPrimitive.first;
      elementID = bodyPrimitive.second;
   }

To view the primitive selected you must use the class : GLC_RenderProperties of the class GLC_3DViewInstance
Code:
pInstance->renderPropertiesHandle()->clearSelectedPrimitives();
pInstance->renderPropertiesHandle()->addSelectedPrimitive(bodyId, elementID);
pInstance->renderPropertiesHandle()->setRenderingMode(glc::PrimitiveSelected);

Finally in the next render you will see the primitive selected.

@+


Mon Jan 03, 2011 7:56 pm
Profile

Joined: Sun Jan 02, 2011 4:50 pm
Posts: 2
Post Re: primitive selection
Dear Laumaya,

Nice information. I can see what we can do now. Thank you very much!


Tue Jan 04, 2011 7:00 pm
Profile

Joined: Thu Oct 28, 2010 10:55 pm
Posts: 17
Post Re: primitive selection
Is it possible to select each line/cirlce/polyline if these geometries are imported or created into world? Thanks.


Tue Jan 18, 2011 6:40 pm
Profile
Site Admin

Joined: Sun Jan 03, 2010 4:27 pm
Posts: 390
Post Re: primitive selection
Hi,
I'm not sure to understand your question.
jeffer wrote:
Is it possible to select each line/cirlce/polyline if these geometries are imported or created into world? Thanks.

What do you mean by line/circle/polyline ?
GLC_Line/GLC_Circle/GLC_Polyline or line/cirlce/poly-line into mesh ?

An what do you want do do ?
Select all the line/circle/poly-line into a world or select them in interactive mode with the mouse?

@+


Tue Jan 18, 2011 10:12 pm
Profile

Joined: Thu Oct 28, 2010 10:55 pm
Posts: 17
Post Re: primitive selection
Sorry that I did not explain the question clearly. I mean to select/pick each GLC_Line, or GLC_CIRCLE or GLC_Polyline in interactive mode with the mouse.


Tue Jan 18, 2011 10:41 pm
Profile
Site Admin

Joined: Sun Jan 03, 2010 4:27 pm
Posts: 390
Post Re: primitive selection
If I understand,
When you select in interactive mode with the mouse, you just want select/pick : GLC_Line, or GLC_CIRCLE or GLC_Polyline and nothing else ?

@+


Wed Jan 19, 2011 2:02 am
Profile

Joined: Thu Oct 28, 2010 10:55 pm
Posts: 17
Post Re: primitive selection
Yes, select each individual GLC_Line,GLC_Circle or GLC_Polyline in interactive mode with the mouse.


Wed Jan 19, 2011 5:07 am
Profile
Site Admin

Joined: Sun Jan 03, 2010 4:27 pm
Posts: 390
Post Re: primitive selection
Ok,
To do this kind of thing, you have to use 2 GLC_3DViewCollection. One for the geometries you want to select and another for the geometries you don't want to select.
@+


Wed Jan 19, 2011 11:07 am
Profile

Joined: Thu Oct 28, 2010 10:55 pm
Posts: 17
Post Re: primitive selection
Sorry it seems that we still have mis-undertanding, I tried to create lines into world like below

for(i=0;i< size;i++)
{
....
GLC_Line *pLine = new GLC_Line(gp1,gp2);
GLC_3DRep* pRep= new GLC_3DRep(pLine);
pLine = NULL;
m_pWorld->rootOccurence()->addChild(new GLC_StructOccurence(pRep));
}

When I pick/select the line created above, sometimes it give the correct selectionID using the OpenglView::select() in GLC_player, sometimes the selectionID is not correct. Could you please give some details how to use GLC_3DViewCollection for the geometries I want to select? Thanks.


Wed Jan 19, 2011 7:25 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 13 posts ]  Go to page 1, 2  Next

Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.