Author Topic: Reassigning arrow keys to spin camera (SpinL.d3m, SpinR.d3m, etc.)  (Read 2436 times)

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
My arrow keys override the default DC behavior which I believe is simply moving the cursor. And since I never do cursor movement drafting, the arrow keys instead spin the camera.

But note there is a reference frame vision/brain thing happening with respect to which way the view/model spins.  Your preference may be the opposite of mine.  If it is, just reverse the inc values in the macros.

My preference:

Left arrow rotates the camera ccw which makes the model appear to rotate clockwise which is intuitive for me since I tend to think of arrow keys spinning the model, right arrow cw (model moves ccw), up arrow, down arrow etc.   That is what I am doing in those flash movies.   Example, at the end of this 3d handles video where I am hitting the right arrow key (camera rotates cw).

A movie - Handles in 3d - with resizing and then shading and spinning the camera with arrow keys

I find it easier to work in 3d space like this, plus I control the spin increment.  Typically 5 degrees in the movies but it could be anything you want.

Also note I've added the behavior that if something is selected and I hit the arrow key, it does a view center this selection set.

Code: [Select]
'Program: SpinL.d3m (rotate camera view about y axis)

'prl reminder: assigned to left arrow

inc = 5

if sys(80)>0 then
  sys(36)=2
  x =(sys(196)+sys(198))/2
  y =(sys(197)+sys(199))/2
  z =(sys(200)+sys(201))/2
 
  >sethandle
  {
  <Type 0
  <pointxyz [x,y,z]
  }
 
  >SetViewerPoints
  {
  <pointxyz [x,y,z]
  }
  sys(1)=0
  sys(36)=0

endif

if Sys(344) = 0 then '3d mode
   y=sys(206)
   sys(206)= y+inc
endif

>redraw
{
}
End


Code: [Select]
'Program: SpinR.d3m (rotate camera view about y axis)

'prl reminder: assigned to right arrow

inc = -5

if sys(80)>0 then
  sys(36)=2
  x =(sys(196)+sys(198))/2
  y =(sys(197)+sys(199))/2
  z =(sys(200)+sys(201))/2
 
  >sethandle
  {
  <Type 0
  <pointxyz [x,y,z]
  }
 
  >SetViewerPoints
  {
  <pointxyz [x,y,z]
  }
  sys(1)=0
  sys(36)=0

endif

if Sys(344) = 0 then '3d mode
   y=sys(206)
   sys(206)= y+inc
endif

>redraw
{
}
End


Code: [Select]
'Program: SpinU.d3m (rotate camera view about x axis)

'prl reminder: assigned to up arrow

inc = -5

if sys(80)>0 then
  sys(36)=2
  x =(sys(196)+sys(198))/2
  y =(sys(197)+sys(199))/2
  z =(sys(200)+sys(201))/2
 
  >sethandle
  {
  <Type 0
  <pointxyz [x,y,z]
  }
 
  >SetViewerPoints
  {
  <pointxyz [x,y,z]
  }
  sys(1)=0
  sys(36)=0

endif

if Sys(344) = 0 then '3d mode
   x=sys(205)
   sys(205)= x+inc
endif

>redraw
{
}
End

Code: [Select]
'Program: SpinD.d3m (rotate camera view about x axis)

'prl reminder: assigned to down arrow

inc = 5

if sys(80)>0 then
  sys(36)=2
  x =(sys(196)+sys(198))/2
  y =(sys(197)+sys(199))/2
  z =(sys(200)+sys(201))/2
 
  >sethandle
  {
  <Type 0
  <pointxyz [x,y,z]
  }
 
  >SetViewerPoints
  {
  <pointxyz [x,y,z]
  }
  sys(1)=0
  sys(36)=0

endif

if Sys(344) = 0 then '3d mode
   x=sys(205)
   sys(205)= x+inc
endif

>redraw
{
}
End
« Last Edit: March 28, 2015, 04:42:41 AM by prl »

minstrel

  • Hero Member
  • *****
  • Posts: 701
Re: Reassigning arrow keys to spin camera (SpinL.d3m, SpinR.d3m, etc.)
« Reply #1 on: March 28, 2015, 10:56:01 AM »
Great prl!

Now, that's a solution.  Finally I can make some use of all that wasted keyboard real-estate! 
Works fine for me in both 'hidden line' mode and 'shaded'; but not in 'wireframe'.  Is that intended or did I setup something wrong?

