Recognizing right / middle and left mouse click in synoptic

Discussions concerning programming of SOFTIMAGE©
Post Reply
User avatar
sirdavid32
Posts: 309
Joined: 10 Feb 2010, 04:36
Location: Ecuador
Contact:

Recognizing right / middle and left mouse click in synoptic

Post by sirdavid32 » 10 Feb 2010, 04:59

Hello, I´ve been trying to trigger events recognizing left /middle/right mouse button clicks with the "in_mousebutton ==1"...(0,3) but so far I can´t do it right because of the syntax. How could I make xsi Recognize right / middle and left mouse click in synoptic view?

I landed into this page: http://translate.google.com/translate?u ... =&ie=UTF-8

Scroll all the way down. The guy says this script adds or substracts from a current selection.

sub Head (in_obj, in_mousebutton, in_keymodifier)
if in_keymodifier = 1 or in_keymodifier = 2 then if in_keymodifier = 1 or in_keymodifier = 2 then
AddToSelection (in_obj & ".Head") AddToSelection (in_obj & ". Head")
else else
SelectObj (in_obj & ".Head"), , True SelectObj (in_obj & ". Head"),, True
end if end if
end sub end sub

That´s a sample.

Sample nº2:
http://vimeo.com/8040543

He´s rigged a character, stored predefined poses for the hand and invokes them from the synoptic view to pose the hands with a (right click) for the right hand pose, (middle click) for both hands posed, and (left click) to pose left hand respectively.

I figured, selecting objects it´s a simple thing. I am not a programmer so I came up with this:

sub eyes(in_obj,in_mousebutton,in_keymodifier)
if(in_mousebutton == 0) SelectObj "sphere1", , True
end sub

"eyes", it´s the name of my hotspot in the synoptic page.
But this script is in VBscript and it turns an error.

I´d really would like to know if anyone could aid me with this code fixed to trigger an action and also to select "something" in the scene. If I have 3 spheres I´d like to select them by using a single hotspot from the synoptic but right/middle or left clicking to select either, please?

David.

User avatar
sirdavid32
Posts: 309
Joined: 10 Feb 2010, 04:36
Location: Ecuador
Contact:

Re: Recognizing right / middle and left mouse click in synoptic

Post by sirdavid32 » 10 Feb 2010, 06:17

I got this chunk of code working:

sub head (in_obj, in_mousebutton, in_keymodifier)
if in_mousebutton = 1 or in_mousebutton = 2 then
SelectObj "happy_smile.sphere2", , True
else
SelectObj "happy_smile.sphere1", , True
end if
end sub


But now I want to add triggering actions with the left or right or middle button.
I pasted this code along with the first part, it returns an error:


sub Posing(in_obj,in_mousebutton,in_keymodifier)
if in_mousebutton = 1 then SelectObj "happy_smile.Mixer.Default_pose_1st";
ApplyAction "happy_smile.Mixer.Default_pose_1st"
else

if in_mousebutton = 0 then SelectObj "happy_smile.Mixer.Rie_atras"
ApplyAction "happy_smile.Mixer.Rie_atras"
else

if in_mousebutton = 2 then DeselectAll
end if

end sub


SO now I´d like to know what would be a better method to name (with a variable) the model.name to trigger actions? so that I could use this same synoptic for other models as well...

Any ideas?

craft
Posts: 107
Joined: 03 Jan 2010, 00:40
Location: Portugal
Contact:

Re: Recognizing right / middle and left mouse click in synoptic

Post by craft » 10 Feb 2010, 19:31

i think you need two more end if's to terminate your conditions.
A good indentation helps clarify that:

Code: Select all

sub Posing(in_obj,in_mousebutton,in_keymodifier)
if in_mousebutton = 1 then 
   SelectObj "happy_smile.Mixer.Default_pose_1st";
   ApplyAction "happy_smile.Mixer.Default_pose_1st"

else
   if in_mousebutton = 0 then 
      SelectObj "happy_smile.Mixer.Rie_atras"
      ApplyAction "happy_smile.Mixer.Rie_atras"

   else
      if in_mousebutton = 2 then 
         DeselectAll
      end if
   end if
