Announcement

Collapse
No announcement yet.

Material name in .vrscene

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Material name in .vrscene

    Can V-Ray Scene Exporter name materials in .vrscene based on they name in host application?

    I'm converting some scenes from 3ds Max to Maya. There is no problem with converting geometry (via .fbx) and materials (via .vrscene) separately. But there is a problem with assigning converted materials to converted geometry properly.

    Maybe it will be a good idea to write some kind of script that will write out to disk material-object links from 3ds Max and than will replicate those links in Maya. Based on object and material names.

    Thank You.
    Last edited by iTiunov; 22-06-2011, 11:42 PM.
    Ivan Tiunov
    Red Screw + Production

  • #2
    Sorry again. I've checkd .vrscene file. There are correctly named materials and objects there. So I'll try to parse this file to extract needed info into Maya...

    I was confused by "Import V-Ray material from file" command in Maya that names materials like "material0, material1, etc...".
    Ivan Tiunov
    Red Screw + Production

    Comment


    • #3
      string $basicFilter = "*.vrscene";
      string $fileNames[] = `fileDialog2 -fileFilter $basicFilter -fileMode 1 -dialogStyle 2`;
      $fileId = `fopen $fileNames[0] "r"`;
      string $nextLine;
      string $buffer[];
      int $number, $count;
      string $brdfName[];
      string $objectName;
      $nextLine = `fgetline $fileId`;
      $count = 0;

      while (size($nextLine) > 0)
      {
      $numTokens = `tokenize $nextLine "/: " $buffer`;
      if ($buffer[0] == "MtlSingleBRDF")
      {
      $buffer[0] = "NULL";
      $count ++;
      $number = `substring $buffer[1] 9 12`;
      $brdfName[$number] = $count - 1;
      //print ("V-Ray: " + $number + " Maya:" + $count + "\n");
      }

      if ($buffer[0] == "Node")
      {
      $buffer[0] = "NULL";
      $objectName = startString($buffer[1], size($buffer[1]) - 5);
      print ("Object: " + $objectName);
      $nextLine = `fgetline $fileId`;
      $nextLine = `fgetline $fileId`;
      $numTokens = `tokenize $nextLine "=" $buffer`;
      $number = `substring $buffer[1] 9 12`;
      //print (" Material: brdf" + $brdfName[$number] + "\n");
      select -r $objectName;
      hyperShade -assign ("brdf" + $brdfName[$number]);
      }

      $nextLine = `fgetline $fileId`;
      }

      fclose $fileId;


      1) Export 3ds Max scene to .fbx file;
      2) Export 3ds Max scene to .vrscene file;
      3) Import .fbx file into Maya. You need to turn of "Use namespaces";
      4) Import materials from .vrscene file. Create->V-Ray->Import V-Ray material from file;
      5) Run script and point it to .vrscene file;
      6) Wait.

      P.S. First test so be careful.
      P.P.S. Doesn't work with MultiSubObject materials. Need time to figure out how FBX handle this kind of materials.
      P.P.P.S. Was tested on some teapots.
      Last edited by iTiunov; 22-06-2011, 10:57 PM.
      Ivan Tiunov
      Red Screw + Production

      Comment


      • #4
        There is no to difficult to read VRayLight info from .vrscene too...
        Ivan Tiunov
        Red Screw + Production

        Comment


        • #5
          There is a problem with MultiSubObject. In Maya there is no material like this. Shaders a directly connected to specified faces. In .vrscene there is face_mtlIDs list that represents shader to faces connections. I'm wondering if face numbers are identical in .fbx and .vrscene...

          Investigating further...
          Ivan Tiunov
          Red Screw + Production

          Comment


          • #6
            Hello. In what format "face_mtlIDs = ListIntHex" are stored in .vrscene? I see what it is in Hex but I did some tests... For example an object containing 253 faces has 3864 digits in "face_mtlIDs = ListIntHex" string...

            Thanks...
            Ivan Tiunov
            Red Screw + Production

            Comment


            • #7
              Hello,

              There are two options in the translator: "write mesh data in hex format" and "compress", turn them off and you'll see the format.

              /Teodor
              V-Ray developer

              Comment


              • #8
                Thanks. I'll try.
                Ivan Tiunov
                Red Screw + Production

                Comment


                • #9
                  There is no this kind of options in export dialog. I'm exporting from 3ds Max.
                  Ivan Tiunov
                  Red Screw + Production

                  Comment


                  • #10
                    Hm,
                    You are correct that 3ds Max doesn't support exporting raw lists,
                    but it also doesn't use compression.

                    So if we have a list that looks like: ListInt(1,2,3)
                    We'll write it in HEX as: ListIntHex(010000000200000003000000)
                    Our Integer numbers are 32bit little endian.

                    And the algorithm is something like:
                    1. iterate the list
                    2. for every item: convert it to hex and write it in the buffer

                    If there is something unclear, ask and I'll try to answer you.

                    /Teodor
                    V-Ray developer

                    Comment


                    • #11
                      Thanks. MELing further...
                      Ivan Tiunov
                      Red Screw + Production

                      Comment


                      • #12
                        All clear. Thank You very much.

                        P.S. It will be useful to integrate my idea to "Import V-Ray material from file" menu item...
                        Last edited by iTiunov; 24-06-2011, 03:31 PM.
                        Ivan Tiunov
                        Red Screw + Production

                        Comment


                        • #13
                          Do V-Ray triangulates geometry before exporting .vrscene?

                          P.S. It seems that face_mtlIDs list in .vrscene has more elements than corresponding geometry exported from Max and imported to Maya via FBX.

                          Thanks.
                          Ivan Tiunov
                          Red Screw + Production

                          Comment


                          • #14
                            I found one more problem. It's crazy, but it seems that some objects are missing from .vrscene file. They are appear in 3ds Max and they are appear in Maya (after FBX export/import) with same names and same paths from scene root. But they are not appear in .vrscene...
                            Last edited by iTiunov; 24-06-2011, 04:38 PM.
                            Ivan Tiunov
                            Red Screw + Production

                            Comment


                            • #15
                              V-Ray definitely triangulates geometry before exporting .vrscene... Turning on triangulation in FBX export options resolves the problem.
                              Ivan Tiunov
                              Red Screw + Production

                              Comment

                              Working...
                              X