Thanks again for the advancements!

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: Reassigning arrow keys to spin camera (SpinL.d3m, SpinR.d3m, etc.)
« Reply #2 on: March 28, 2015, 11:00:40 AM »
Works fine for me in both 'hidden line' mode and 'shaded'; but not in 'wireframe'.  Is that intended or did I setup something wrong?

That's odd.  Should work in all graphic opengl modes.  Double check you have graphics acceleration checked.
« Last Edit: March 28, 2015, 11:53:05 AM by prl »

minstrel

  • Hero Member
  • *****
  • Posts: 701
Re: Reassigning arrow keys to spin camera (SpinL.d3m, SpinR.d3m, etc.)
« Reply #3 on: March 28, 2015, 12:47:41 PM »
That's odd.
Not really...just my mistake.  That's what happens sometimes when we're busy working to shape the future. ;)

The commands work fine in all 'modes'!  Thanks again!

samdavo

  • Hero Member
  • *****
  • Posts: 2587
  • the trick is knowin...^ > v < - which way's up?
Re: Reassigning arrow keys to spin camera (SpinL.d3m, SpinR.d3m, etc.)
« Reply #4 on: March 28, 2015, 04:06:19 PM »
prl
I'm missing something.   I understand that each macro rotates the view by 5 degrees etc - (looks very promising) - and that if I run, eg SpinL in the spacebar command line, then that is what happens -

and I am also familiar with changing the keyboard to amend the function of (most) keys

but I can't find where you can reassign the arrow keys.  Any clues please.

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: Reassigning arrow keys to spin camera (SpinL.d3m, SpinR.d3m, etc.)
« Reply #5 on: March 28, 2015, 04:21:15 PM »
but I can't find where you can reassign the arrow keys.  Any clues please.

Under Options>Options>Keyboard  Category Macro   SpinL.d3m assign it to the left arow.   Same for others.

samdavo

  • Hero Member
  • *****
  • Posts: 2587
  • the trick is knowin...^ > v < - which way's up?
Re: Reassigning arrow keys to spin camera (SpinL.d3m, SpinR.d3m, etc.)
« Reply #6 on: March 28, 2015, 04:27:54 PM »
ahhh - easy!!
What I was doing (as I normally do) was trying to find where the arrows were currently allocated so that I could cancel them ... and only THEN to reassign them.

But it seems that with arrows you don't need to do that (i.e. the first step of cancelling).  All good.   Anyway great macros, thanks!
« Last Edit: March 28, 2015, 04:34:00 PM by samdavo »

samdavo

  • Hero Member
  • *****
  • Posts: 2587
  • the trick is knowin...^ > v < - which way's up?
Re: Reassigning arrow keys to spin camera (SpinL.d3m, SpinR.d3m, etc.)
« Reply #7 on: March 28, 2015, 05:56:16 PM »
PS I have actually reversed the +/- direction of the increment in each of the macros -
mainly so that the direction is consistent with the DCAD default "view toolbox" - and also incidentally with bdeck's vd.d3m .    (edit) lol - but reversed back next post

Having said that,  I often start spinning left when I really want to spin right  (object vs camera etc) - and possibly your macros are more intuitive - all as you describe so well in the first post.   
My preference:

Left arrow rotates the camera ccw which makes the model appear to rotate clockwise which is intuitive for me since I tend to think of arrow keys spinning the model, ...   

PS Maybe I'll change back after a few days and try your method :)
cheers
« Last Edit: March 28, 2015, 08:45:35 PM by samdavo »

samdavo

  • Hero Member
  • *****
  • Posts: 2587
  • the trick is knowin...^ > v < - which way's up?
Re: Reassigning arrow keys to spin camera (SpinL.d3m, SpinR.d3m, etc.)
« Reply #8 on: March 28, 2015, 08:34:53 PM »
prl
I take it back.
Having checked it out better, I've gone back to your sign convention for rotations :)
And have changed bdeck's macro to suit your SpinL.d3m etc.  Cheers

reply #19 here :-
http://forum.designcadcommunity.com/index.php?topic=6158.msg43951#new

Note:-
With these great macros, and great "spin the view" options, I don't think I will ever use the default DCAD view-manipulation-options again.  :)   
« Last Edit: March 28, 2015, 08:43:20 PM by samdavo »

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: Reassigning arrow keys to spin camera (SpinL.d3m, SpinR.d3m, etc.)
« Reply #9 on: March 29, 2015, 03:35:49 AM »
I take it back.

