PDA

View Full Version : Need some help with building a mesh from an obj.


dbmata
10-16-2006, 06:58 AM
Hey folks,
I'm in the middle of learning mel, and I'm having a hard time finding resources to find out how to read from an external file.

So here is the idea:
I want to create a mel script that will take a .obj file from a directory of obj files, and build a mesh from the info held within the .obj. Then, in the rest of my script I'm planning to have the ability to build 3 types of objects from the associated obj files, randomize their size, and their position in X,Z. The type of mesh generated from the obj files will be based on user input from a window.

So, I've been able to track down fread, but I can't figure out how to get fread to read from a folder, let alone to build a mesh from obj data.

I'm also leaning toward having the folder added into the scripts folder in the maya 7.0 folder found in the particular user's my docs. Any suggestions?



Here is a simplistic version of a user interface window I plan on starting with:


window -t "GeneratorScript" -tb true -rtf true -w 300;

rowColumnLayout -numberOfColumns 4;

button -label "Make Rock" -rs true -command "makeRock";
button -label "Make Bush" -rs true -command "makeBush";
button -label "Make Tree" -rs true -command "makeTree";
button -label "Delete All" -rs true -command "deleteAll";

showWindow;

Robert Bateman
10-16-2006, 11:13 AM
file -import "somefile.obj"

assuming you have the obj export plugin loaded

dbmata
10-19-2006, 12:03 AM
file -import "somefile.obj"

assuming you have the obj export plugin loaded

Thanks Robert. I'm coming up against a small problem now, and I think it's due to my relative newness to mel... but I haven't been able to figure out how to get the script to open a file in another folder.

Suggestions? I wanted to get it from something like C:\scripts\somefile.obj

Thanks.
Dave

ashishdantu
10-19-2006, 04:04 AM
hi dbmata,

u can try this:


string $filePath="C:/whatever/whateverDocs/Desktop/tingobj.obj";
file -import $filePath;
// change the above $filePath to what ever is ur required file path


-rgds,

sparaig
10-19-2006, 08:05 AM
Hey folks,
I'm in the middle of learning mel, and I'm having a hard time finding resources to find out how to read from an external file.

[/CODE]


I'm a big fan of:



global proc fileCallback(string $fileName,string $type)
{
print($fileName +"\n");
}

fileBrowser( "fileCallback", "buttonMessage", "", 0 );

so that you can see how directories and files are described in MEL on your system. It also makes for a nice generic file open interface...

CGTalk Moderation
10-19-2006, 08:05 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.