Viewpoint Developer Central    Viewpoint Forums    Viewpoint Forums  Hop To Forum Categories  JavaScript    Waiting for Object to Load

Moderators: e_phoenix13
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Member
Posted
How can I wait for an object to load after using LoadMTX... I need to wait so I can assign properties to the object.
 
Posts: 48 | Registered: April 17, 2006Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of Admin
Posted Hide Post
Shawn,

Put this at the end of the mtx being loaded just before the closing </scene> tag:

<MTXDoneEvent Data="myFileDone" />

Then use an interactor in the main mtx file to pick up the event:

<MTSInteractor Name="someinteractor" >
<MTSHandle Event="myFileDone" Action="someaction" />
</MTSInteractor>
 
Posts: 1188 | Registered: January 08, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Posted Hide Post
hmmm... what I need to do is set a dynamic name to the object after it is done loading. This seems like a very hard thing to accomplish using the above method.
 
Posts: 48 | Registered: April 17, 2006Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of Admin
Posted Hide Post
Using the above method, you can pick up the MTXDoneEvent and then assign a new name to the object:

<MTXDoneEvent Data="myFileDone" />

<MTSInteractor Name="someinteractor" >
<MTSHandle Event="myFileDone" Action="MTSAssignProperty" Target="MTSInstance.myInstance.name" Value="myName" />
</MTSInteractor>
 
Posts: 1188 | Registered: January 08, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Posted Hide Post
How can I set what that name is going to be from javascript?
 
Posts: 48 | Registered: April 17, 2006Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of Admin
Posted Hide Post
Sorry, Shawn, I thought you already got our answer to that. (see http://viewpoint.infopop.cc/eve/forums?a=tpc&f=3632...921097971#2921097971)
 
Posts: 1188 | Registered: January 08, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Posted Hide Post
I got that post but I need to wait for it to load then set the name to a custom name from the Javascript.
 
Posts: 48 | Registered: April 17, 2006Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of Admin
Posted Hide Post
Ok,

So then when you get the event in the mtx from the MTXDoneEvent, you can call a javascript function to rename:

In MTX:

<MTXDoneEvent Event="myDoneEvent" />

<MTSInteractor Name="myInteractor" >
<MTSHandle Event="myDoneEvent" Action="MTSJavaScript" Func="myFunction()" /> --- (this would be your javascript function to rename the instance)
</MTSInteractor>

In Javascript:

function myFunction(){
vmp.SetProperty('MTSInstance.myInstance','name',myName,'mts_str');
}
 
Posts: 1188 | Registered: January 08, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Posted Hide Post
ok... I put the following MTX into the object being loaded for testing

<MTXDoneEvent Event="myDoneEvent" />

<MTSInteractor Name="myInteractor" >
<MTSHandle Event="myDoneEvent" Action="MTSJavaScript" Func="testFunc()" />
</MTSInteractor>

then i made the function testFunc() in the .js file used on the page where the VMP is located. When the object is loaded nothing happens.
 
Posts: 48 | Registered: April 17, 2006Reply With QuoteEdit or Delete MessageReport This Post
EnIgMaTiCScOrPioN
Member
Picture of e_phoenix13
Posted Hide Post
Hi Shawn !!

Attached is a sample file. When you see the code, you will see that the original name of the object is OldName. But after the scene loads, click on the Show Name button and you see the name has already been changed to NewName.

Hope this helps.

Cheers,

Anup

Zip/GZ archiveName_Change.zip (9 KB, 19 downloads)
 
Posts: 557 | Location: India | Registered: February 12, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of Admin
Posted Hide Post
Shawn,

You will notice in Anup's example that the MTXDoneEvent tag should be written with Data instead of Event like so:

<MTXDoneEvent Data="myDoneEvent" />

Sorry for the confusion
 
Posts: 1188 | Registered: January 08, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Posted Hide Post
ok well i am trying to use your code... I basically copied your exact code and added it to the bottom of my MTX file like so:
 <MTSTimeElem Type="MTSStream"  Name="test"  Path="new_school.mts" >
		<Target Name="MTSInstance.wheel_replace_me" />
	</MTSTimeElem>

	<MTSInteractor Name="newInt" >
		<MTSHandle Event="myDoneEvent" Action="MTSJavaScript" Func="nameFunction();" />
	</MTSInteractor>




<MTXDoneEvent Data="myDoneEvent" />
</MTSScene> 


then i copied your javascript function and put it in the HTML file where the VMP variable is

 function nameFunction(){
alert("TRIGGERED LOAD");
} 


Nothing happens... suggestions?
 
Posts: 48 | Registered: April 17, 2006Reply With QuoteEdit or Delete MessageReport This Post
Member
Posted Hide Post
I think i found the problem... this method does not work when using the LoadMTX function?
 
Posts: 48 | Registered: April 17, 2006Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of Admin
Posted Hide Post
Hi Shawn,

Here's a working example for you.

Regards.

Zip/GZ archivemtsloadmtx_doneEvent_test.zip (118 KB, 29 downloads)
 
Posts: 1188 | Registered: January 08, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Posted Hide Post
awsome... that last example put me on the right track. for anyone in the future the way to get this to work with loadMTX is to put this part in the main.mtx, the project you first load

<MTSInteractor Name="wheelSetupInt" >
<MTSHandle Event="wheelLoaded" Action="MTSJavaScript" Func="setupWheel();" />
</MTSInteractor>

then you just put this part in the object you want to call that action

<MTXDoneEvent Data="wheelLoaded" />
 
Posts: 48 | Registered: April 17, 2006Reply With QuoteEdit or Delete MessageReport This Post
Member
Posted Hide Post
Also, thanks again Anup for all the great help.
 
Posts: 48 | Registered: April 17, 2006Reply With QuoteEdit or Delete MessageReport This Post
Junior Member
Posted Hide Post
This seems like a similar discussion topic to the issues I am having. I created animations of American Sign Language using motion capture data then exported them to Viewpoint. They generally work great, but I don't like how they load. First the hair appears, then the avatar appears below the hair. Often the animations start before the avatar is finished loading. I could insert additional frames in the animation with no actual motion, but it seems like there must be a better way.
Here is my sample animation:
Alligator

Any suggestions?
 
Posts: 2 | Location: Stephen F. Austin State University | Registered: February 16, 2007Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of Admin
Posted Hide Post
Scott,

Go to the XML Database and search for MTSEventCollection. Also do a search here in forums for the same thing.

Regards
 
Posts: 1188 | Registered: January 08, 2003Reply With QuoteEdit or Delete MessageReport This Post
  Powered by Eve Community  
 

Viewpoint Developer Central    Viewpoint Forums    Viewpoint Forums  Hop To Forum Categories  JavaScript    Waiting for Object to Load