Script that rotates background image?

Next
 From:  Martin (MARTIN3D)
8317.1 
Can I rotate a background image via script?

This trial crashes MoI:

code:
var img = moi.view.getBackgroundImages().item(0);

var objectList = moi.geometryDatabase.createObjectList();
objectList.addObject( img );

var factory = moi.command.createFactory( "rotate" );
factory.setInput( 0, objectList );
factory.setInput( 1, img.frame );
factory.setInput( 2, 45 );
factory.setInput( 5, 'false' );
factory.commit();



-Martin
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
8317.2 In reply to 8317.1 
Maybe change cplane???

The cplane can be changed, and the image reloaded. Point spaceing would have to be saved...

EDITED: 19 Feb by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Max Smirnov (SMIRNOV)
8317.3 In reply to 8317.1 
Hi Martin,

You can't use rotate factory with background images. Use frame property instead.
moi.view.getBackgroundImages().item(0).frame = moi.VectorMath.createFrame(moi.VectorMath.createPoint(0,0,0),moi.VectorMath.createPoint(0,1,0),moi.VectorMath.createPoint(-1,0,0))
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
8317.4 In reply to 8317.3 
Yup, background images are distinct from geometry objects, they can't go in an object list. The frame property like Max writes above is how they can be manipulated. Thanks Max!

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  mkdm
8317.5 In reply to 8317.3 
Hi Max!

Tanks a lot for the tip!

ASAP I'm going to write a commands with UI (?) ad I will include it in my scripts/commands toolbox.

See you!

- Marco (mkdm)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Martin (MARTIN3D)
8317.6 
Thanks a lot for the help!

-Martin
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Martin (MARTIN3D)
8317.7 
I need your help again:

The default rotation origin of the image frame is the lower left corner. How can I change this?
I want to rotate the center of the background image around MoIs 0,0,0 coordinate.

I found this in the Javascript documentation but it has no effect:
img.frame.newOriginX = img.width/2;
img.frame.newOriginY = img.height/2;

-Martin
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Max Smirnov (SMIRNOV)
8317.8 In reply to 8317.7 
Hi Martin,

this task is not easy :)
imp.frame specifies position of lower left corner of the image.

To rotate image around its center you need to find a central axis coordinates.
p0 = img.frame.evaluate(img.width/2, img.height/2, 0);
p1 = img.frame.evaluate(img.width/2, img.height/2, 1);

Then you need to rotate img.frame.origin, img.frame.xaxis and img.frame.yaxis points around this vector.
You can use google to find articles with titles like "Rotation about an arbitrary axis"

Also you can check my nodeeditor project. core/litegraph.js -> rotateAroundNormalizedVector function
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Martin (MARTIN3D)
8317.9 In reply to 8317.8 
Thank you Max for the tips.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All