Exporting to .obj in Maya 2012 and textures and materials desappear in Prefab2

Software: Prefab3D

Mar, Newbie
Posted: 27 May 2013 09:09 AM   Total Posts: 29   [ # 16 ]

Hi Fabrice,

Thanks a lot, I wish I could send you the files for you to help me more in this, but I don’t think my company will allow me to send you the files…
Is there any way I can change the name of each geometry in Prefab without the rest changing too? I just saw the new Away3d release 4.1.1Alpha and it seems to have many posibilities for customizing the materials by code is AS, so i’ll try to do that by code then. I will export each and every part of my car separately (paint, rubber, glass,..) and the instances as well, and make those in as to save time to the compiler. But I really need to be organized or it will be a complete mess to try to figure out what piece is what if I can’t give it an appropiate name in Prefab. My Maya names seem to disappear.

   

Avatar
Fabrice Closier, Administrator
Posted: 27 May 2013 09:49 AM   Total Posts: 1265   [ # 17 ]

There is a nasty bug regarding renaming that I’m after. Hope next update will fix it. The work around for now, is to load all, save. quit Prefab and load the project. then rename, if you have lots of meshes to rename, I would suggest that if your names are similar, like wheel1, wheel2, that you save in between successfull renaming.
I’m sorry this bug is still alive…

   

Mar, Newbie
Posted: 28 May 2013 08:21 AM   Total Posts: 29   [ # 18 ]

It’s okey, it seemed to be confusing the items names with the layers names, that’s why I had EXT1, EXT2,... instead of FrontDoor_Body, RearBumper,... so I just broke (undid) all the nodes in Window>Hypergraph:Connections by clicking the item and drag them out of the tree scheme in Maya2012 and exported with OBJ and import3D in Prefab and it worked, all the names seem to be right in Prefab now, so I don’t have to change anything by hand in Prefab with is even more tedious.

Again thanks a lot for your help, keep the good work with Prefab. It helped a lot! THANKS!!!!

   

Avatar
Fabrice Closier, Administrator
Posted: 28 May 2013 10:05 AM   Total Posts: 1265   [ # 19 ]

Ah good, nice to hear that it works now!

   

Mar, Newbie
Posted: 28 May 2013 11:13 AM   Total Posts: 29   [ # 20 ]

Oh, one last thing smile)

“You can access the wheel by looping over the class.meshes, and you could mirror by code. The 4.1 version of the Mirror class has been improved, so you could save on data size…”

How can I code this in my As main file? Let’s say I want to make a mirror by code of my wheel.as file inside my main.as file. I included it but how can I give it the instructions to mirror it? Do I have to give them coordinates or can I simply code to mirror from coordinates x0,y0,z0? I’ve been looking for an example online but none seem to be clear. I don’t know a lot of as and all seem to be so complicated.

Thanks!

   

Avatar
Fabrice Closier, Administrator
Posted: 28 May 2013 12:06 PM   Total Posts: 1265   [ # 21 ]

“all seem to be so complicated.”
may be it seems, but by actually trying you would see it’s pretty easy.

in speudo code
loop over yourPrefabClass.meshes
  if (yourPrefabClass.meshes[indexloop].name == “theNameOfTheWheelMeshThaTIWantToMirror”)

var myWheel:Mesh = yourPrefabClass.meshes[indexloop];
var mirror:Mirror = new Mirror();
mirror.apply(myWheel, Mirror.X_AXIS, Mirror.CENTER, 0);

where X_AXIS, Y and Z define the axis to mirror on
where Mirror.MAX_BOUND define if the mirror starts on the biggest vertice value along the define axis or Mirror.MIN_BOUND the smallest. Or if you use Mirror.CENTER you want to mirror on the axis at world 0.

duplicate will ensure you get a new mirrored mesh of have teh mirror be part of the wheel mesh. In your case, means having 2 independant front wheels meshes and one rear axle mesh.

I could type a lot more to explain, but its so self explainatory, you should first try then eventually ask for help if you get stuck.
Just make a simple test class, add the Trident to see the axises, and play with settings.

   

Mar, Newbie
Posted: 29 May 2013 08:24 AM   Total Posts: 29   [ # 22 ]

Wow, thanks a LOT man! This was exactly what I was looking for!! I was trying to find and example online of mirror.apply or some more info, but I didn’t find anything. And thanks a lot too for the explanation.

I tried coding this in my PaintInstance.as file (not in my main.as, am i right?). I have to make an if statement inside a for loop? Inside a private function, right?:

public class PaintInstance extends ASBase
{
  private function Mirror(): void
  {
    for (PaintInstance.meshes)
    {
      if (PaintInstance.meshes[indexloop].name == “Hood_Cover”, “sideclosures_mainbodytop”, “fender_bodypart”,...) //Can I add here with comas a list of all the meshes of PaintInstance.as I want to mirror? or do i have to do this for each and every mesh separately? In [indexloop], do I have to make an array of all the meshes in the file, rather I mirror them or not? or should I just leave it the way it is? I tried it but it doesn’t work.
      {
 
          var Hood_Cover:Mesh = PaintInstance.meshes[indexloop];
          var mirror:Mirror = new Mirror ();
          mirror.apply(Hood_Cover, Mirror.X_AXIS, Mirror.CENTER, 0);
      }
    }
  }
}

Sorry to bug you with this once again, I know it must take a lot of pacience to explain to someone who doesn’t know how to program, sorry, but you are like my angel guard, THANKS SOOOO much for your help

   

Avatar
Fabrice Closier, Administrator
Posted: 29 May 2013 08:35 AM   Total Posts: 1265   [ # 23 ]

If you want to mirror “lots” of meshes, just insert a switch statement in the class.meshes loop, and have a dedicated mirror function in the switch cases, where you could for instance push a stack of mirror commands.

like

switch(mesh.name){
  case “myWheel”:
    doMirror(mesh, [ xmax, zmin ] );

   

Mar, Newbie
Posted: 29 May 2013 03:54 PM   Total Posts: 29   [ # 24 ]

But what do I have to susbtitute here? I don’t know as, so do I susbtitute “mesh” for each and every mesh I have in my various models, ...

What does “myWheel” correspond to? My models (PaintInstance and/or MainBodyInstance) or the meshes inside of them? Do I have to do this with every model, inside the model.as? Do I have to substitute name for something, indexloop or mesh? or mesh… and most importantly WHERE do I write this code? In my main.as or inside my models .as?

Where do I insert the switch statement? Inside the for loop, inside the if statement, ....?

I don’t know how to apply this examples you show me, I’m just getting more and more confused, sorry. I’m so new with all this and even programming…

   

Avatar
Fabrice Closier, Administrator
Posted: 29 May 2013 05:10 PM   Total Posts: 1265   [ # 25 ]

The “where” to is actually your job smile its pretty much coder’s choice.
but If I would do it, I would keep the classes exported untouched, because if you do and you need to rexport for some reasons, you will have to update all by hand again. So I would, and again, all depends how you setup your logic in your project keep it in the class that you use to instanciate the class, probably in a dedicated method to keep it clean and easy to maintain in the future.

the “mywheel”
I gave you 3 lines of pseudo code.
in the first there is your answer. wink  switch (mesh.name)
This mesh name is shown in Prefab, you can change it if you want to.

“Do I have to do this with every model, inside the model.as?”
If you are a mirror freak and want to mirror all day long, is up to you smile
The example shows you that if you have more meshes to mirror
that you can use a switch statement. if you have only one wheel to mirror,
simply do if(mesh.name == “mywheel”) doMirror
Generally when you mirror wheels, you often have a half car body, 2 interior sits, half dashboard etc… hence the proposed switch. An if else statement would do same job.
Because you mirror, does say you have to do something with every meshes.
all depends how your model looks like and what is your goal.

Imagine your class holds 10 meshes, 2 requires mirror and 1 a transform
your switch would then look like this

switch(mesh.name)
case “wheel”:
  doMirror(mesh);
case “car_body”:
  doMirror(mesh);

case “steeringWheel”:
  mesh.x = 100;

only these 3 would be affected all others ignored, untouched.

“I’m so new with all this and even programming…”
We’ve all been there, so no need to worry about that. What I do know
is that 3d is very complex, even if Away makes it’s accessible to everyone,
your programming skills will not progress until you try yourself.
I would recommand you make a standalone class, import and addChild the class, implement the loop and play around (a lot). Follow the tuts, run the demo classes etc..
You will then be able to test things, see for yourself what they do and
implement the “good parts” in your project.

If you have issues, post your away errors or problems.
Please consider that this forum is made for away3d and related,
it’s not a generic AS3 forum.

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X