end if

end sub

User avatar
sirdavid32
Posts: 309
Joined: 10 Feb 2010, 04:36
Location: Ecuador
Contact:

Re: Recognizing right / middle and left mouse click in synoptic

Post by sirdavid32 » 11 Feb 2010, 04:43

Then If I code this:


sub head (in_obj, in_mousebutton, in_keymodifier)
if in_mousebutton = 1 or in_mousebutton = 2 then
SelectObj "happy_smile.sphere2", , True
else
SelectObj "happy_smile.sphere1", , True
end if
end sub

sub Posing(in_obj,in_mousebutton,in_keymodifier)
if in_mousebutton = 1 then SelectObj "happy_smile.Mixer.Default_pose_1st";
ApplyAction "happy_smile.Mixer.Default_pose_1st"
else

if in_mousebutton = 0 then SelectObj "happy_smile.Mixer.Rie_atras"
ApplyAction "happy_smile.Mixer.Rie_atras"
else

if in_mousebutton = 2 then DeselectAll
end if

end sub

----
Xsi returns: Expected end of statement - [line12]
That would be at the end of the first "if" statement....so how to correctly syntax there?

craft
Posts: 107
Joined: 03 Jan 2010, 00:40
Location: Portugal
Contact:

Re: Recognizing right / middle and left mouse click in synoptic

Post by craft » 11 Feb 2010, 05:08

;) hey.
i'm not that experienced with vbs (i'm mostly into jscript and python) so this might be incorrect, but you should try anyway:
1) take a closer look at my code in the previous post. i didn't write any code to the right of the "then" statement, only under. The reason why i did that is because in JScript and Python, if you write something straight after the if (then) condition, the program will assume that's the only command inside the if statement.
so:

Code: Select all

if(a=="something")b=3
c=4
is the same as :

Code: Select all

if(a=="something"){
b=3
}
c=4
and NOT

Code: Select all

if(a=="something"){
b=3
c=4
}
Assuming VBS is the same, the program expects and "Else" of "end if" after that line and instead it's receiving another command, thus resulting in an error. So, keep your commands in a new line, not after the Then, for this situation.

2) you are still not using all the 3 END IF's at the end as i wrote in my example. you'll need that or else you'll stumble into another error after the one you're already getting at line 12.

User avatar
sirdavid32
Posts: 309
Joined: 10 Feb 2010, 04:36
Location: Ecuador
Contact:

XSI Recognizing right / middle and left mouse click in synop

Post by sirdavid32 » 11 Feb 2010, 17:54

This is the code that finally triggered it all. I can now select 2 spheres in the scene wi the hotspot named "head" and I can trigger actions with the hotspot named "Posing". XSI recognizes right, middle and left mouse button in synoptic view. Excellent!

sub head (in_obj, in_mousebutton, in_keymodifier)
if in_mousebutton = 1 or in_mousebutton = 2 then
SelectObj "happy_smile.sphere2", , True
else
SelectObj "happy_smile.sphere1", , True
end if
end sub

sub Posing(in_obj,in_mousebutton,in_keymodifier)
if in_mousebutton = 1 then
SelectObj "happy_smile.Mixer.Default_pose_1st"
ApplyAction "happy_smile.Mixer.Default_pose_1st"

else
if in_mousebutton = 0 then
SelectObj "happy_smile.Mixer.Rie_atras"
ApplyAction "happy_smile.Mixer.Rie_atras"

else
if in_mousebutton = 2 then
DeselectAll
end if
end if
end if

end sub

THANK YOU SO VERY MUCH! This will save me tons of hours in animation.

One single question though: if I want to open a ppg from the synoptic, how could I do that? I´ve been looking everywhere in the SDK and the log actions from the script editor do not trigger a ppg alone. Is there a way to trigger ppgs from within synoptic?

craft
Posts: 107
Joined: 03 Jan 2010, 00:40
Location: Portugal
Contact:

Re: Recognizing right / middle and left mouse click in synoptic

Post by craft » 11 Feb 2010, 20:46

use the InspectObj command. search it in the help files to learn how it works, its pretty basic.

