/ test_full_migration.py
test_full_migration.py
 1  """
 2  Full migration test: MindVirusInfection with generator_mode=True
 3  
 4  Tests:
 5  - ThreeDCamera as Python Generator
 6  - FoldableCube as Python Generator
 7  - MindVirus with generator_mode (cube control via direct UserData)
 8  - HumanMind (USD mesh - stroke_mode pending)
 9  
10  This validates the XPresso-free architecture for MoGraph compatibility.
11  """
12  import sys
13  from pathlib import Path
14  
15  # Purge DreamTalk modules for clean import
16  modules_to_delete = [key for key in sys.modules.keys() if 'DreamTalk' in key]
17  for mod in modules_to_delete:
18      del sys.modules[mod]
19  
20  # Bootstrap paths for all submodules
21  _submodules = Path(__file__).resolve().parent.parent / 'MindVirusInfection' / 'submodules'
22  sys.path.insert(0, str(_submodules))
23  
24  from DreamTalk.imports import *
25  
26  # Import sovereign symbol modules
27  import importlib.util
28  
29  def load_dreamnode(name):
30      """Load a DreamNode's main class from submodules."""
31      spec = importlib.util.spec_from_file_location(
32          name,
33          _submodules / name / f"{name}.py"
34      )
35      module = importlib.util.module_from_spec(spec)
36      spec.loader.exec_module(module)
37      return getattr(module, name)
38  
39  HumanMind = load_dreamnode("HumanMind")
40  MindVirus = load_dreamnode("MindVirus")
41  
42  
43  class FullMigrationTestScene(ThreeDScene):
44      def __init__(self):
45          # generator_mode=True for camera
46          super().__init__(sketch_mode=True, generator_mode=True)
47  
48      def construct(self):
49          print("=== Full Migration Test ===")
50  
51          # Human mind (USD mesh)
52          human = HumanMind(scale=1.0)
53          print(f"HumanMind type: {human.obj.GetTypeName()}")
54  
55          # Cable anchor
56          cable_anchor = Null(z=800, name="CableOrigin")
57  
58          # MindVirus with generator_mode
59          virus = MindVirus(
60              color=BLUE,
61              cable=True,
62              cable_origin=cable_anchor,
63              cable_radius=4,
64              cable_color=WHITE,
65              stroke_width=3,
66              z=400,
67              scale=0.6,
68              generator_mode=True,
69              name="MindVirus"
70          )
71  
72          # Verify generator mode
73          print(f"\n=== Generator Mode Verification ===")
74          print(f"Camera: {self.camera.obj.GetTypeName()} (is_gen: {self.camera.obj.GetType() == 1023866})")
75          print(f"FoldableCube: {virus.cube.obj.GetTypeName()} (is_gen: {virus.cube.obj.GetType() == 1023866})")
76          print(f"MindVirus generator_mode: {virus.generator_mode}")
77  
78          # Test fold animation works via generator
79          print(f"\n=== Fold Parameter Test ===")
80          print(f"Initial fold (cube): {virus.cube.obj[virus.cube.fold_parameter.desc_id]}")
81  
82          # Set fold to 0.5 and verify generator updates
83          virus._set_fold_value(0.5)
84          c4d.EventAdd()
85          print(f"After setting 0.5: {virus.cube.obj[virus.cube.fold_parameter.desc_id]}")
86  
87          # Set fold to 1.0 (fully folded)
88          virus._set_fold_value(1.0)
89          c4d.EventAdd()
90          print(f"After setting 1.0: {virus.cube.obj[virus.cube.fold_parameter.desc_id]}")
91  
92          print("\n=== Test Complete ===")
93          print("Scene created with XPresso-free architecture!")
94          print("FoldableCube and ThreeDCamera use Python Generators")
95  
96  
97  if __name__ == "__main__":
98      scene = FullMigrationTestScene()