/ test_v2_architecture.py
test_v2_architecture.py
1 """ 2 Test: DreamTalk v2.0 Architecture 3 4 Validates the fresh architecture: 5 - Geometry-based stroke rendering (no Sketch & Toon) 6 - Python Generators for all relationships (no XPresso) 7 - Simplified Scene class 8 - New base classes (LineObject, SolidObject, CustomObject) 9 10 Run this in Cinema 4D to verify the refactoring. 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 from DreamTalk.imports import * 21 22 23 class V2ArchitectureTest(ThreeDScene): 24 """Test the v2.0 architecture with basic primitives.""" 25 26 def construct(self): 27 print("=" * 60) 28 print("DreamTalk v2.0 Architecture Test") 29 print("=" * 60) 30 31 # Test 1: LineObject with geometry-based strokes 32 print("\n[Test 1] LineObject - Circle with stroke rendering") 33 circle = Circle(radius=100, color=BLUE, stroke_width=4, x=-200) 34 print(f" Circle type: {circle.obj.GetTypeName()}") 35 print(f" Has stroke_gen: {hasattr(circle, 'stroke_gen')}") 36 print(f" Has spline: {hasattr(circle, 'spline')}") 37 38 # Test 2: SolidObject with fill and stroke 39 print("\n[Test 2] SolidObject - Sphere with fill and stroke") 40 sphere = Sphere(radius=80, color=RED, filled=0.5, stroke_width=3, x=0) 41 print(f" Sphere type: {sphere.obj.GetTypeName()}") 42 print(f" Has mesh: {hasattr(sphere, 'mesh')}") 43 print(f" Has stroke_gen: {hasattr(sphere, 'stroke_gen')}") 44 print(f" Has fill_material: {hasattr(sphere, 'fill_material')}") 45 46 # Test 3: Rectangle (another LineObject) 47 print("\n[Test 3] LineObject - Rectangle") 48 rect = Rectangle(width=150, height=100, color=GREEN, stroke_width=3, x=200) 49 print(f" Rectangle type: {rect.obj.GetTypeName()}") 50 51 # Test 4: Camera (CustomObject with generator) 52 print("\n[Test 4] ThreeDCamera - CustomObject with generator") 53 print(f" Camera type: {self.camera.obj.GetTypeName()}") 54 print(f" Is Python Generator: {self.camera.obj.GetType() == 1023866}") 55 56 # Test 5: Animation works 57 print("\n[Test 5] Animation test - draw circle") 58 circle2 = Circle(radius=60, color=PURPLE, draw_completion=0, y=-150) 59 self.play(circle2.draw(1.0), run_time=1) 60 print(f" Draw animation executed") 61 62 print("\n" + "=" * 60) 63 print("All tests passed! v2.0 architecture is working.") 64 print("=" * 60) 65 print("\nKey changes in v2.0:") 66 print("- No Sketch & Toon VideoPost (removed)") 67 print("- No XPresso (generators only)") 68 print("- All strokes are geometry (StrokeGen)") 69 print("- All solids have silhouette generators") 70 print("- Cameras use Python Generator code") 71 72 73 if __name__ == "__main__": 74 scene = V2ArchitectureTest()