User avatar
sirdavid32
Posts: 309
Joined: 10 Feb 2010, 04:36
Location: Ecuador
Contact:

Selecting an object in Javascript from the synoptic?

Post by sirdavid32 » 24 Aug 2010, 06:21

Hello, I´ve been trying to setup a simple script in jscript to select an object inside a model from a synpptic view setup un in javascript:

<html>
<body version="2">
<script language="JavaScript">
function round_area(in_obj,in_mousebutton,in_keymodifier)
{
SelectObj ("sphere, , True);
};


But this returns an error everytime. I don´t know what part of the sytax
I´m not working right.

Could anyone help me please?

craft
Posts: 107
Joined: 03 Jan 2010, 00:40
Location: Portugal
Contact:

Re: Recognizing right / middle and left mouse click in synoptic

Post by craft » 24 Aug 2010, 18:44

missing a " here: SelectObj ("sphere, , True);
should be: SelectObj ("sphere", , True);

User avatar
sirdavid32
Posts: 309
Joined: 10 Feb 2010, 04:36
Location: Ecuador
Contact:

Re: Recognizing right / middle and left mouse click in synoptic

Post by sirdavid32 » 25 Aug 2010, 03:55

Thanks!! it´s working now!! yes!!
So how in js can one place a reset actor and keyframe all commands?

User avatar
sirdavid32
Posts: 309
Joined: 10 Feb 2010, 04:36
Location: Ecuador
Contact:

Re: Recognizing right / middle and left mouse click in synoptic

Post by sirdavid32 » 01 Sep 2010, 21:07

I solved the reset actor like this:

function Reset_ALL(in_obj)
{
SelectObj("Rig.Animable_Ctrls", null, null);
SelectMembers(null, null, null);
Translate(null, 0, 0, 0, siAbsolute, siPivot, siObj, siX, null, null, null, null, null, null, null, null, null, 0, null);
Translate(null, 0, 0, 0, siAbsolute, siPivot, siObj, siY, null, null, null, null, null, null, null, null, null, 0, null);
Translate(null, 0, 0, 0, siAbsolute, siPivot, siObj, siZ, null, null, null, null, null, null, null, null, null, 0, null);

Rotate(null, 0, 0, 0, siAbsolute, siPivot, siObj, siX, null, null, null, null, null, null, null, 0, null);
Rotate(null, 0, 0, 0, siAbsolute, siPivot, siObj, siY, null, null, null, null, null, null, null, 0, null);
Rotate(null, 0, 0, 0, siAbsolute, siPivot, siObj, siZ, null, null, null, null, null, null, null, 0, null);

DeselectAll();
}


But now, how do I create a button to keyframe translations or rotations depending on the mode that´s currently selected?

Thanks. This is great help, I appreciate it a lot.

User avatar
sirdavid32
Posts: 309
Joined: 10 Feb 2010, 04:36
Location: Ecuador
Contact:

Recognizing right / middle and left mouse click in synoptic

Post by sirdavid32 » 16 Sep 2010, 22:17

I´m polishing some of the synoptic code I commented
about 2 weeks ago, and I am trying to create a condition for the "in_mousebutton"
to be detected when clicking on the synoptic with javascript.

For example: In the synoptic page If I (LEFT) click in this region..something happens. If I (RIGHT) click on this region
something else will happen. If I (MIDDLE) click on this region then both things (left and right) click happens at the same time.

I had this piece of code originally in visual basic:

sub Posing(in_obj,in_mousebutton,in_keymodifier)
if in_mousebutton = 1 then
SelectObj "happy_smile.Mixer.Default_pose_1st";
ApplyAction "happy_smile.Mixer.Default_pose_1st"

else
if in_mousebutton = 0 then
SelectObj "happy_smile.Mixer.smile_back"
ApplyAction "happy_smile.Mixer.smile_back"

else
if in_mousebutton = 2 then
DeselectAll
end if
end if
end if

When I tried to evaluate this in .js threw me a lot of syntax errors. So I thought to tie it all in in a single "if"
but errors on syntax still appear:

