Designing a Webpage with JavaScript to control MAYA (Part I)
You can design and create your own webpages to control MAYA the way you want. Webpage can be used as a User Interface for MAYA users to use and control your MAYA assets (such as rigs, particles and even ASCII or Binary assets which are stored on the database server). With Web 2.0, the web has becoming very friendly and creative with it's ability to support technologies such as AJAX, CSS, JAVASCRIPT, XML, etc; making it more dynamic and giving it endless room for project development.
Following is a sample tutorial which uses JAVASCRIPT and MEL to interact with MAYA.
<html>
<head>
<title>Create Spheres in MAYA</title>
</head>
<SCRIPT language="JavaScript" type="text/javascript" SRC="MayaWebTools.js"></SCRIPT>
<SCRIPT language="javascript" type="text/javascript">
function create_sphere(){
var noOfSphere = document.getElementById('sphereID').value;
if (isNaN(parseInt(noOfSphere))){
alert("You have entered an invalid number");
}else{
MWT_Execute("polySphere -r 1 -sx 6 -sy 6 -ax 0 1 0 -cuv 2 -ch 1;"); // pSphere1 polySphere1 //
if(parseInt(noOfSphere) > 1){
MWT_Execute("duplicate -rr;"); // Result: pSphere2 //
MWT_Execute("move -r 0 0 3;"); // Move the duplicated sphere2\
for(var x = 2; x< parseInt(noOfSphere); x++){
MWT_Execute("duplicate -smartTransform;"); // pSphere3... pSphereX //
}
}
}
}
</SCRIPT>
<body onload="MWT_Embed('MCP','commandportDefault');">
<H1>Create Spheres in MAYA</H1>
<form id="form1" name="form1" method="post" action="">
<p>No of Spheres you wish to create:
<input name="sphereID" type="text" id="sphereID" size="2" maxlength="2" />
</p>
<p>
<input type="button" value="Create" onmouseup="create_sphere();"/>
</p>
</form>
</body>
</html>
Save this html with the MayaWebTools.js ( can be found in MAYA_INSTALLED_DIR/ExternalWebBrowser/Examples/OtherBrowser ) in the same folder.
Click on page 2 to see how the Webpage will look like.
DEMO PAGE: Click here |
|
COMMENTS: If you have any enquiry, please comment or feedback here. |
|
RELATED TOPIC: How to design your own webpage to control Maya in vbscript? Prerequisites: HTML, VBScript, MEL |
Chris Chia