Home Unreal Engine

Exporting Pivots from Maya to UDK

polycounter lvl 10
Offline / Send Message
SirCalalot polycounter lvl 10
Hi all,

Sorry to create another thread on .fbx exporting, but I thought I'd pose you a query:

I have my environment blocked out in Maya and plan to export it into UDK as an .fbx file.
Now I know that I'll have to go through and manually delete and replace all of my instanced objects, (-_-) but I was wondering if anyone knew of a way to centre the pivot of each static mesh based on its Maya pivot?

As it stands, each mesh has its exported pivot at the origin - which kind of defeats the object of being able to import them all under one file if I'm being honest.

Is there a check box I'm missing? There appears to be no documentation that I can find on the subject and I'm hoping that I won't have to go through and manually place every object back at the origin before exporting them all one-by-one.

Help me Polycount, you're my only hope.

Replies

  • passerby
    Options
    Offline / Send Message
    passerby polycounter lvl 12
    i just made a mel script that does a batch export of my objects, and moves them to 0 0 0 before export and puts them back after.

    pretty simple thing to make.
  • SirCalalot
    Options
    Offline / Send Message
    SirCalalot polycounter lvl 10
    A very good idea!
    Would that still work for objects moved from the origin and had 'Freeze Transformations' applied?
    Or does it work on World-space values rather than object-space?
  • passerby
    Options
    Offline / Send Message
    passerby polycounter lvl 12
    doesn't matter if transformations are frozen or not.
    global proc UDKexport() {
    	string $selection[] = `ls -sl`;
    	string $thisObj;
    	string $presetpath = `internalVar -usd` + "UDK-FBX.fbxexportpreset";
    	FBXLoadExportPresetFile -f $presetpath;
    	int $selsize = size($selection);
        
    	if ($selsize == 0) {
    		warning("Nothing is Selected");
    	}
    	else {
    		for ($thisObj in $selection) {
    		select $thisObj;
    		$OrginalLoc = `xform -q -piv -ws`;
    		centerObj($thisObj);
    		doexport($thisObj);
    		move -r $OrginalLoc[0] $OrginalLoc[1] $OrginalLoc[2] $thisObj;
    		}
    	}
    }	
    
    // Center Object in Scene
    global proc centerObj(string $objSelection){
            select -r $objSelection;
            makeIdentity -apply true -t 1 -r 1 -s 1 -n 0;
            $Pos = `xform -q -piv -ws`;
            move -a  (-1 *  $Pos[0]) (-1*$Pos[1] ) (-1*$Pos[2]) ;
    }
    
    //Start Export
    global proc doexport(string $selExport) {
    	string $extension = ".fbx";
    	string $ExportPath;
    	string $rootdir = `workspace -q -rd`;
    	$ExportPath = ($rootdir + "data/" + $selExport + $extension);
    	select $selExport;
    	FBXExport -f $ExportPath -s;
    }
    

    you will prolly want to edit it to your liking, since it currently chooses the export path based on the active project in maya.

    can toss that in your scripts folder, with the name "UDKexport.mel", and make a shelf button with "UDKexport();" and it should work for you.

    edit: also forgot it requires a fbx preset be made name it "UDK-FBX.fbxexportpreset" and also put it in your scripts folder.
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    I had an FBX batch Exporter I posted a while back. Its similar to Passerby's haha and also reminds me I need to re-do some stuff.
  • passerby
    Options
    Offline / Send Message
    passerby polycounter lvl 12
    ya i was using your script before i made that, i wanted to get rid of any reliance on a UI or needing to setup the path, and i always use projects in maya, so i made that.
  • SirCalalot
    Options
    Offline / Send Message
    SirCalalot polycounter lvl 10
    Thanks to the both of you!
    I'll have a bash at using it when I'm back home next week :D

    Edit: Hmm, I wonder if there is a way to make the script ignore objects that are instanced?
  • passerby
    Options
    Offline / Send Message
    passerby polycounter lvl 12
    prolly possible, i will look into how sometime in the next day or 2.

    that is prolly easier in max since it;s easier to tell a instance from a object, but i should be able to check for rednundent shape data, and not export those ones.
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    string $objects[] = `listRelatives -allParents $shapeNode`;
    if (size($objects)>1){
           //Do whatever you want with the parent or instances. Parent is $objects[0]
    }
    

    Hope that helps. I'll try and see if I can get it incorporated in my FBX Exporter.
  • SirCalalot
    Options
    Offline / Send Message
    SirCalalot polycounter lvl 10
    Legend.
    I can't wait to try this out.
  • passerby
    Options
    Offline / Send Message
    passerby polycounter lvl 12
    @haiddasalami how exactly would that code work, if i just wanted to exclude instances, from being exported?
  • SirCalalot
    Options
    Offline / Send Message
    SirCalalot polycounter lvl 10
    You know, I still haven't tried this out yet.
    I'm moving house over the next week or two, so things are going to be a bit hectic before I manage to give your methods a blast, guys.
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Hey sorry didnt see an update to the thread. Ill post later/edit this post with code to get it working :D
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    global proc stupidMayaGlobals(){
    
    //Getting Selection
    string $sel[] = `ls -sl`;
    
    //Declaring outside loop so I can access it later
    string $objects[];
    
    //Cycle through selection
        for ($object in $sel){
            //Get shape node of current
           string $shapes[] = `listRelatives -shapes -path $object`;
           //Get parents of shape node
           $objects = `listRelatives -allParents $shapes[0]`;
        }
        
        //If size of the array is greater than 1, its instanced
        if(size($objects)>1){
               //Our original Mesh
               print $objects[0];
        }
    }
    
    stupidMayaGlobals();
    
  • SirCalalot
    Options
    Offline / Send Message
    SirCalalot polycounter lvl 10
    Well, I finally got to a point in my project where I am exporting and so far so good!
    You guys have been a massive help :D

    Now, to see what they look like the other end in UDK...
Sign In or Register to comment.