Raytracing API example/fr: Difference between revisions

From FreeCAD Documentation
(Created page with "La même chose pour Luxrender:")
(Updating to match new version of source page)
 
(4 intermediate revisions by 2 users not shown)
Line 32: Line 32:
}}
}}


== Créer un objet de rendu personnalisé ==
== Creating a custom render object ==
Apart from standard povray and luxrender view objects that provide a view of an existing Part object, and that can be inserted in povray and luxrender projects respectively, a third object exist, called RaySegment, that can be inserted either in povray or luxrender projects. That RaySegment object is not linked to any of the FreeCAD objects, and can contain custom povray or luxrender code, that you might wish to insert into your raytracing project. You can also use it, for example, to output your FreeCAD objects a certain way, if you are not happy with the standard way. You can create and use it like this from the python console:
Outre les objets de vue standard povray et luxrender qui fournissent une vue d'un objet Part existant et qui peuvent être insérés dans des projets povray et luxrender, il existe un troisième objet, appelé RaySegment, pouvant être inséré dans des projets povray ou luxrender. Cet objet RaySegment n'est lié à aucun des objets FreeCAD et peut contenir du code povray ou luxrender personnalisé que vous pourriez souhaiter insérer dans votre projet Raytracing. Vous pouvez également l'utiliser, par exemple, pour générer vos objets FreeCAD d'une certaine manière, si vous n'êtes pas satisfait de la manière standard. Vous pouvez le créer et l'utiliser comme ceci depuis la console python:


{{Code|code=
{{Code|code=
Line 42: Line 42:
}}
}}


{{Powerdocnavi{{#translation:}}}}
{{Raytracing Tools navi}}
[[Category:Developer Documentation{{#translation:}}]]
{{Userdocnavi}}
[[Category:API]]
[[Category:Python Code{{#translation:}}]]
{{Raytracing Tools navi{{#translation:}}}}
{{clear}}

Latest revision as of 21:08, 22 August 2020

Other languages:

Introduction

Les modules Raytracing et RaytracingGui fournissent plusieurs méthodes pour écrire le contenu d'une scène sous forme de données povray ou luxrender.

Les commandes les plus utiles sont Raytracing.getPartAsPovray () et Raytracing.getPartAsLux () pour restituer un objet Part FreeCAD dans une définition de type povray ou luxrender et RaytracingGui.povViewCamera () et RaytracinGui.luxViewCamera () pour obtenir le point de vue actuel de la fenêtre de vue 3D au format povray ou luxrender.

Sortie de fichiers de rendu

Voici comment écrire un fichier Povray à partir de python, en supposant que votre document contienne un objet "Box":

import Raytracing,RaytracingGui
OutFile = open('C:/Documents and Settings/jriegel/Desktop/test.pov','w')
OutFile.write(open(App.getResourceDir()+'Mod/Raytracing/Templates/ProjectStd.pov').read())
OutFile.write(RaytracingGui.povViewCamera())
OutFile.write(Raytracing.getPartAsPovray('Box',App.activeDocument().Box.Shape,0.800000,0.800000,0.800000))
OutFile.close()
del OutFile

La même chose pour Luxrender:

import Raytracing,RaytracingGui
OutFile = open('C:/Documents and Settings/jriegel/Desktop/test.lxs','w')
OutFile.write(open(App.getResourceDir()+'Mod/Raytracing/Templates/LuxClassic.lxs').read())
OutFile.write(RaytracingGui.luxViewCamera())
OutFile.write(Raytracing.getPartAsLux('Box',App.activeDocument().Box.Shape,0.800000,0.800000,0.800000))
OutFile.close()
del OutFile

Créer un objet de rendu personnalisé

Outre les objets de vue standard povray et luxrender qui fournissent une vue d'un objet Part existant et qui peuvent être insérés dans des projets povray et luxrender, il existe un troisième objet, appelé RaySegment, pouvant être inséré dans des projets povray ou luxrender. Cet objet RaySegment n'est lié à aucun des objets FreeCAD et peut contenir du code povray ou luxrender personnalisé que vous pourriez souhaiter insérer dans votre projet Raytracing. Vous pouvez également l'utiliser, par exemple, pour générer vos objets FreeCAD d'une certaine manière, si vous n'êtes pas satisfait de la manière standard. Vous pouvez le créer et l'utiliser comme ceci depuis la console python:

myRaytracingProject = FreeCAD.ActiveDocument.PovProject
myCustomRenderObject = FreeCAD.ActiveDocument.addObject("Raytracing::RaySegment","myRenderObject")
myRaytracingProject.addObject(myCustomRenderObject)
myCustomRenderObject.Result = "// Hello from python!"