Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search   Register Register  Login Login

SplineObject in Draw()

 Post Reply Post Reply
Author
Message
WickedP View Drop Down
Member
Member
Avatar

Joined: 2011 Aug 21
Online Status: Offline
Posts: 470
Post Options Post Options   Quote WickedP Quote  Post ReplyReply Direct Link To This Post Topic: SplineObject in Draw()
    Posted: 2018 Jan 03 at 12:36am

User Information:

Cinema 4D Version:   R14 
Platform:   Windows  ;   
Language(s):     C++  ;   

---------

Hi folks,

think I'm missing something simple here - how do I draw a SplineObject in an objectdata's Draw() function? Everything I try results in the base draw returning DRAWRESULT_SKIP.

// Init function - allocate class level variable
Bool My_Object::Init(GeListNode *node)
{
    Spline = SplineObject::Alloc(2,SPLINETYPE_LINEAR);
    Vector *pnt = Spline->GetPointW();
    pnt[0] = Vector(0.0,100.0,0.0);
    pnt[1] = Vector(0.0,100.0,-100.0);
    Spline->Message(MSG_UPDATE);

    return TRUE;
}

// Draw function
DRAWRESULT My_Object::Draw(BaseObject *op,DRAWPASS drawpass,BaseDraw *bd,BaseDrawHelp *bh)
{
    if(drawpass == DRAWPASS_OBJECT)
    {
        Vector col = Vector(0.0,1.0,1.0);
        bd->SetMatrix_Matrix(nullptr,bh->GetMg());
        Spline->SetMg(bh->GetMg());
        Spline->SetAbsPos(Vector(0.0,100.0,0.0));
        DRAWRESULT res = bd->DrawObject(bh,Spline,DRAWOBJECT_FORCEPOINTS|DRAWOBJECT_USE_OBJECT_COLOR,drawpass,op,col);

        if(res == DRAWRESULT_OK)
        {
            GePrint("Success!!"); // never called        
        }
        else if(res == DRAWRESULT_SKIP)
        {
            GePrint("Skipped.."); // always called
        }
    }

    return SUPER::Draw(op,drawpass,bd,bh);
}

// Spline is freed in plugin object's Free()

Always prints "Skipped..". Cheers,

WP.
WickedP® Developer
http://www.wickedp.com
Back to Top
gr4ph0s View Drop Down
Member
Member


Joined: 2015 Jul 07
Location: France
Online Status: Offline
Posts: 437
Post Options Post Options   Quote gr4ph0s Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Jan 03 at 1:58am
You must retrieve LineObject. A good read for you https://c4dprogramming.wordpress.com/2012/11/21/drawing-a-spline-in-the-viewport/

Hope it's help :)
Technical lover.
Back to Top
WickedP View Drop Down
Member
Member
Avatar

Joined: 2011 Aug 21
Online Status: Offline
Posts: 470
Post Options Post Options   Quote WickedP Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Jan 03 at 2:21am
I missed the LineObject. Page bookmarked. Thanks gr4ph0s!

WP.
WickedP® Developer
http://www.wickedp.com
Back to Top
knickknack View Drop Down
Forum Moderator
Forum Moderator


Joined: 2016 Jul 01
Location: Italy
Online Status: Offline
Posts: 195
Post Options Post Options   Quote knickknack Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Jan 03 at 7:47am
Thanks gr4ph0s for getting here fast and precise!

As a side note, consider that the SplineObject::GetLineObject() has changed compared to that used in the blog post and appreciable changes in terms of spline curve tessellation can be obtained with LOD ranging between 0.1 and 1.

Best, Riccardo
MAXON Computer GmbH
SDK Support Team
Back to Top
WickedP View Drop Down
Member
Member
Avatar

Joined: 2011 Aug 21
Online Status: Offline
Posts: 470
Post Options Post Options   Quote WickedP Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Jan 03 at 11:25pm
Hi knickknack,

could you explain the spline curve tessellation a little more?

WP.
WickedP® Developer
http://www.wickedp.com
Back to Top
knickknack View Drop Down
Forum Moderator
Forum Moderator


Joined: 2016 Jul 01
Location: Italy
Online Status: Offline
Posts: 195
Post Options Post Options   Quote knickknack Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Jan 04 at 2:18am
Hi WickedP, thanks for writing back.

Since we need to represent lines rather than pure spline curves using the ObjectData::Draw() function, we need to approximate the real curve to a sequence of segments whose distance from the curve represent the level of approximation desired. Using the LOD parameter you're able to change this approximation where a value of 0 basically create straight lines among the points building the spline whilst greater values create smaller line pieces approximating better and better the spline itself.

Make sense?

Best, Riccardo
MAXON Computer GmbH
SDK Support Team
Back to Top
WickedP View Drop Down
Member
Member
Avatar

Joined: 2011 Aug 21
Online Status: Offline
Posts: 470
Post Options Post Options   Quote WickedP Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Jan 04 at 2:40am
So it's to do with the quality of the curve line draw between points? Assuming there's a curve between points, a value closer to 1.0 draws a more precise curve line?

WP.
WickedP® Developer
http://www.wickedp.com
Back to Top
knickknack View Drop Down
Forum Moderator
Forum Moderator


Joined: 2016 Jul 01
Location: Italy
Online Status: Offline
Posts: 195
Post Options Post Options   Quote knickknack Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Jan 04 at 5:18am
Exactly!
MAXON Computer GmbH
SDK Support Team
Back to Top
WickedP View Drop Down
Member
Member
Avatar

Joined: 2011 Aug 21
Online Status: Offline
Posts: 470
Post Options Post Options   Quote WickedP Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Jan 04 at 1:32pm
Gotchya! Thanks,

WP.
WickedP® Developer
http://www.wickedp.com
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.125 seconds.