Scenegraph/ro: Difference between revisions

From FreeCAD Documentation
No edit summary
No edit summary
Line 40: Line 40:
}}
}}


După cum puteți vedea, structura este foarte simplă. Utilizați separatoare pentru a vă organiza datele în blocuri, un pic asemănător cu modul cum ați organiza fișierele în foldere. Fiecare afirmație afectează ce urmează, de exemplu primele două elemente ale separatorului rădăcină sunt o rotație și o translație, ambele afectează următorul element, care este un separator. În acest separator se definește un material și o altă transformare. Cilindrul nostru va fi astfel afectat de ambele transformări, cel care a fost aplicat direct la acesta și cel aplicat separatorului părinte.
As you can see, the structure is very simple. You use separators to organize your data into blocks, a bit like you would organize your files into folders. Each statement affects what comes next, for example the first two items of our root separator are a rotation and a translation, both will affect the next item, which is a separator. In that separator, a material is defined, and another transformation. Our cylinder will therefore be affected by both transformations, the one who was applied directly to it and the one that was applied to its parent separator.


We also have many other types of elements to organize our scene, such as groups, switches or annotations. We can define very complex materials for our objects, with color, textures, shading modes and transparency. We can also define lights, cameras, and even movement. It is even possible to embed pieces of scripting in openInventor files, to define more complex behaviours.
We also have many other types of elements to organize our scene, such as groups, switches or annotations. We can define very complex materials for our objects, with color, textures, shading modes and transparency. We can also define lights, cameras, and even movement. It is even possible to embed pieces of scripting in openInventor files, to define more complex behaviours.

Revision as of 16:02, 16 August 2018

FreeCAD este în esență un colaj de diferite biblioteci puternice, cea mai importantă fiind openCascade, for managing and constructing geometry, Coin3d to display that geometry, and Qt to put all this in a nice Graphical User Interface.

Geometria care apare în vizualizările 3D ale FreeCAD este redată de biblioteca Coin3D. Coin3D este o implementare satandard a OpenInventor.Software-ul openCascade oferă, de asemenea, aceeași funcționalitate, dar s-a hotărât, încă de la începuturile FreeCAD, să nu se folosească de vizualizatorul openCascade încorporat ci mai degrabă să se treacă la software-ul coin3D mai performant. O modalitate bună de a învăța despre această bibliotecă este cartea Open Inventor Mentor.

OpenInventor este de fapt un limbaj de descriere a scenei 3D. Scena descrisă în openInventor este apoi redată în OpenGL pe ecran. Coin3D are grijă să facă acest lucru, astfel încât programatorul nu are nevoie să se ocupe de apelurile complexe openGL, ci doar să-l furnizeze cu un cod OpenInventor valabil. Marele avantaj este că OpenInventor este un standard foarte bine cunoscut și bine documentat.

Una din marile servicii pe care FreeCAD le face pentru dvs. este de a traduce în mod deschis informația geometriei OpenCascade în limbajul openInventor.

OpenInventor descrie o scenă 3D sub formă de ascenegraph, like the one below:

image from Inventor mentor

Un scenograf openInventor descrie tot ce face parte dintr-o scenă 3D, cum ar fi geometria, culorile, materialele, luminile etc., și organizează toate datele într-o structură convenabilă și clară. Totul poate fi grupat în sub-structuri, permițându-vă să vă organizați conținutul scenei cât de mult vă place. Iată un exemplu de fișier openInventor:

#Inventor V2.0 ascii
 
Separator { 
    RotationXYZ {	
       axis Z
       angle 0
    }
    Transform {
       translation 0 0 0.5
    }
    Separator {	
       Material {
          diffuseColor 0.05 0.05 0.05
       }
       Transform {
          rotation 1 0 0 1.5708
          scaleFactor 0.2 0.5 0.2
       }
       Cylinder {
       }
    }
}

După cum puteți vedea, structura este foarte simplă. Utilizați separatoare pentru a vă organiza datele în blocuri, un pic asemănător cu modul cum ați organiza fișierele în foldere. Fiecare afirmație afectează ce urmează, de exemplu primele două elemente ale separatorului rădăcină sunt o rotație și o translație, ambele afectează următorul element, care este un separator. În acest separator se definește un material și o altă transformare. Cilindrul nostru va fi astfel afectat de ambele transformări, cel care a fost aplicat direct la acesta și cel aplicat separatorului părinte.

We also have many other types of elements to organize our scene, such as groups, switches or annotations. We can define very complex materials for our objects, with color, textures, shading modes and transparency. We can also define lights, cameras, and even movement. It is even possible to embed pieces of scripting in openInventor files, to define more complex behaviours.

If you are interested in learning more about openInventor, head directly to its most famous reference, the Inventor mentor.

In FreeCAD, normally, we don't need to interact directly with the openInventor scenegraph. Every object in a FreeCAD document, being a mesh, a part shape or anything else, gets automatically converted to openInventor code and inserted in the main scenegraph that you see in a 3D view. That scenegraph gets updated continuously when you do modifications, add or remove objects to the document. In fact, every object (in App space) has a view provider (a corresponding object in Gui space), responsible for issuing openInventor code.

But there are many advantages to be able to access the scenegraph directly. For example, we can temporarily change the appearence of an object, or we can add objects to the scene that have no real existence in the FreeCAD document, such as construction geometry, helpers, graphical hints or tools such as manipulators or on-screen information.

FreeCAD itself features several tools to see or modify openInventor code. For example, the following python code will show the openInventor representation of a selected object:

obj = FreeCAD.ActiveDocument.ActiveObject
viewprovider = obj.ViewObject
print viewprovider.toString()

But we also have a python module that allows complete access to anything managed by Coin3D, such as our FreeCAD scenegraph. So, read on to Pivy.

Mesh to Part/ro
Pivy/ro