Announcement

Collapse
No announcement yet.

how SoVertexProperty use "connectFrom'

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • how SoVertexProperty use "connectFrom'

    Hi,

    I use OpenInventor on Qt. Now I rcreate a line customly. In the line class, the scene of it includes: firstPoint( it is a SoTranslate2Dragger), secondPoint (it also a SoTranslate2Dragger), lineSet(it is a SoLineSet). I want to achieve this function: when move the "firstPoint", One end of the lineSet follows the firstPoint, another end of the lineSet follows the secondPoint. So I want to ues "connectFrom". But I don't know how the "SoVertexProperty" connectFrom "SoTranslate2Dragger->translation".

  • #2
    Hi,
    This is actually quite easy to do!

    The solution is to use an SoConcatenate engine to combine the Vec3f values from the two draggers into an MFVec3f value that can be connected to the LineSet's VertexProperty.
    In other words, the dragger positions (translation fields) are connected to the Concatenate engine and the engine is connected to the VertexProperty's vertex field.

    The C++ code to do that is shown below (.NET and Java code would be similar).
    I also attached a small test program: Test_DraggerToLine.zip
    Regards,
    Mike
    Code:
    // Line geometry
    // We do not need to initialize the VertexProperty node because the coordinates will be filled automatically from dragger positions.
    SoLineSet* lineSet = new SoLineSet();
      lineSet->vertexProperty = new SoVertexProperty();
    
    // Connect the dragger positions to the line geometry.
    // We need to concatenate two Vec3f values to make an MFVec3f value.
    SoConcatenate* concatEngine = new SoConcatenate( SoMFVec3f::getClassTypeId() );
      concatEngine->input[0]->connectFrom( &dragger1->translation );
      concatEngine->input[1]->connectFrom( &dragger2->translation );
    SoVertexProperty* lineProp = (SoVertexProperty*)lineSet->vertexProperty.getValue();
      lineProp->vertex.connectFrom( concatEngine->output );
    Attached Files

    Comment


    • #3
      Hi, Thanks a lot! I have understander. I want to see your example , but I can't download the attached file. Please send to my address: hnayhxlzz@163.com

      Comment


      • #4
        Originally posted by OIV_Ting View Post
        Hi, Thanks a lot! I have understander. I want to see your example , but I can't download the attached file. Please send to my address: hnayhxlzz@163.com
        Done.
        -Mike

        Comment

        Working...
        X