Notifications
Clear all

[Closed] Detect maximized viewport

I feel that you won’t find anything in the SDK because this is a functionality that extends 3dsMax build-in stuff.

The way I would probably going to approach a problem like yours, without any use of SDK etc would be:
I would have three arrays, one for the modifiers, one for the modifierStacks and one for the objects.

modifiers: This array, would store all the scene modifiers.
modifierStacks: In this array I would store subArrays with modifiers
Objects: And finally, in this array, I would store all the dependences between an object and the modifierStack/modifiers

[EXAMPLE]
modifiersAr = #(bend, twist, turbosmooth1, turbosmooth2, cloth)
modifierStacksAr = #(stack1, stack2)
stack1 = #(bend, turbosmooth1)
stack2 = #(twist, turbosmooth2)
objectsAr = #( obj1, obj2, obj3, obj4, obj5 )
obj1 = #(stack1, cloth)
obj2 = #(stack2, cloth)
obj3 = #(bend, twist, turbosmooth2)
obj4 = #()
obj5 = #(turbosmooth1, cloth)

At this point, you need a lot of callbacks in order to check, if a modifiers was deleted, if an object was deleted, to check if the modifiers on an object are synced with your objectsAr etc.

Hope that helps,
-Nick

 JHN

Not sure I agree, looking through the docs I find these pages:
Geo Pipeline and IDeriveObject.

Ephere Zookeeper can only leverage the SDK (the only thing exposed from ADSK) via the dotnet wrapper. So I think it should be possible, check again the zookeeper link I put up with the schematic from zookeeper (bottom page). The IDerivedObject holds the references to the modifers, which makes it basically a stack. If we can move and instance stacks around that would be really powerful as layering stacks over multiple objects becomes very easy all of a sudden.

But that’s just theory offcourse

~Johan

So if I understood right, the IDerivedObject, is basically a modifiers group, (I saw it has methods such as addModifier, deleteModifier etc) and then you can stack these IDerivedObjects, on INodes?! If this is possible, it sounds really interesting!

If you see the INode though, it doesn’t have any methods to add IDerivedObjects. The only relevant methods are GetWSMDerivedObject() and CreateWSMDerivedObject().

Nick

 JHN

I don’t think that INode provides ways, because the IObjectReference results in INode not the other way around. You derive from Object via getref see this

I have been looking add various sources, but it takes a lot of time for this stuff to make sense to me

~Johan

P.s. Also found this book from David Lanier (I think he’s even employed by ADSK now)

Don’t worry, all these concepts are new to me too.

Neither the Object Class Reference has any method that hints the possibility to have more than one IDerivedObjects.

Nick

P.S. Yes, I have seen the book, but I never had the guts to read it. You should also check (if you haven’t already) the http://www.autodesk.com/develop3dsMax . In the “Learning” paragraph, they have two great “Video based Tutorials”. Check them out.

 JHN

I think an IDerivedObject can have an IDerivedObject as input, so you can basically stack stacks. In the max UI when you reference an object and reference that object too, the last object pipeline looks like:
baseObject->IDerivedObject1->IDerivedObject2->IDerivedObject1->INode
I think this piece of code explains some bits and pieces:


/** Creates a DerivedObject from object. If object is a DerivedObject, a derived object using the same base
	object and the same modifiers is created. If not, a derived object with object as base object is created 
	(not modifiers are assigned in this case)*/
	IDerivedObject* createDerivedObject( Object* object)
	{
		IDerivedObject* createdDerivedObject = 0;
		if ( (object->ClassID() == derivObjClassID) || (object->ClassID() == WSMDerivObjClassID) )
		{
			Object* baseObject = object;

			// Modifiers are applied to the object, acquire the base object
			while ( baseObject->SuperClassID() == GEN_DERIVOB_CLASS_ID )
			{
				IDerivedObject * derivedObject = ( IDerivedObject* ) baseObject;
				baseObject = derivedObject->GetObjRef();
			}

			// Object is a derived object
			IDerivedObject* derivedObject = (IDerivedObject*) object;

			createdDerivedObject = CreateDerivedObject(baseObject);

			for ( int i = 0, count = derivedObject->NumModifiers(); i < count; ++i )
			{
				createdDerivedObject->AddModifier(derivedObject->GetModifier( i ));
			}
		}
		else
		{
			// Create the derived object for the target and the modifier
			createdDerivedObject = CreateDerivedObject(object);
		}
		return createdDerivedObject;
	}


Source

~Johan

hm, that makes sense since in the Pipeline overview under the “Reference Copies” paragraph it says, “Note that the object reference of the new Derived Object points to the original Derived Object.” IDerived is a object so I suppose that you can hook it up using the ReferenceObject.
So the first thing it would be to find out is how to create a IDerived object. I’ve tried through MXS and I didn’t make it. Didn’t found any constructors, properties, methods etc for the “Autodesk.Max.Plugins.IDerivedObject” eventhough, all the methods and the properties are exposed in the Dll.

Unfortunately I don’t have a Workstation at home, so I can only do some tests on my lunch break at work. I did some tests today and I came up with this:


gbl = (dotNetClass "Autodesk.Max.GlobalInterface").instance --Get the GlobalInterface
myNode = gbl.coreInterface.RootNode.GetChildNode 0 --Select the first object in scene (INode)
myObject = myNode.ObjectRef --Get its object (IObject)
 
myDerivedObj = gbl.CreateDerivedObject myObject --Create a derived object
bendCid = gbl.Class_ID.Create 16 0 --Get Bends Class_ID
bendObj = gbl.COREInterface14.CreateInstance (dotNetClass "Autodesk.Max.SClass_ID").Osm bendCid --Create a bend "Autodesk.Max.Wrappers.OSModifier"
myDerivedObj.AddModifier bendObj undefined 0 --AddModifier expects (Autodesk::Max::IModifier^ mod, Autodesk::Max::IModContext^ mc, int before)

Using sample code from this example, I’ve tried to create a bend modifier and add it to the IDerived that I’ve added to the first scene object.
I have two problems though, the first one is that in the example he uses “as IModifier” in order to convert the OSModifier to IModifier (something I don’t know how to do it with MXS) and the second that I haven’t even tried to create the object for the second object (IModContext).

Hope that helps,
Nick

Page 3 / 3