/* Rotate Plugin Client - DMS - Mar 99 - by Sylvain HUET */ /* modified - Jun 99 - by Christophe LOREK */ /* plugin Rotobjet par iri - http://www.irizone.net */ var FRAMES_PER_SECOND = 1;; /* default framerate value */ typeof class=S;; var rotobj_click = 0;; var actif = 0;; fun rotclick(o, p)= let p -> [h3d mat btn] in let match hd (ObAnchor o) with (objAnchor [h _ _ _] -> h ) |(_->nil) -> h in set rotobj_click = if (btn == RBUTTON) && (h == h3d) && (actif == 1) then 1 else 0;; fun rotobj2(x, v) = match x with (objAnchor [h _ _ _] -> M3rotateObj session h v) |(_->nil) ;; fun rotobj(o, p)= let p -> [angx angy angz framerate] in if rotobj_click == 1 then let w3d.V3dcursor -> [xc yc] in let match hd (ObAnchor o) with (objAnchor [h _ _ _] -> M3getObjVec session h ) |(_->nil) -> [x y z] in let if angx == 1 then (xc-x)/framerate else 0 -> a in let if angy == 1 then (yc-y)/framerate else 0 -> b in let if angz == 1 then (yc-z)/framerate else 0 -> c in apply_on_list (ObAnchor o) @rotobj2 [a b c] else 0;; fun activate(o, from, action, param, rep) = set actif = 1; _DMSevent this strcat class ".activated" nil nil;; fun desactivate(o, from, action, param, rep) = set actif = 0; _DMSevent this strcat class ".desactivated" nil nil;; fun delete(o,paramU) = ObCbAnim o nil; let paramU -> [ax ay az] in match hd (ObAnchor o) with (objAnchor [h _ _ _] -> M3setObjAng session h [ax ay az]) |(_->nil);; fun newOb(o)= let atoi hd UgetParam ObUi o "angularX" -> angx in let atoi hd UgetParam ObUi o "angularY" -> angy in let atoi hd UgetParam ObUi o "angularZ" -> angz in let atoi hd UgetParam ObUi o "framerate" -> framerate in let if framerate == nil || framerate == 0 then FRAMES_PER_SECOND else framerate -> framerate in let match hd (ObAnchor o) with (objAnchor [h _ _ _] -> M3getObjAng session h ) |(_->nil) -> [ax ay az] in ( ObCbControlClick o @rotclick; ObCbAnim o mkfun2 @rotobj [angx angy angz framerate]; ObCbDestroy o mkfun2 @delete [ax ay az]; ObRegisterAction o strcat ObName o ".activate" @activate; ObRegisterAction o strcat ObName o ".desactivate" @desactivate; 0 );; fun IniPlug(file)= set class=getInfo strextr _getpack _checkpack file "name"; PLUGsetinfo thisplug PLUGIN_OBJECT|PLUGIN_RESERVED; PlugRegister class @newOb nil; 0;;