Beispiel #1
0
INITRENDERRESULT SDKGradientClass::InitRender(BaseShader *sh, const InitRenderStruct &irs)
{
	BaseContainer *dat = sh->GetDataInstance();

	gdata.mode			 = dat->GetLong(SDKGRADIENTSHADER_MODE); 
	gdata.angle			 = dat->GetReal(SDKGRADIENTSHADER_ANGLE); 
	gdata.cycle			 = dat->GetBool(SDKGRADIENTSHADER_CYCLE);
	gdata.turbulence = dat->GetReal(SDKGRADIENTSHADER_TURBULENCE);
	gdata.octaves    = dat->GetReal(SDKGRADIENTSHADER_OCTAVES);
	gdata.scale      = dat->GetReal(SDKGRADIENTSHADER_SCALE);
	gdata.freq       = dat->GetReal(SDKGRADIENTSHADER_FREQ);
	gdata.absolute   = dat->GetBool(SDKGRADIENTSHADER_ABSOLUTE);
	gdata.gradient	 = (Gradient*)dat->GetCustomDataType(SDKGRADIENTSHADER_COLOR,CUSTOMDATATYPE_GRADIENT); 
	if (!gdata.gradient || !gdata.gradient->InitRender(irs)) return INITRENDERRESULT_OUTOFMEMORY;

	gdata.sa=Sin(gdata.angle);
	gdata.ca=Cos(gdata.angle);

	LONG i;
	GradientKnot *k;

	for (i=0; i<4; i++)
	{
		gdata.c[i]=0.0;
		k = gdata.gradient->GetRenderKnot(i); 
		if (k) gdata.c[i]=k->col; 
	}

	return INITRENDERRESULT_OK;
}
Bool PickObjectTool::MouseInput(BaseDocument* doc, BaseContainer& data, BaseDraw* bd, EditorWindow* win, const BaseContainer& msg)
{
	Int32						mode = data.GetInt32(MDATA_PICKOBJECT_MODE);
	Int32						x, y, l, xr = 0, yr = 0, wr = 0, hr = 0;
	Matrix4d				m;
	ViewportPixel** pix = nullptr;
	String					str;
	char ch[200];
	Bool ret = false;
	AutoAlloc<C4DObjectList> list;
	if (!list)
		return false;

	VIEWPORT_PICK_FLAGS flags = VIEWPORT_PICK_FLAGS_ALLOW_OGL | VIEWPORT_PICK_FLAGS_USE_SEL_FILTER;
	if (data.GetBool(MDATA_PICKOBJECT_ONLY_VISIBLE))
		flags |= VIEWPORT_PICK_FLAGS_OGL_ONLY_VISIBLE;
	x = msg.GetInt32(BFM_INPUT_X);
	y = msg.GetInt32(BFM_INPUT_Y);
	Float64 timer = 0.0;
	if (mode == MDATA_PICKOBJECT_MODE_CIRCLE)
	{
		Int32 rad = data.GetInt32(MDATA_PICKOBJECT_CIRCLE_RAD);
		timer = GeGetMilliSeconds();
		ret = ViewportSelect::PickObject(bd, doc, x, y, rad, xr, yr, wr, hr, pix, flags, nullptr, list, &m);
		timer = GeGetMilliSeconds() - timer;
	}
	else if (mode == MDATA_PICKOBJECT_MODE_RECTANGLE)
	{
		Int32 width	 = data.GetInt32(MDATA_PICKOBJECT_RECT_W);
		Int32 height = data.GetInt32(MDATA_PICKOBJECT_RECT_H);
		x -= width / 2;
		y -= height / 2;
		timer = GeGetMilliSeconds();
		ret = ViewportSelect::PickObject(bd, doc, x, y, x + width, y + height, xr, yr, wr, hr, pix, flags, nullptr, list, &m);
		timer = GeGetMilliSeconds() - timer;
	}
	if (ret)
	{
		sprintf(ch, "Picking region from (%d, %d), size (%d, %d)|", xr, yr, wr, hr);
		str += ch;
		for (l = 0; l < list->GetCount(); l++)
		{
			sprintf(ch, ", z = %.4f|", list->GetZ(l));
			str += "Found Object " + list->GetObject(l)->GetName() + ch;
		}
	}
	else
	{
		str	= "PickObject failed";
	}
	sprintf(ch, "|Time: %.2f us", float(timer) * 1000.0f);
	str += ch;

	DeleteMem(pix);
	GeOutString(str, GEMB_OK);

	return true;
}
Beispiel #3
0
 /// Called to hide/unhide the container object contents.
 void HideNodes(BaseObject* op, BaseDocument* doc, Bool hide)
 {
   if (hide)
   {
     BaseContainer* bc = op->GetDataInstance();
     CriticalAssert(bc != nullptr);
     HideHierarchy(op->GetDown(), true, doc);
     if (bc->GetBool(NRCONTAINER_HIDE_TAGS))
       HideHierarchy(op->GetFirstTag(), true, doc);
     if (bc->GetBool(NRCONTAINER_HIDE_MATERIALS))
       HideMaterials(op, true, doc);
   }
   else
   {
     HideHierarchy(op->GetDown(), false, doc);
     HideHierarchy(op->GetFirstTag(), false, doc);
     HideMaterials(op, false, doc);
   }
 }