The frame of reference things comes up often.   

You are in an elevator that is falling.  Your world following the initial acceleration at least temporarily appears static again.

Taking it to excess.

You are in an elevator that is falling.  You are going to have a bad day today.
The earth is an atom in a second elevator in a higher order universe.   That second elevator is falling too.
That higher order universe is an atom on a butterfly taking flight.  It is a spring day and all is well for the butterfly.

« Last Edit: March 29, 2015, 03:52:07 AM by prl »

samdavo

  • Hero Member
  • *****
  • Posts: 2587
  • the trick is knowin...^ > v < - which way's up?
Re: Reassigning arrow keys to spin camera (SpinL.d3m, SpinR.d3m, etc.)
« Reply #10 on: May 08, 2015, 04:26:45 PM »
prl,
I have a minor problem / puzzle,  probably something to do with Regen statements - or maybe General settings (?)  Really strange that the problem only happens with V24 (and not V22).
(edit) PS Easily sorted out - see next post.

I really like these macros, (eg spinL.d3m, spinR.d3m etc), and have assigned them to arrow keys, and to standard keyboard.

Ok, suppose you have a box in 3D;  in V22 they work fine, and the redraw of the spun box is instantaneous.

However I am finding the box  done with V24 only redraws after I manually add a  regen (Ctrl + R).    In fact sometimes you can have both the unspun and the spun versions of the box visible.   I am guessing this would be a simple amendment to the 4 macros (?)  ....  OR alternatively, there might be a setting somehwhere in Q\general (?)

PS   Then there is bdeck's vdd.d3m,  all as discussed in reply #19 here :-
http://forum.designcadcommunity.com/index.php?topic=6158.msg43948#msg43948
It seems to work fine in both V22 and V24.
« Last Edit: May 09, 2015, 02:08:01 AM by samdavo »

samdavo

  • Hero Member
  • *****
  • Posts: 2587
  • the trick is knowin...^ > v < - which way's up?
Re: Reassigning arrow keys to spin camera (SpinL.d3m, SpinR.d3m, etc.)
« Reply #11 on: May 08, 2015, 09:08:07 PM »
Think I've fixed it ...
It seems that "redraw" is an acceptable command for V22 but not for V24 (!?)
If you change that to "regenerate" then all works in both.

PS You have to change SpinL, SpinR, SpinU and SpinD.d3m  (attached)
Quote
Program: SpinL.d3m (rotate camera view about y axis)

'prl reminder: assigned to left arrow
'samdavo amendment - regenerate instead of redraw

inc = 5

if sys(80)>0 then
  sys(36)=2
  x =(sys(196)+sys(198))/2
  y =(sys(197)+sys(199))/2
  z =(sys(200)+sys(201))/2
 
  >sethandle
  {
  <Type 0
  <pointxyz [x,y,z]
  }
 
  >SetViewerPoints
  {
  <pointxyz [x,y,z]
  }
  sys(1)=0
  sys(36)=0

endif

if Sys(344) = 0 then '3d mode
   y=sys(206)
   sys(206)= y+inc
endif

'>redraw - oops this doesnt want to play with V24
>regenerate
{
}
End
« Last Edit: May 09, 2015, 04:42:46 AM by samdavo »

samdavo

  • Hero Member
  • *****
  • Posts: 2587
  • the trick is knowin...^ > v < - which way's up?
Re: Reassigning arrow keys to spin camera (SpinL.d3m, SpinR.d3m, etc.)
« Reply #12 on: December 15, 2015, 01:40:29 PM »
Old topic but REALLY handy macros, ESPECIALLY when assigned to arrows as hotkeys.

Here's a great file to work with to demonstrate / practice. 
Suppose you've drawn a sphere with a heap of hexagonal tubes through it.
i.e. you've been passively and unknowingly smoking weed - AND inhaling, lol.

I enclose a dcd drawn by adriank of just such an object.
(reply #1 here :-  http://forum.designcadcommunity.com/index.php?topic=6437.msg46098#new  )

Now suppose you want to look down each of those tubular elements.

These macros, if assigned to the arrow keys are PERFECT for this.
Select the sphere (which will centralise it in the screen and for viewing rotations), then start using the arrows.   
I enclose a photo of one tube.
After that, simply use the other arrows.

Thanks again prl - (wherever you are lol).
Cheers
Sam   
« Last Edit: December 15, 2015, 01:50:21 PM by samdavo »