forked from CGCookie/retopoflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodaloperator_prototype.py
94 lines (73 loc) · 3.2 KB
/
modaloperator_prototype.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
'''
Copyright (C) 2015 Taylor University, CG Cookie
Created by Dr. Jon Denning and Spring 2015 COS 424 class
Some code copied from CG Cookie Retopoflow project
https://github.com/CGCookie/retopoflow
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
import bpy
import bgl
from bpy_extras.view3d_utils import location_3d_to_region_2d, region_2d_to_vector_3d
from bpy_extras.view3d_utils import region_2d_to_location_3d, region_2d_to_origin_3d
from mathutils import Vector, Matrix
import math
from .modaloperator import ModalOperator
class OP_BaseEditor(ModalOperator):
''' ModalOperator Prototype '''
bl_category = "Retopology"
bl_idname = "cgcookie.prototype" # unique identifier for buttons and menu items to reference
bl_label = "RetopoFlow Prototype" # display name in the interface
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
#bl_options = {'REGISTER', 'UNDO'} # enable undo for the operator.
def __init__(self):
FSM = {}
'''
fill FSM with 'state':function(self, eventd) to add states to modal finite state machine
FSM['example state'] = example_fn, where `def example_fn(self, context)`.
each state function returns a string to tell FSM into which state to transition.
main, nav, and wait states are automatically added in initialize function, called below.
'''
self.initialize(FSM=FSM)
def start_poll(self, context):
''' Called when tool is invoked to determine if tool can start '''
return True
def start(self, context):
''' Called when tool has been invoked '''
pass
def end(self, context):
''' Called when tool is ending modal '''
pass
def end_commit(self, context):
''' Called when tool is committing '''
pass
def end_cancel(self, context):
''' Called when tool is canceled '''
pass
def draw_postview(self, context):
''' Place post view drawing code in here '''
pass
def draw_postpixel(self, context):
''' Place post pixel drawing code in here '''
pass
def update(self,context):
'''Place update stuff here'''
pass
def modal_wait(self, context, eventd):
'''
Place code here to handle commands issued by user
Return string that corresponds to FSM key, used to change states. For example:
- '': do not change state
- 'main': transition to main state
- 'nav': transition to a navigation state (passing events through to 3D view)
'''
return ''