Re: *.obj sequence import?

Date : Mon, 31 Mar 2008 20:01:54 +0100
To : "XSI(at)Softimage.COM" <XSI(at)Softimage.COM>
From : Juan Brockhaus <juanb(at)the-mill.com>
Subject : Re: *.obj sequence import?
Hi,

this is a script I've written which imports an obj sequence as shape-animation.

Don't have the time to rewrite at the moment, but it's pretty straight forward to make it work to set visibility keys.

change .lalala to .js

Hope that helps,

Cheers,

Juan




Tim Leydecker wrote:
Hi guys,

I´m using an animated texture to create 3D geometry in zBrush,
sort of like using a push op, rename the resulting geometry:

Skin_tex.###.OBJ

then want to import that into XSI 6.5 and animate obj visibility
based on the *.obj number, like skin_tex.001.obj visible only
on frame one, stepped curve.

The resulting effect looks close to the X-Men effect, with
that desk where those cubes scale into a city.

There´d be more efficient ways to do this than via ZBrush
but I´m testing this to see wether it is possible to create
actual 3D geometry that disintegrates nicely - without using realflow.

I had done that once allready with ZBrush2 but the geometry
popped like crazy, due to pivots not lining up on export
(which I can´t influence unfortunately).

Ultimately, it might be useful to log it a feature request
with Pixologic.

Cheers

tim





Steven Caron wrote:
my obj drag and drop plugin will import multiple obj files, assuming you
have at least v6.5

so put them all in a folder, ctrl+a, drag and drop into the interface.

s

On Mon, Mar 31, 2008 at 10:24 AM, Tim Leydecker <baueroink(at)gmx.de> wrote:

Hi there,

is there a way of importing an *.obj sequence into XSI,
other than manually doing so?

I have a series of sculpted shapes I´d like to import,
then have their visibility keyed based on the naming,
like myobject.001.obj visible only on frame one and so on?

This calls for a script I guess...

Cheers

tim


--- Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body: unsubscribe xsi


--- Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body: unsubscribe xsi
// *************************************************
// name:		import_objs_as_shape_animation.js
// author:	Juan P. Brockhaus
// *************************************************
// import objs as shape animation
// *************************************************
// usage:	run script
// 				select folder, copy/paste filename
//				select sequence length
// *************************************************



// *************************************************
// *************************************************


//define variables
var scn_root = Application.ActiveProject.ActiveScene.Root

LogMessage ("...");
LogMessage ("Starting script...");
LogMessage ("...");

Main_Function();

DeselectAll();

LogMessage ("...");
LogMessage ("bye,...");
LogMessage ("...");

// *************************************************
// *************************************************



// *************************************************
// main sub
// *************************************************

function Main_Function()
{


	//open dialog for input
	if(dialog_input() == -1)
		return;


	//evalaute obj_name
	var tmp_name = obj_name.slice( 0, (obj_name.length-4) );
	var tmp_splitted = tmp_name.split(".");
	var tmp_obj_name = tmp_splitted[0].split("\\");

	var new_obj_name = tmp_obj_name[ tmp_obj_name.length-1 ];
	var folder_name = tmp_splitted[0].slice( 0, (tmp_splitted[0].length - new_obj_name.length) );

	//LogMessage(obj_name);
	//LogMessage(tmp_name);
	//LogMessage(folder_name);
	//LogMessage(new_obj_name);


	// import objs
	var import_obj = new Array;
	var n = 0;

	for(i=start_frame; i<=end_frame; i++)
	{
		import_obj[n] = ObjImport(folder_name + new_obj_name +"." + i + ".obj", 1, 0, true, true, false, true)(0);
		n++;
	}


	// dup object, freeze and delete all clusters	
	var dup_obj = Duplicate(import_obj[0], null, 2, 1, 1, 0, 0, 1, 0, 1, null, null, null, null, null, null, null, null, null, null, 0)(0);
	dup_obj.Name = new_obj_name + "__shapeplot";
	FreezeObj(dup_obj, null, null);

	if(dup_obj.ActivePrimitive.Geometry.Clusters.Count != 0)
	{
		DeleteObj( dup_obj + ".cls.*");
	}


	//create shapekeys
	for(i=0; i<n; i++)
	{
		SetValue("PlayControl.Current", i+1, null);

		SelectShapeKey(dup_obj, import_obj[i], siShapeObjectReferenceMode, false, true);
	}

	DeleteObj( import_obj );

	SetValue("PlayControl.Current", 1, null);

}
// *************************************************





