MoDynamics Rigid Body Global Positions
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/04/2010 at 17:14, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 11.528
Platform:
Language(s) : C++ ;---------
Hi everyone,
Is there any way to report and/or set the matrices of clones as they are effected by a MoDynamics RigidBody tag with C++? Is everything I need in c4d_baseeffectordata.h? A rigid body tag isn't really an effector, right, so I don't see how this class would work.
All I want for now is to report the positions of each clone as they move. The Xpresso MotionGraphic>MotionObjects>Data can report the positions of the top level objects in a cloner, but I'd like to get positions for objects even if they are allowed to fall apart using the "all" settings, i.e., if I have 3 Cubes as children of a clone, each with one child sphere, I want to print the correct global positions of all 6 objects whether the Tag>Collision>IndividualElements is set to Top Level, All, Second Level, etc.
Eventually, I'd like to be able to set positions as well.
I understand from previous threads that Global Matrices of clones altered by modynamics forces cannot be retrieved or set with Coffee. There is some chat that one can do this with C++. I've written a few C++ plugins, so I'm ready-ish, but I can't find any discussion of how to gain any access to MoDynamics, to Rigid Body Tags, to MoData, etc I'm guessing the commands to find a clone's position are more generic when in C++ and that I'd have to follow one of the Hair examples in the SDK to get something close.
Any pointers to appropriate threads or examples would be most appreciated.
Thanks,
Graham -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/04/2010 at 12:13, xxxxxxxx wrote:
Hi Folks,
Does the lack of response mean that finding the global matrices of clones effected by a MoDynamics force is easy and listed somewhere else or that its really difficult. I'd appreciate any insight.
Thanks again,
Graham -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/04/2010 at 14:34, xxxxxxxx wrote:
IMO it could work if you use the cache of the MoGraph cloner. The cache should give you an object with all the clones as child objects.
BaseObject *CacheParent = NULL; BaseObject *cloner = YourMoGraphCloner; if (!cloner) return FALSE; if (cloner->GetCache()) CacheParent = cloner->GetCache();
However, it is not sure that the cache is always valid. That depends on the type of your plugin and when it's being called. But it's worth a try.
Cheers,
Jack -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/04/2010 at 00:28, xxxxxxxx wrote:
Currently the transformation data of the MoDynamics can not be accessed directly. You have either get the current state of the object (Current State to Object command) or step through the cache when possible (in a shader for instance).
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/04/2010 at 10:16, xxxxxxxx wrote:
Jack and Matthias, thanks for the feedback.
I'm able to get the cache and see the correct number of points from my three default primitives I put into a cloner (without Current State To Object) using Jack's suggestion, but I can't get the positions. i've tried SendModeling commands many times with no success- mostly surprised that even if I send the command, I'm still not allowed to GetMg() on the return. The confused code below will print 0 for all of the y positions but successfully print 5, 288, 8, and 5 for a cloner with a pyramid, sphere, and cube set to linear 4 iterations... the latter does not require CurrentStateToObj.
I'm sure I've got my variables confused and would appreciate any suggestions.
Thanks again,
GrahamBaseObject *cloner = objCloner;
if (!cloner) return FALSE;
if (cloner->GetCache())
{
CacheParent = cloner->GetCache();
GePrint("Got Cache");DoRecursion(cloner);
}Bool gMoDynamicsPositions::DoRecursion(BaseObject *op)
{
BaseObject *tp = op->GetDeformCache();
// Bool r;
// r = tp->IsDirty(DIRTY_CACHE);
// GePrint("Is Dirty = " + RealToString(r));if (tp)
{
DoRecursion(tp);
}
else
{
tp = op->GetCache(NULL);
if (tp)
{
DoRecursion(tp);
}
else
{
if (!op->GetBit(BIT_CONTROLOBJECT))
{if (op->IsInstanceOf(Opolygon))
{
// --------------------------
// do whatever you want HERE
// --------------------------
ModelingCommandData cd;
//cd.doc = doc;
cd.op = op;
SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, cd);
if (!SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, cd)) return FALSE;
BaseObject* res = static_cast<BaseObject*>(cd.result->GetIndex(0));
Vector opPos;
opPos = res->GetPos();// this->GetParameter(DescID(ID_BASEOBJECT_POSITION:VECTOR_Y) );
GePrint("pos = " + RealToString(opPos.y) +"..."+ RealToString(ToPoly(op)->GetPolygonCount()) );
}
}
}
}
for (tp = op->GetDown(); tp; tp=tp->GetNext())
{
DoRecursion(tp);
}
return TRUE;
} -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/04/2010 at 01:42, xxxxxxxx wrote:
In what type of plugin and method is your code running? Remember that most of the times you are not allowed to use the cache.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/04/2010 at 01:51, xxxxxxxx wrote:
Hi Matthias,
The code is running in a menu plugin of the GeDialog class. I'm happy to run it from any hook, as long as I can eventually call it from Py4D to at least return the MoDynamics positions, and hopefully to set them before updating the scene and redrawing. We want to use this to calculate scoring functions for molecular dynamics trajectories.
Thanks,
Graham