Пример #1
0
Bool VoxelGenerator::Init(GeListNode* node)
{
	BaseObject*		 op = (BaseObject*)node;
	BaseContainer* data = op->GetDataInstance();
	
	data->SetFloat(VGEN_SCALE, 0.95);
	data->SetFloat(VGEN_THRESHOLD,0.01);
	return true;
}
Пример #2
0
Bool Objectify::Init(GeListNode *node)
{
    BaseObject    *op   = (BaseObject*)node;
    BaseContainer *data = op->GetDataInstance();
    
    data->SetReal(TRIANGULATION_MAX_SEARCH_RADIUS,30.);

    GePrint("Objectify by http://twitter.com/eight_io for Cinema 4D r14");
    prevFrame = 0;
    return TRUE;
}
Пример #3
0
Bool Voxelify::Init(GeListNode *node)
{
	BaseObject		*op   = (BaseObject*)node;
	BaseContainer *data = op->GetDataInstance();
    
	//data->SetReal(CTTSPOBJECT_MAXSEG,1000.);
	//data->SetReal(CTTSPOBJECT_MINSEG,0.1);
    data->SetLong(SPLINEOBJECT_INTERPOLATION,SPLINEOBJECT_INTERPOLATION_ADAPTIVE);
    GePrint("Voxelify by http://twitter.com/eight_io for Cinema 4D r14");
    
    return TRUE;
}
Пример #4
0
// initialize settings
Bool AtomObject::Init(GeListNode *node)
{
	BaseObject		*op		= (BaseObject*)node;
	BaseContainer *data = op->GetDataInstance();

	data->SetReal(ATOMOBJECT_SRAD,5.0);
	data->SetReal(ATOMOBJECT_CRAD,2.0);
	data->SetLong(ATOMOBJECT_SUB,8);
	data->SetBool(ATOMOBJECT_SINGLE,FALSE);

	return TRUE;
}
Пример #5
0
Bool DropEffector::InitEffector(GeListNode* node)
{
	if (!rcol || !node)
		return false;

	BaseObject* op = (BaseObject*)node;
	if (!op)
		return false;

	BaseContainer* bc = op->GetDataInstance();
	if (!bc)
		return false;

	bc->SetFloat(DROPEFFECTOR_DISTANCE, 1000.0);

	return true;
}
Пример #6
0
Bool VoxelGenerator::Message(GeListNode* node, Int32 type, void* t_data)
{
	switch(type)
	{
	case MSG_DESCRIPTION_COMMAND:
		{
			DescriptionCommand *dc = (DescriptionCommand*)t_data;

			/* Handle Candidate button */
			FXAPI::FXServer *server = FXAPI::FXServer::Get(node->GetDocument());
			if(!server) break;

			BaseObject* op = (BaseObject *)node;
			//Effex Scene BaseObject interface from the link field
			BaseObject* scene = op->GetDataInstance()->GetObjectLink(VGEN_SCENE, node->GetDocument());

			if(dc->id[0].id==VGEN_CHANNEL_SELECTOR && scene)
			{
				//Get the Effex Scene node which should contain the scalar channel
				FXAPI::FXScene* effex_scene = server->GetEffexScene(scene); 
				if(!effex_scene) break;

				/* Create a list of scalar channels that are already in the scene that the user may want to use.
				We use GetNodes to search the scene for channels */
				std::vector<FXAPI::FXBase*> items;
				FXAPI::GetNodes(effex_scene,NULL,items,FXAPI::NodeRetrieveType_ScalarChannel);

				/* Create a list of compatible channel types (for the candidate buttons "Create.." submenu) */
				FXAPI::FXTypeInfos t_types;
				t_types.push_back(FXAPI::FXTypeInfo(EFFEX_CHANNEL_SCALAR,"Scalar Channel")); //The naming part is only for safe-guarding
				
				/* Pass all the info to the Candidate button Popup */
				BaseObject *op = (BaseObject*)node;
				FXAPI::OpenCandidatePopup(false,items,t_types,op,VGEN_CHANNEL,false,true,0);
				return true;
			}
		}
		break;
	}
	return ObjectData::Message(node,type,t_data);
}
Пример #7
0
/// ***************************************************************************
/// This function recursive hides or unhides a node and all its following
/// nodes in the same hierarchy level and below object manager and timeline.
/// Only direct children are hidden or revealed, no other branches.
/// @param[in] root The node to start with.
/// @param[in] hide \c true if the hierarchy should be hidden, \c false
///     if it should be revealed by this function.
/// @param[in] doc The BaseDocument to add undos to, if desired. Pass
///     \c nullptr if no undos should be created.
/// @param[in] sameLevel If \c true (default), all objects following *root*
///     in the hierarchy will also be processed by this function.
/// ***************************************************************************
static void HideHierarchy(BaseList2D* root, Bool hide, BaseDocument* doc, Bool sameLevel=true)
{
  while (root)
  {
    if (doc)
      doc->AddUndo(UNDOTYPE_BITS, root);
    const NBITCONTROL control = (hide ? NBITCONTROL_SET : NBITCONTROL_CLEAR);
    root->ChangeNBit(NBIT_OHIDE, control);
    root->ChangeNBit(NBIT_TL1_HIDE, control);
    root->ChangeNBit(NBIT_TL2_HIDE, control);
    root->ChangeNBit(NBIT_TL3_HIDE, control);
    root->ChangeNBit(NBIT_TL4_HIDE, control);
    root->ChangeNBit(NBIT_THIDE, control);
    root->DelBit(BIT_ACTIVE);

    Bool hideChildren = true;
    if (root->IsInstanceOf(Obase))
    {
      BaseObject* op = static_cast<BaseObject*>(root);
      BaseContainer* bc = op->GetDataInstance();
      CriticalAssert(bc);

      if (bc->GetString(CONTAINEROBJECT_PROTECTIONHASH).Content())
        // Don't modify the hierarchy of "protected" Null-Objects.
        hideChildren = false;
      else if (ContainerIsProtected(op))
        // Don't modify the hierarchy of protected Containers.
        hideChildren = false;
    }

    if (hideChildren)
      HideHierarchy(static_cast<BaseList2D*>(root->GetDown()), hide, doc);

    if (!sameLevel) break;
    root = root->GetNext();
  }
}
Пример #8
0
Bool LiquidToolData::MouseInput(BaseDocument* doc, BaseContainer& data, BaseDraw* bd, EditorWindow* win, const BaseContainer& msg)
{
	Float mx = msg.GetFloat(BFM_INPUT_X);
	Float my = msg.GetFloat(BFM_INPUT_Y);
	Int32 button;

	switch (msg.GetInt32(BFM_INPUT_CHANNEL))
	{
		case BFM_INPUT_MOUSELEFT: button	= KEY_MLEFT; break;
		case BFM_INPUT_MOUSERIGHT: button = KEY_MRIGHT; break;
		default: return true;
	}

	BaseObject* cl = nullptr, *null = nullptr, *op = nullptr;
	Float				dx, dy, rad = 5.0;
	Bool				newmeta = false;

	op = BaseObject::Alloc(Osphere);
	if (!op)
		return false;

	null = BaseObject::Alloc(Ometaball);
	{
		null->GetDataInstance()->SetFloat(METABALLOBJECT_SUBEDITOR, 10.0);
		null->MakeTag(Tphong);
	}
	newmeta = true;

	if (newmeta)
	{
		doc->InsertObject(null, nullptr, nullptr);
		doc->SetActiveObject(null);

		doc->AddUndo(UNDOTYPE_NEW, null);

		DrawViews(DRAWFLAGS_ONLY_ACTIVE_VIEW | DRAWFLAGS_NO_THREAD | DRAWFLAGS_NO_ANIMATION);
	}

	BaseContainer bc;
	BaseContainer device;
	win->MouseDragStart(button, mx, my, MOUSEDRAGFLAGS_DONTHIDEMOUSE | MOUSEDRAGFLAGS_NOMOVE);
	while (win->MouseDrag(&dx, &dy, &device) == MOUSEDRAGRESULT_CONTINUE)
	{
		bc = BaseContainer();
		win->BfGetInputEvent(BFM_INPUT_MOUSE, &bc);
		if (bc.GetInt32(BFM_INPUT_CHANNEL) == BFM_INPUT_MOUSEWHEEL)
		{
			rad += bc.GetFloat(BFM_INPUT_VALUE) / 120.0;
			rad	 = ClampValue(rad, (Float) 0.1, (Float) MAXRANGE);
			GePrint(String::FloatToString(rad));
		}

		if (dx == 0.0 && dy == 0.0)
			continue;

		mx += dx;
		my += dy;
		cl	= (BaseObject*)op->GetClone(COPYFLAGS_0, nullptr);
		if (!cl)
			break;

		cl->GetDataInstance()->SetFloat(PRIM_SPHERE_RAD, rad);

		cl->SetAbsPos(bd->SW(Vector(mx, my, 500.0)));
		cl->InsertUnder(null);
		DrawViews(DRAWFLAGS_ONLY_ACTIVE_VIEW | DRAWFLAGS_NO_THREAD | DRAWFLAGS_NO_ANIMATION);
	}

	if (win->MouseDragEnd() == MOUSEDRAGRESULT_ESCAPE)
	{
		doc->DoUndo(true);
	}

	BaseObject::Free(op);

	EventAdd();
	return true;
}
Пример #9
0
BaseContainer *ObjectDataM::GetDataInstance(GeListNode *node)
{
	BaseObject		*op   = (BaseObject*)node;
	BaseContainer *data = op->GetDataInstance();
	return data;
}
Пример #10
0
// go through every (child) object
static Bool Recurse(HierarchyHelp *hh, BaseThread *bt, BaseObject *main, BaseObject *op, const Matrix &ml, Real srad, Real crad, LONG sub, Bool single)
{
	// test if input object if polygonal
	if (op->GetType()==Opolygon)
	{
		BaseObject *tp   = NULL;
		PolyInfo	 *pli  = NULL;
		const Vector *padr = ToPoly(op)->GetPointR();
		Vector pa,pb;
		LONG       pcnt  = ToPoly(op)->GetPointCount(),i,side,a=0,b=0;
		const CPolygon *vadr = ToPoly(op)->GetPolygonR();
		LONG       vcnt  = ToPoly(op)->GetPolygonCount();
		Matrix     m;
		Neighbor	 n;

		// load names from resource
		String		 pstr = GeLoadString(IDS_ATOM_POINT);
		String		 estr = GeLoadString(IDS_ATOM_EDGE);

		// initialize neighbor class
		if (!n.Init(pcnt,vadr,vcnt,NULL)) return FALSE;

		// create separate objects
		// if this option is enabled no polygonal geometry is build - more parametric objects
		// are returned instead
		if (single)
		{
			for (i=0; i<pcnt; i++)
			{
				// alloc sphere primitive
				tp=BaseObject::Alloc(Osphere);
				if (!tp) return FALSE;

				// add phong tag
				if (!tp->MakeTag(Tphong)) return FALSE;
				tp->SetName(pstr+" "+LongToString(i));

				// set object parameters
				BaseContainer *bc = tp->GetDataInstance();
				bc->SetReal(PRIM_SPHERE_RAD,srad);
				bc->SetReal(PRIM_SPHERE_SUB,sub);

				// insert as last object under main
				tp->InsertUnderLast(main);

				// set position in local coordinates
				tp->SetRelPos(padr[i]*ml);
			}

			for (i=0; i<vcnt; i++)
			{
				// get polygon info for i-th polygon
				pli = n.GetPolyInfo(i);

				for (side=0; side<4; side++)
				{
					// only proceed if edge has not already been processed
					// and edge really exists (for triangles side 2 from c..d does not exist as c==d)
					if (pli->mark[side] || side==2 && vadr[i].c==vadr[i].d) continue;

					// alloc cylinder primitive
					tp=BaseObject::Alloc(Ocylinder);
					if (!tp) return FALSE;

					// add phong tag
					if (!tp->MakeTag(Tphong)) return FALSE;

					switch (side)
					{
						case 0: a=vadr[i].a; b=vadr[i].b; break;
						case 1: a=vadr[i].b; b=vadr[i].c; break;
						case 2: a=vadr[i].c; b=vadr[i].d; break;
						case 3: a=vadr[i].d; b=vadr[i].a; break;
					}

					tp->SetName(estr+" "+LongToString(pli->edge[side]));

					pa = padr[a]*ml;
					pb = padr[b]*ml;

					// set object parameters
					BaseContainer *bc = tp->GetDataInstance();
					bc->SetReal(PRIM_CYLINDER_RADIUS,crad);
					bc->SetReal(PRIM_CYLINDER_HEIGHT,Len(pb-pa));
					bc->SetReal(PRIM_AXIS,4);
					bc->SetLong(PRIM_CYLINDER_CAPS,FALSE);
					bc->SetLong(PRIM_CYLINDER_HSUB,1);
					bc->SetLong(PRIM_CYLINDER_SEG,sub);

					// place cylinder at edge center
					tp->SetRelPos((pa+pb)*0.5);

					// build edge matrix
					m.v3=!(pb-pa);
					RectangularSystem(m.v3,&m.v1,&m.v2);
					tp->SetRelRot(MatrixToHPB(m, tp->GetRotationOrder()));

					// insert as last object under main
					tp->InsertUnderLast(main);
				}
			}
		}
		else
		{
			// check if polygonal geometry has to be built
			tp = BuildPolyHull(ToPoly(op),ml,srad,crad,sub,hh->GetLOD(),&n,bt);

			if (tp)
			{
				tp->SetName(op->GetName());
				tp->InsertUnderLast(main);

				// check if isoparm geometry has to be built
				if (hh->GetBuildFlags()&BUILDFLAGS_ISOPARM)
				{
					LineObject *ip = BuildIsoHull(ToPoly(op),ml,srad,crad,sub,hh->GetLOD(),&n,bt);

					// isoparm always needs to be set into a polygon object
					if (ip) tp->SetIsoparm(ip);
				}
			}
		}
	}

	for (op=op->GetDown(); op; op=op->GetNext())
		if (!Recurse(hh,bt,main,op,ml*op->GetMl(),srad,crad,sub,single)) return FALSE;

	// check for user break
	return !bt || !bt->TestBreak();
}