// *************************************************
// dialog for input
// *************************************************
function dialog_input( cam_array, cam_count, current_pass_cam )
{

	//Dialog for input

	//generate temporary Property with Parameter
	var my_prop = scn_root.AddProperty ("Custom_parameter_list", false, "Input_Property");

	var obj_name_param = my_prop.AddParameter2( "obj_name", siString, "", null, null, null, null, 0, 4, "Object Name");
	var start_frame_param = my_prop.AddParameter2( "start_frame", siInt2, 1, 1, 1000, 1, 100, 0, 4, "Start");
	var end_frame_param = my_prop.AddParameter2( "end_frame", siInt2, 100, 1, 1000, 1, 100, 0, 4, "End");
	var step_frame_param = my_prop.AddParameter2( "step_frame", siInt2, 1, 1, 999, 1, 99, 0, 4, "Step");


	//build gui of property
	var my_ppglayout = my_prop.PPGLayout;
	my_ppglayout.AddGroup(" obj file ");
	var obj_name_item = my_ppglayout.AddItem("obj_name", "", siControlFilePath);
	obj_name_item.SetAttribute( siUIInitialDir, "project" );
	obj_name_item.SetAttribute( siUIFileFilter, "obj files (*.obj)|*.obj|All Files (*.*)|*.*|" );
	obj_name_item.SetAttribute( siUIOpenFile, true );
	my_ppglayout.EndGroup();

	my_ppglayout.AddGroup(" Frames ");
	my_ppglayout.AddItem("start_frame");
	my_ppglayout.AddItem("end_frame");
	my_ppglayout.AddItem("step_frame");
	my_ppglayout.EndGroup();

	my_ppglayout.AddGroup(" Usage ");
	my_ppglayout.AddStaticText(" select one obj-file and set the timerange ");
	my_ppglayout.AddStaticText(" sequence has to have NO leading zeros padding ");
	my_ppglayout.EndGroup();


	my_ppglayout.Logic = 		start_frame_OnChanged.toString()
												+ end_frame_OnChanged.toString();
	my_ppglayout.Language = "JScript";



	//open dialog
	try
	{
		var inspect_obj = InspectObj( my_prop, "", "Gimmy some input!", siModal); 
	}
	catch(e)
	{
		DeleteObj( my_prop );
		LogMessage ("...");
		LogMessage ("Script aborted...");
		LogMessage ("...");
		return(-1);
	}

	// store input data
	obj_name = obj_name_param.value;
	start_frame = start_frame_param.value;
	end_frame = end_frame_param.value;
	step_frame = step_frame_param.value;

	DeleteObj( my_prop );

}
// *************************************************





// *************************************************
// function to check end_frame < start_frame
// *************************************************
function start_frame_OnChanged()
{
	var tmp_startframe = PPG.Inspected(0).Parameters.Item("start_frame").Value;
	var tmp_endframe = PPG.Inspected(0).Parameters.Item("end_frame").Value;

	if (tmp_endframe < tmp_startframe)
		{
			PPG.Inspected(0).Parameters.Item("end_frame").Value = tmp_startframe;
			PPG.Refresh();
		}
}
// *************************************************




// *************************************************
// function to check end_frame < start_frame
// *************************************************
function end_frame_OnChanged()
{
	var tmp_startframe = PPG.Inspected(0).Parameters.Item("start_frame").Value;
	var tmp_endframe = PPG.Inspected(0).Parameters.Item("end_frame").Value;

	if (tmp_endframe < tmp_startframe)
		{
			PPG.Inspected(0).Parameters.Item("start_frame").Value = tmp_endframe;
			PPG.Refresh();
		}
}
// *************************************************


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.