Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: a question about rotation of entities  (Read 3251 times)

0 Members and 1 Guest are viewing this topic.

robot

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 38
    • View Profile
a question about rotation of entities
« on: November 01, 2009, 07:16:27 PM »

hi!

i have an entity (f.e. a tree). a script which is attached to it triggers all leftclicks on the tree.
so far so good, but when i rotate the tree and click to the top of the tree (which is now on the ground) it doesn't trigger any leftclick
do i miss something or is this not possible?

thx
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: a question about rotation of entities
« Reply #1 on: November 01, 2009, 10:12:23 PM »

this is downside of rotation - the interactive region remains the original. I did that manually but it's not very nice. For every visual region I have one dynamic region entity (Tile is the image, F is the region entity):

take that as a possible inspiration only.
Code: WME Script
  1.         var e = Scene.GetNode("Tile"+entityNumber);
  2.         var u = Scene.GetNode("F"+entityNumber);
  3.         var u2 = u.Region;
  4.        
  5.         var rx = -1 * (e.Width / 2);
  6.         var ry = -1 * e.Height;
  7.  
  8.         var rx2 = (e.Width / 2);
  9.         var ry2 = e.Height;
  10.        
  11.         var x1 = ToInt(e.rx + (e.Width /2 ) + (rx * Math.Cos(e.Rotate) - ry*Math.Sin(e.Rotate)));       
  12.         var y1 = ToInt(e.ry + e.Height + (rx * Math.Sin(e.Rotate) + ry * Math.Cos(e.Rotate)));
  13.  
  14.         var x2 = ToInt(e.rx2 - (e.Width / 2) + (rx2 * Math.Cos(e.Rotate) - ry*Math.Sin(e.Rotate)));     
  15.         var y2 = ToInt(e.ry + e.Height + (rx2 * Math.Sin(e.Rotate) + ry * Math.Cos(e.Rotate)));
  16.  
  17.         var x3 = ToInt(e.rx2 - (e.Width /2 ) + (rx2 * Math.Cos(e.Rotate) - ry2*Math.Sin(e.Rotate)));   
  18.         var y3 = ToInt(e.ry2 - e.Height + (rx2 * Math.Sin(e.Rotate) + ry2 * Math.Cos(e.Rotate)));
  19.        
  20.         var x4 = ToInt(e.rx + (e.Width /2 ) + (rx * Math.Cos(e.Rotate) - ry2*Math.Sin(e.Rotate)));     
  21.         var y4 = ToInt(e.ry2 - e.Height(rx * Math.Sin(e.Rotate) + ry2 * Math.Cos(e.Rotate)));
  22.        
  23.  
  24.         u2.SetPoint(0,x1,y1);
  25.         u2.SetPoint(1,x2,y2);
  26.         u2.SetPoint(2,x3,y3);
  27.         u2.SetPoint(3,x4,y4);
  28.  
  29.  

One more problem is, that entity for some strange reason doesn't have it's width stored so I stored these manually (e.Width is presetted earlier in code).
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

robot

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 38
    • View Profile
Re: a question about rotation of entities
« Reply #2 on: November 01, 2009, 10:46:06 PM »

thanks for your answer. so you calculate the rotation and set the four points for the region entity by script, hmm...
it seems to me that this only will work for square images. in my case the image is a tree with transparency so when
i draw a dynamic region entity for the tree, it will have much more than 4 points and so the calculating will be much
more complicated  ???

or does it work also for non-square images?
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: a question about rotation of entities
« Reply #3 on: November 01, 2009, 10:51:06 PM »

well, you can approximate it by rectangle (not necessarily a square) but anything else would be an overkill. :( As I wrote before - it's a downside of an engine rotation in WME 1.x
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

robot

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 38
    • View Profile
Re: a question about rotation of entities
« Reply #4 on: November 01, 2009, 11:04:31 PM »

ok thanks.

thought there would be an easier way  :-\
Logged
 

Page created in 0.066 seconds with 24 queries.