Skip to content

Commit

Permalink
Arch: Turned jreinhardt's fix to webGL into an option
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed May 2, 2014
1 parent 07f3f82 commit 90f2fc2
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/Mod/Arch/Arch_rc.py

Large diffs are not rendered by default.

33 changes: 31 additions & 2 deletions src/Mod/Arch/Resources/ui/archprefs-import.ui
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>531</width>
<height>548</height>
<width>553</width>
<height>612</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -358,6 +358,35 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>WebGL export</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_15">
<item>
<widget class="Gui::PrefCheckBox" name="checkBox_5">
<property name="toolTip">
<string>If this is checked, wires will be discretized, which results in more accurate curves, but heavier files.</string>
</property>
<property name="text">
<string>Discretize wires</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>webGlDiscretizeCurves</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Arch</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
Expand Down
12 changes: 11 additions & 1 deletion src/Mod/Arch/importWebGL.py
Expand Up @@ -38,6 +38,9 @@
def translate(ctxt,txt):
return txt

p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
DISCRETIZE = p.GetBool("webGlDiscretizeCurves",False)

tab = " " # the tab size
wireframeStyle = "faceloop" # this can be "faceloop", "multimaterial" or None
cameraPosition = None # set this to a tuple to change, for ex. (0,0,0)
Expand Down Expand Up @@ -172,7 +175,14 @@ def getObjectData(obj,wireframeMode=wireframeStyle):
for f in obj.Shape.Faces:
for w in f.Wires:
wo = Part.Wire(DraftGeomUtils.sortEdges(w.Edges))
wires.append(wo.discretize(0.1))
if DISCRETIZE:
wires.append(wo.discretize(0.1))
else:
p = []
for v in wo.Vertexes:
p.append(v.Point)
p.append(wo.Vertexes[0].Point)
wires.append(p)

elif obj.isDerivedFrom("Mesh::Feature"):
mesh = obj.Mesh
Expand Down

0 comments on commit 90f2fc2

Please sign in to comment.