Viewpoint Developer Central    Viewpoint Forums    Viewpoint Forums  Hop To Forum Categories  JavaScript    Javascript and VETScript data exchange

Moderators: e_phoenix13
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Junior Member
Posted
Hello,

we bought an Enliven Pro Licence and we are currently testing data exchange between Javascript (HTML) and VETScript (mtx). We have not yet found a possibility to pass parameters from Javascript to VETScript. Reviewing the documentation didn’t help.

We want to apply interactive changes to a model (size, textures) using HTML-controls. Until now, we could accomplish this only by creating VETScript dynamically from Javascript. This is somewhat cumbersome.

Please find attached a simple example of our efforts.

Could you give us a hint how to pass user input e.g. input text/html to VETScript?

Thank you in advance.

This message has been edited. Last edited by: MrBool,

Zip/GZ archivecube.zip (8 KB, 27 downloads)
 
Posts: 4 | Registered: March 12, 2007Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of Admin
Posted Hide Post
There is a VETScript keyword you can pass to the Execute method of the plugin:

vmp.Execute(‘VETScript( script )’);

Basically, whatever you pass as the script gets evaluated in VETScript, like eval in javascript, so it’s all a string, but you can do stuff like this:

vmp.Execute(‘VETScript(myFunc(‘+arg+’);’);


or perhaps more accurately:

vmp.Execute(‘VETScript(myFunc(“‘+arg+’”);’);
 
Posts: 1188 | Registered: January 08, 2003Reply With QuoteEdit or Delete MessageReport This Post
Junior Member
Posted Hide Post
Thank you for your quick response!

Could you please provide an example, how to define 'myFunc' and parameter handling in mtx?
Below the code we tried for dynamically creating VETScript from Javascript.

Thank you in advance.

--- HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<script language="javascript" src="MTS3Interface.js"></script>
<script language="javascript">
<!--

var vmp; //This global variable is for the VET content

function postevent(name, param)
{
vmp.PostEvent(name,param);
}

function Resize()
{
var value = document.getElementById('size').value;

if (value !='')
{
vmp.ExecuteVETScript("MTSInstances.Cube.Scale.x="+value+";");
}
}

//-->

</script>
</head>

<body>
<script language="javascript">
vmp = new MTSPlugin("cube.mtx", 400, 400, "", "simple",'');
</script>

<form>
<input type="text" name="size" />
<input type="button" name="CubeResize" value="Resize" onclick="javascript:Resize();"/>
<!--input type="button" name="CubeResize" value="Resize" onclick="javascriptRazzostevent('CubeResize',0);"/-->
</form>

</body>
</html>

--- MTX

<?xml version="1.0"?>
<MTSScene Version="330" >

<MTSSceneParms RenderMode="LightTexture" BlendShadow="1" EdgeBias="1" SortRule="0" ActiveCamera="MtsRuntimeCamera" />
<MTSCamera Name="MtsRuntimeCamera" CameraRotateMin="-10000.000187 -10000.000187 -10000.000187" CameraRotateMax="10000.000187 10000.000187 10000.000187" CameraScaleMin="0.01 0.01 0.01" CameraScaleMax="1000 1000 1000" OrbitDist="5" >
<Rotate x="30" y="-332" z="0" />
<Pivot x="0" y="0.55573" z="0" />
<ViewLocation x="0" y="0" z="4" />
</MTSCamera>

<MTSInstance Name="Cube" >
<MTSGeometry Name="MTSSimple_0" MultiUV="0" Type="MTSCube"/>
</MTSInstance>


<MTSTimeElem Type="VETScriptInterpreter"/>

<MTSAction Type="VETScript" Name="CubeResize">
<!--
//MTSInstances.Cube.Scale.x=3;
-->
</MTSAction>


<MTSInteractor>
<MTSHandle Event="CubeResize" Action="CubeResize" />
</MTSInteractor>

</MTSScene>
 
Posts: 4 | Registered: March 12, 2007Reply With QuoteEdit or Delete MessageReport This Post
Junior Member
Posted Hide Post
Anybody is still alive here?
 
Posts: 4 | Registered: March 12, 2007Reply With QuoteEdit or Delete MessageReport This Post
EnIgMaTiCScOrPioN
Member
Picture of e_phoenix13
Posted Hide Post
Hi !!

Do you want your VET script inside the HTML code and not inside the MTX? If yes, your HTML script looks good. Just that you need no VET script written inside the MTX file. You just need the VETScriptListner.

I modified your code and the modified files are attached.

Hope this helps.


Cheers,

Anup

Zip/GZ archivecube_mod.zip (8 KB, 53 downloads)
 
Posts: 557 | Location: India | Registered: February 12, 2003Reply With QuoteEdit or Delete MessageReport This Post
  Powered by Eve Community  
 

Viewpoint Developer Central    Viewpoint Forums    Viewpoint Forums  Hop To Forum Categories  JavaScript    Javascript and VETScript data exchange