Beispiel #4
0
void PaletteSubDialog::FromContainer(const BaseContainer &bc)
{
    Int32 i=0;
    m_showLabel    = bc.GetBool(++i);
    m_rows         = bc.GetInt32(++i);
    m_layout       = bc.GetInt32(++i);
    m_searchString = bc.GetString(++i);
    m_paletteID    = bc.GetInt32(++i);
    
    if(m_rowArea != NULL){
        SetInt32(m_rowArea, m_rows);
    }
    if(m_layoutArea != NULL){
        SetInt32(m_layoutArea, m_layout);
    }
    if(m_labelCheckArea != NULL){
        SetBool(m_labelCheckArea,m_showLabel);
    }
    if(m_searchText != NULL){
        SetString(m_searchText, m_searchString);
    }
    
    m_controlsShown = !m_showControls;
}
/*********************************************************************\
	Function name    : CDialogCustomElement::Save
	Description      :
	Created at       : 27.03.02, @ 14:54:04
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
Bool CDialogCustomElement::Save(BaseFile* pFile, String strFill)
{
    if (g_pCustomElements && m_lElement >= 0 && m_lElement < g_pCustomElements->Entries())
    {
        CustomProperty* pProp;

        CCustomElements* pElement = g_pCustomElements->GetItem(m_lElement);
        if (!pElement) return true;
        if (!m_pbcGUI) return false;
        BaseContainer* pBC = &m_pbcGUI[m_lElement];

        pProp = pElement->m_pProp;

        WriteString(pFile, pElement->m_pChResSym);
        WriteString(pFile, " ");
        WriteString(pFile, m_strControlID);
        LineBreak(pFile, strFill);

        WriteString(pFile, "{");
        LineBreak(pFile, strFill + *g_pstrFillSave);
        SaveAlignment(pFile);
        LineBreak(pFile, strFill);

        if (pElement->m_bIsOpen)
        {
            WriteString(pFile, *g_pstrFillSave);
            WriteString(pFile, "OPEN");
            WriteString(pFile, "; ");
            LineBreak(pFile, strFill);
        }

        Int32 i;
        for (i = 0; pProp && pProp[i].type != CUSTOMTYPE_END; i++)
        {
            Bool b = false;
            if (pProp[i].type == CUSTOMTYPE_FLAG)
            {
                if (pBC->GetBool(pProp[i].id))
                {
                    WriteString(pFile, *g_pstrFillSave);
                    WriteString(pFile, pProp[i].ident);
                    WriteString(pFile, "; ");
                    b = true;
                }
            }
            else if (pProp[i].type == CUSTOMTYPE_LONG)
            {
                WriteString(pFile, *g_pstrFillSave);
                WriteString(pFile, pProp[i].ident);
                WriteString(pFile, " ");
                WriteString(pFile, String::IntToString(pBC->GetInt32(pProp[i].id)));

                // XXX: BITMAPBUTTON SIZE is a CUSTOMTYPE_LONG property, yet it
                // requires a tuple for the SIZE parameter. Can we find a better
                // way than hardcoding this?
                // https://github.com/nr-plugins/resedit/issues/2
                if (String(pElement->m_pChResSym) == String("BITMAPBUTTON") &&
                        String(pProp[i].ident) == String("SIZE")) {
                    WriteString(pFile, ", ");
                    WriteString(pFile, String::IntToString(pBC->GetInt32(pProp[i].id)));
                }

                WriteString(pFile, "; ");
                b = true;
            }
            else if (pProp[i].type == CUSTOMTYPE_REAL)
            {
                WriteString(pFile, *g_pstrFillSave);
                WriteString(pFile, pProp[i].ident);
                WriteString(pFile, " ");
                WriteString(pFile, String::FloatToString(pBC->GetFloat(pProp[i].id)));
                WriteString(pFile, "; ");
                b = true;
            }
            else if (pProp[i].type == CUSTOMTYPE_STRING)
            {
                if (pBC->GetString(pProp[i].id).Content())
                {
                    WriteString(pFile, *g_pstrFillSave);
                    WriteString(pFile, pProp[i].ident);
                    WriteString(pFile, " ");
                    WriteString(pFile, pBC->GetString(pProp[i].id));
                    WriteString(pFile, "; ");
                    b = true;
                }
            }
            else if (pProp[i].type == CUSTOMTYPE_VECTOR)
            {
                WriteString(pFile, *g_pstrFillSave);
                WriteString(pFile, pProp[i].ident);
                WriteString(pFile, " ");
                WriteString(pFile, String::FloatToString(pBC->GetVector(pProp[i].id).x));
                WriteString(pFile, " ");
                WriteString(pFile, String::FloatToString(pBC->GetVector(pProp[i].id).y));
                WriteString(pFile, " ");
                WriteString(pFile, String::FloatToString(pBC->GetVector(pProp[i].id).z));
                WriteString(pFile, " ");
                WriteString(pFile, "; ");
                b = true;
            }

            if (b)
                LineBreak(pFile, strFill);
        }
        WriteString(pFile, "}");
    }

    return true;
}
Beispiel #6
0
BaseObject *Objectify::GetVirtualObjects(BaseObject *op, HierarchyHelp *hh)
{
    BaseDocument *doc = op->GetDocument();
    BaseContainer *data = op->GetDataInstance();
    BaseObject* obj = (BaseObject*)data->GetLink(CTT_OBJECT_LINK,doc,Obase);
    LONG crntFrame = doc->GetTime().GetFrame(doc->GetFps());
    if (!obj) return NULL;
    
    if (obj->GetType() != Ospline){
        return NULL;
    }
    // start new list
    op->NewDependenceList();
    
    // check cache for validity and check master object for changes
    Bool dirty = op->CheckCache(hh) || op->IsDirty(DIRTYFLAGS_DATA);

    // if child list has been modified
    if (!dirty) dirty = !op->CompareDependenceList();
    
    // mark child objects as processed
    op->TouchDependenceList();

    dirty = dirty || (prevFrame != crntFrame);
    prevFrame = crntFrame;
    // if no change has been detected, return original cache
    if (!dirty) return op->GetCache(hh);
    
    SplineObject* spline = (SplineObject*) obj;
    
    AutoAlloc<SplineHelp> splineHelp;
    
    StatusSetText("Collecting points");
    float positioAlongSpline = data->GetReal(POSITION_ALONG_SPLINE,0.5);
    positioAlongSpline /= 10000.0f;
    positioAlongSpline = positioAlongSpline > 1.0 ? 1.0: positioAlongSpline;
    positioAlongSpline = positioAlongSpline < 0.0 ? 0.0: positioAlongSpline;
    cout<<positioAlongSpline<<endl;
    vector<vector<float> > points;
    for (LONG i = 0; i < spline->GetSegmentCount(); i++){
        Vector p = spline->GetSplinePoint(positioAlongSpline, i);
        vector<float> point;
        point.push_back(p.x);
        point.push_back(p.y);
        point.push_back(p.z);
        points.push_back(point);
    }
    
    StatusSetText("Collected "+LongToString(points.size())+" points");

    ksearchNeighbors= data->GetLong(TRIANGULATION_MAX_NEIGHBORS, 100);
    gp3SearchRadius = data->GetReal(TRIANGULATION_MAX_SEARCH_RADIUS,30.);
    gp3MaxNeighbors = data->GetLong(KSEARCH_NEIGHBORS, 20);

    gp3Mu = data->GetReal(KSEARCH_MU, 0.5);

    vector<vector<float> > surfacePoints;
    vector<vector<int> > triIndxs;
    StatusSetBar(0);
    StatusSetText("Triangulating");
    
    bool useMls = data->GetBool(USE_MLS, false);

    tri.computeSurface(points, surfacePoints, triIndxs, ksearchNeighbors, gp3SearchRadius, gp3MaxNeighbors, gp3Mu, useMls);

    StatusSetBar(100);
    StatusSetText("Got "+LongToString(triIndxs.size())+" triangles");

    if (triIndxs.size() == 0){
        return NULL;
    }
    
    PolygonObject* myPoly = PolygonObject::Alloc(surfacePoints.size(),triIndxs.size());
    Vector* ppoints = myPoly->GetPointW();
    
    vector<float> sp;
    for (int t = 0; t < surfacePoints.size()-2; t += 3) {
        sp = surfacePoints[t];
        ppoints[t+0] = Vector(sp[0],sp[1],sp[2]);
        
        sp = surfacePoints[t+1];
        ppoints[t+1] = Vector(sp[0],sp[1],sp[2]);
        
        sp = surfacePoints[t+2];
        ppoints[t+2] = Vector(sp[0],sp[1],sp[2]);
    }
    
    for (int t = 0; t < triIndxs.size(); t ++) {
        myPoly->GetPolygonW()[t] = CPolygon(triIndxs[t][0], triIndxs[t][1], triIndxs[t][2], triIndxs[t][2]);
    }
    
    StatusClear();
    myPoly->Message(MSG_UPDATE);
    return ToPoly(myPoly);

    BaseThread* bt=hh->GetThread();
    BaseObject* main = BaseObject::Alloc(Onull);

    SplineObject* emptySpline = SplineObject::Alloc(0, SPLINETYPE_LINEAR);
    ModelingCommandData mcd;
    
    mcd.doc = doc;
    
    mcd.op = emptySpline;
    
    if(!SendModelingCommand(MCOMMAND_JOIN, mcd)){
        return NULL;
    }
Error:

    return NULL;
}