if (in_mousebutton = 0)
SelectObj("happy_smile.Mixer.Default_pose_1st", null, null);
ApplyAction("happy_smile.Mixer.Default_pose_1st", null, null, null, null, null, null);
SelectMembers(null, null, null);
else
if (in_mousebutton = 2)
SelectObj("happy_smile.Mixer.smile_back", null, null);
ApplyAction("happy_smile.Mixer.smile_back", null, null, null, null, null, null);
SelectMembers(null, null, null);

I can´t seem to tie If - else (if) - else (if) in .js.
I know this must be something not really complicated for you Tiago, and just like
I said before, I´ll credit you on the video about synoptic pages i´m making.

Thank you for all your help on this!
David.

User avatar
sirdavid32
Posts: 309
Joined: 10 Feb 2010, 04:36
Location: Ecuador
Contact:

Re: Recognizing right / middle and left mouse click in synoptic

Post by sirdavid32 » 16 Sep 2010, 23:33

I found out softimage it´s only allowing 1 call per "if"

if (in_mousebutton==1)
{ this happens;
}

...But when I need to invoque 2 ACTIONS to be applied like this:

else if (in_mousebutton==2)
{ this ACTION happens;
this ACTION happens also;
}

Softimage only fulfills the first call to apply the first action, not the second one.
IS there anything in particular to execute an "apply action" from mixer consecutively?
(apply action1 and also action2 when I middle click)?

User avatar
Hirazi Blue
Administrator
Posts: 5107
Joined: 04 Jun 2009, 12:15

Re: Recognizing right / middle and left mouse click in synoptic

Post by Hirazi Blue » 17 Sep 2010, 11:17

Merely a forum related suggestion (not a rule or anything :D ):
you could use the Code tags to highlight the code in your posts.
This would result in the following (for the code in your last post)...

Code: Select all

if (in_mousebutton==1)
 { this happens;
  }
...But when I need to invoque 2 ACTIONS to be applied like this:

Code: Select all

else if (in_mousebutton==2)
 { this ACTION happens;
    this ACTION happens also;
  }
Making it instantly obvious, what is to be considered code and what not... ;)
Stay safe, sane & healthy!

User avatar
mattmos
Posts: 445
Joined: 02 Dec 2009, 16:59

Re: Recognizing right / middle and left mouse click in synoptic

Post by mattmos » 17 Sep 2010, 12:34

sirdavid32 wrote:I solved the reset actor like this:

function Reset_ALL(in_obj)
{
SelectObj("Rig.Animable_Ctrls", null, null);
SelectMembers(null, null, null);
Translate(null, 0, 0, 0, siAbsolute, siPivot, siObj, siX, null, null, null, null, null, null, null, null, null, 0, null);
Translate(null, 0, 0, 0, siAbsolute, siPivot, siObj, siY, null, null, null, null, null, null, null, null, null, 0, null);
Translate(null, 0, 0, 0, siAbsolute, siPivot, siObj, siZ, null, null, null, null, null, null, null, null, null, 0, null);

Rotate(null, 0, 0, 0, siAbsolute, siPivot, siObj, siX, null, null, null, null, null, null, null, 0, null);
Rotate(null, 0, 0, 0, siAbsolute, siPivot, siObj, siY, null, null, null, null, null, null, null, 0, null);
Rotate(null, 0, 0, 0, siAbsolute, siPivot, siObj, siZ, null, null, null, null, null, null, null, 0, null);

DeselectAll();
}
I'm sure this works, but if you wanted another way to reset the actor, you could try using an action source - saving out the default srts of the model into a default_pose action. You can then reset the whole actor or just the selected part based on this clip. The advantage of doing this is that you don't have to have all the controllers zeroed completely. Have a look at the softimage example synoptic.

User avatar
sirdavid32
Posts: 309
Joined: 10 Feb 2010, 04:36
Location: Ecuador
Contact:

Re: Recognizing right / middle and left mouse click in synoptic

Post by sirdavid32 » 22 Sep 2010, 16:05

by "reseting just a part" from the same default_action_clip, you meant?

a) creating individual "default_pose_for_each_body_part"
b) invoking a script where it tells the default_pose_action_clip to be called for "this body part only"?

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests