<div dir="ltr"><div dir="ltr">correction first output is<div><div> <Scene></div><div> <Group DEF='A'></div><div> <Transform DEF='C'/></div><div> </Group></div><div> <Group DEF='B'></div><div> <Transform DEF='C'/></div><div> </Group></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 16, 2023 at 10:32 AM GPU Group <<a href="mailto:gpugroup@gmail.com">gpugroup@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">That may relate to the DEF USE issue with X3D.py:<div>x x3d.py makes no effort to conjugate DEF and USE and properly order DEF before USE in its export stream</div><div>- not a common problem unless a node has 2 fields that take the same node (directly SF or indirectly in MFNode descendent field)</div><div>x it's a problem with HAnimHumanoid which has coordinate and skin fields, which typically involve the same Coordinate node</div><div>- tinkering can be done in the blender exporter, to do a USE before a DEF, but with inconvenience and messy code</div><div>If a call can be made in x3d.py before exporting a DEF or USE, then that function can be over-ridden to take responsibility for DEF USE conjugation and correct output ordering something like this:</div><div>node = getDefOrUse(node, node.DEF, node.USE)</div><div>and for the x3d.py default it would just return the same element (or node), and overrides can do something more sophisticated.</div><div><br></div><div>more..</div><div>DEF USE NON-CONJUGATION IN X3D.PY</div><div>test_def.py</div><div><div>x3d = X3D()</div><div>scene = Scene()</div><div>x3d.Scene = scene</div><div>grpa = Group(DEF='A')</div><div>grpb = Group(DEF='B')</div><div>scene.children.append(grpa)</div><div>scene.children.append(grpb)</div><div>trans = Transform(DEF='C')</div><div>grpb.children.append(trans)</div><div>grpa.children.append(trans)</div><div>blob = x3d.XML()</div><div>fp = open("dump.x3d","w+")</div><div>fp.write(blob)</div><div>fp.close()</div></div><div><br></div><div>output:</div><div><div><?xml version="1.0" encoding="UTF-8"?></div><div><!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 4.0//EN" "<a href="https://www.web3d.org/specifications/x3d-4.0.dtd" target="_blank">https://www.web3d.org/specifications/x3d-4.0.dtd</a>"></div><div><X3D profile='Full' version='4.0' xmlns:xsd='<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>' xsd:noNamespaceSchemaLocation='<a href="https://www.web3d.org/specifications/x3d-4.0.xsd" target="_blank">https://www.web3d.org/specifications/x3d-4.0.xsd</a>'></div><div> <Scene></div><div> <Group DEF='A'></div><div> <Transform USE='C'/></div><div> </Group></div><div> <Group DEF='B'></div><div> <Transform DEF='C'/></div><div> </Group></div><div> </Scene></div><div></X3D></div></div><div><br></div><div>test_def_use.py</div><div><div>from x3d import *</div><div><br></div><div>x3d = X3D()</div><div>scene = Scene()</div><div>x3d.Scene = scene</div><div>grpa = Group(DEF='A')</div><div>grpb = Group(DEF='B')</div><div>scene.children.append(grpa)</div><div>scene.children.append(grpb)</div><div>trans = Transform(DEF='C')</div><div>grpb.children.append(trans)</div><div>grpa.children.append(trans)</div><div>blob = x3d.XML()</div><div>fp = open("dump.x3d","w+")</div><div>fp.write(blob)</div><div>fp.close()</div></div><div><br></div><div>output:</div><div><div><?xml version="1.0" encoding="UTF-8"?></div><div><!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 4.0//EN" "<a href="https://www.web3d.org/specifications/x3d-4.0.dtd" target="_blank">https://www.web3d.org/specifications/x3d-4.0.dtd</a>"></div><div><X3D profile='Full' version='4.0' xmlns:xsd='<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>' xsd:noNamespaceSchemaLocation='<a href="https://www.web3d.org/specifications/x3d-4.0.xsd" target="_blank">https://www.web3d.org/specifications/x3d-4.0.xsd</a>'></div><div> <Scene></div><div> <Group DEF='A'></div><div> <Transform USE='C'/></div><div> </Group></div><div> <Group DEF='B'></div><div> <Transform DEF='C'/></div><div> </Group></div><div> </Scene></div><div></X3D></div></div><div><br></div><div><br></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 16, 2023 at 10:09 AM GPU Group <<a href="mailto:gpugroup@gmail.com" target="_blank">gpugroup@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">It seems possible to override functions in python, if there are just a few to override.<div>And one suggestion for x3d.py imperfections is to apply fixes at runtime in some initialization function.</div><div>- that assumes/requires just a few target functions, not 480 functions that need to be repaired</div><div>- so for some fixes it may be helpful to change the upstream x3d.py to call a function that can be easily replaced.</div><div>-Doug</div><div>Example:</div><div>file myclass.py<div><div>class Wonky:</div><div> def __init__(self):</div><div> self.color = "Red"</div><div> def func1(self, color :str) -> bool:</div><div> if color == self.color:</div><div> return True</div><div> return False</div></div><div><br></div><div>file override.py</div><div><div>from myclass import *</div><div><br></div><div>mc = Wonky()</div><div>print("match with Blue? "+str(mc.func1("Blue")))</div><div><br></div><div>def func2(self, color: str) -> bool:</div><div> if self.color != color:</div><div> return True</div><div> return False</div><div>Wonky.func1 = func2 # <<<<<<<<<<<< OVERRIDE<br></div><div>print("don't match with Blue? "+str(mc.func1("Blue")))<br></div></div><div><br></div><div>output:</div><div><div>match with Blue? False</div><div>don't match with Blue? True</div></div><div>-Doug</div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 16, 2023 at 9:55 AM John Carlson <<a href="mailto:yottzumm@gmail.com" target="_blank">yottzumm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Instead of calling str() to print out a value, call a function that does precision floating point formatting on floats according to a user’s wishes. If the value is a list, call the function recursively with a list comprehension, otherwise, call str.<div dir="auto"><br></div><div dir="auto">I think this is doable by mere humans.</div><div dir="auto"><br></div><div dir="auto">Thanks,</div><div dir="auto"><br></div><div dir="auto">John</div>
</blockquote></div>
</blockquote></div>
</blockquote></div>