Max geometry esporter in C#

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  12 December 2011
Question Max geometry esporter in C#

Hi, my problem is to make a tool that exports large files (about 20MB), i already made it with maxscript but the heapsize increase untill 100MB, the script is very slow and if i want add a Edit_Normal modifier i must wait about 10 min !!!
I noticed that using C# or esternal .dll can do very fast the same operations... so i decided to learn c#, I'm still a novice but I think I understand how it works; I don't want use C/C++... isn't a simple language for my purpose.
I already use dotnet into maxscript: http://forums.cgsociety.org/showthr...05&page=2&pp=15 to use an esternal dll decompressor.

My purpose is to delegate exporting geometric data (which slows a lot) with a esternal c# code, and write with maxscript only other simple data and value, because i already made some function like name sorting, texture name ecc...

I watch this tutorial http://vimeo.com/11191227 and i installed autodesk_max1_2_8_0_offline_install.exe for max2011 32bit
But i need help to understand how to pass a editable_mesh's node into c# and found the maxscript's function like: getNormal , getVerts , getFace etc....
using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using Autodesk.Max;
 using Autodesk.Max.Plugins;
 
 namespace Gamelibrary
 {
 	public class GeometryEsporter
 	{
 		static string WriteGeometryData (INode tmesh ; FileIOType fout)
 		{
 			/*  write faces, vertex , normals , tangents , binormals , uvw , vcolor to
 			 *  fout but with fout = open "mydgamedata.mesh" "wb" passed in maxscript
 			 */
 		   return "OK"
 		}
 	}
 }
 


Thanks anyway for your interest , I believe that this example can be very useful to "break the ice" with max > .NET scripts
 
  12 December 2011
Visual C#:
namespace Gamelibrary
 {
 	using System;
 	using System.Diagnostics;
 	using System.Runtime.InteropServices;
 	using System.IO;
 
 	using Autodesk.Max.Plugins;
 
 	public class GeometryEsporter
 	{
 		public string WriteGeometryData (INode tmesh)
 		{
 			return tmesh.Name;
 		}
 	}
 }
 

Maxscript:
(
 clearListener()
 local ScriptDir = getFilenamePath (getSourceFileName())
 local dll = dotnet.loadAssembly @"C:\Documents and Settings\Admin\Documenti\Visual Studio 2010\Projects\ClassLibrary1\ClassLibrary1\ClassLib  rary1.dll"
 local esp = dll.createInstance("Gamelibrary.GeometryEsporter")
 showMethods esp
 showProperties esp
 result = esp.WriteGeometryData $
 print result
 )


a simple:
public string WriteGeometryData (string nome) {return nome;}

work but this return:
-- result: undefined
-- Runtime error: No method found which matched argument list

How can i pass one node or node selection to work with them ? and why i must load Autodesk.Max.dll ? i must compile it for each existing version of 3dstudio ?
 
  12 December 2011
if you're going to go to that kind of trouble just cut out the middle man altogether, write it as a export plugin using c++. lots of examples in the SDK, pretty easy really. you can even use a proper step by step debugger if you have problem with your code.
 
  12 December 2011
Unhappy

Originally Posted by claude666: if you're going to go to that kind of trouble just cut out the middle man altogether, write it as a export plugin using c++. lots of examples in the SDK, pretty easy really. you can even use a proper step by step debugger if you have problem with your code.


i think c++ sdk is the only solution, why don't exist some simple example for C# (without always a plugin derived...)? is a simple language.
 
  12 December 2011
The C# library you're using is "simply" a wrapper for the SDK. So the C++ examples you'll find in the SDK will largely apply to your library too.
 
  12 December 2011
I would start by posting your maxscript version and trying to understand why it's so slow. It doesn't sound like a 20MB file should take that long to export.
 
  12 December 2011
Originally Posted by lo: I would start by posting your maxscript version and trying to understand why it's so slow. It doesn't sound like a 20MB file should take that long to export.


i'm agreed with lo. it can't be so slow...
 
  12 December 2011
I think a script I found that exports the data to XAML did it in only a few seconds or something with a filesize of around that.

http://blogs.microsoft.co.il/blogs/...rom-3d-max.aspx
 
  12 December 2011
Originally Posted by denisT: i'm agreed with lo. it can't be so slow...


Thanks for interest :-) , so:
this is my work : http://www.twcenter.net/forums/down...do=file&id=3311
I have to manage files with more than 1 million of vertices (world files of 20 MB) what required about 1-2 minutes to import and export and increase the heapsize about to 90 MB !!! (there are also two video what show this)
The maxscript version is optimized and work fast but not enough because:
1) for 2 milion of vertices (the bigger case with a 40 MB of file) i must wait 5-6 minutes
2) i disabled the Edit_Normal modifier creation, increse the time to x20 !!! so i can't save normals but isn't important.
3) menage and build some fast algorithm to work with vertex list in maxscript isn't possible, example for Lzo decompression (http://forums.cgsociety.org/showthr...05&page=2&pp=15) i add two function to delegate all array's operation, and maxscript thanked mewithout increase heapsize and with x10 time fast XD!!!

But the issue:
I know a little C#, the essential , isn't difficult for my purpose... some little difference with C, but when i saw the tutorial my head exploded T_T, the .Net version is more appreciated for my little brain !

On internet there aren't ONE tutorial or source code for a simple mesh esporter... i wan't plugin extension because the tool must work without problem for a lot of 3dstudio's version (max9 to max2012... max2013 isn't a problem : the world end ) and because i don't want save dll into plugin folders.
 
  12 December 2011
can you post just the code for the exporter? those are some huge scripts and will take people time to locate your exact code.
 
  12 December 2011
Originally Posted by lo: can you post just the code for the exporter? those are some huge scripts and will take people time to locate your exact code.


if the community is interested we can organize some sort of brain-storming: HOW TO DO IT FAST AND MEMORY SAFE
my guess is for 10,000,000 verts the export of faces, vert positions, vert uvw, verts normals has to be about ~20-30 secs using just pure mxs solution...
 
  12 December 2011
Originally Posted by denisT: if the community is interested we can organize some sort of brain-storming: HOW TO DO IT FAST AND MEMORY SAFE


WHAT AN WONDERFUL IDEA!
 
  12 December 2011
Quote: if the community is interested we can organize some sort of brain-storming: HOW TO DO IT FAST AND MEMORY SAFE
my guess is for 10,000,000 verts the export of faces, vert positions, vert uvw, verts normals has to be about ~20-30 secs using just pure mxs solution...


make it "next gen" and add binormals, tangents, second uv's and vertex colour.
 
  12 December 2011
Originally Posted by claude666: make it "next gen" and add binormals, tangents, second uv's and vertex colour.

i think it's a good idea... you will show us how to get vertex tangent.
 
  12 December 2011
easy, do it as a plugin.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 03:26 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.