Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 45

Thread: How do I start the debugger from a .p file?

  1. #16
    So here's an other one... I created a loop like this:

    for (int i = sceneinfo->frameStart; i > sceneinfo->frameEnd; i++) {
    char *mess[sizeof(i)];
    sprintf(mess, "%3.3f ", i);
    Log(mess);

    }

    When I check i it is some big negative number like -8654367 or something like that. Even when I declare i first like this int i = 0; and then use it in the loop it still gets that odd number. Can someone tell me why this isn't 0 like I want it to be? When I make it a static int and initialize it outside the loop it works but I want it all happening inside the loop.
    Last edited by Every4thPixel; 01-06-2017 at 07:57 AM.

  2. #17
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    7,876
    Are you beginner in C/C++ ?

    What is this?
    char *mess[sizeof(i)];

    sizeof( i ) variable is 4...

    Output buffer for printing floats must have at least 16 bytes long or so...

    %3.3f formatting command has 3 integer digits, 1 dot, 3 float digits, and 1 eol, and 1 for null characters.
    In total 3+1+3+1+1=9 bytes must be.

    Why you used " i > sceneinfo->frameEnd" ?
    frameEnd typically is bigger number than frameStart..

    Also sprintf/printf() expects i variable to be integer,
    if you want to print it as float, you need type-casting..

    Replace it by:

    for (int i = sceneinfo->frameStart; i <= sceneinfo->frameEnd; i++) {
    char mess[16];
    sprintf(mess, "%3.3f ", (float) i);
    Log(mess);

    }

    or


    for (int i = sceneinfo->frameStart; i <= sceneinfo->frameEnd; i++) {
    char mess[16];
    sprintf(mess, "%3.3f ", (float) i);
    Log(mess);

    }

    or even

    for (int i = sceneinfo->frameStart; i <= sceneinfo->frameEnd; i++) {
    char mess[16];
    sprintf(mess, "%d", i);
    Log(mess);

    }
    Last edited by Sensei; 01-06-2017 at 10:18 AM.

  3. #18
    creacon
    Join Date
    Nov 2005
    Location
    Belgium
    Posts
    1,299
    Sensei, I'd move the char mess[16] before the loop. sprintf adds a null character, so you can reuse the variable.

  4. #19
    Yes, I'm a total noob at C/C++. I started with c# about a year ago so I'm a programming rooky in general. I noticed the < being in the wrong direction. Stupid mistake that was.

    I copied the print line from a different part of my script that worked and I got some problems with puting int's in it. So i was a bit lazy and didn't change it because it did print what I wanted to know. Now I cleaned my code a bit and I'M using %d option.

    @creacon I did that ad well. Now I'm reusing the same variable multiple times.

    I think the node is almost doing what it should do a the moment but it still needs a lot of testing. F10 renders already worked but now it should work on lwsn too. Fingers crossed

    Thanks for the help guys. Sometimes I just need a little push.

  5. #20
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    7,876
    The main issue with you code is this line
    "char *mess[sizeof(i)];"

    Trying to print to mess, will end up writing to random memory, trashing it, and causing random (or constant) crashes.

    char *memory[ size ];
    is array (with quantity 'size') of pointers to strings.

    char string[ size ];
    is string with defined size.

  6. #21
    I've some trouble understanding how and what NewTime does. Is it possible with NewTime to get input values from my node at a different frame than the current one?
    I thought if I would feed a value in LWFrame it evaluates a different frame than the current one but this doesn't seem to be the case? Is it even possible to read the input value of a node at a different time?
    If not I think the best way would be storing the triggered time/value while playing the sequence in openGL.

    XCALL_(static LWError)
    NewTime(LWInstance instance, LWFrame f, LWTime t)
    {

    Trigger_p inst = (Trigger_p)instance;
    int switz = inst->v_swi; // input of node

    inputfuncs->evaluate(inst->swi, instance, &switz);

    }

    This code above doesn't give me the value of time f does it?

  7. #22
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    7,876
    LWNodeInputFuncs doesn't have time as argument.

    Channels and Envelopes do take it as argument.

    If parameter is dynamically generated by plugin,
    then there is needed first baking them to envelope/channel.

  8. #23
    Ah to bad! It's like you say. The parameter is generated dynamically. If I understand it correctly: there is no way I can generate an envelope while rendering (I mean like a pre-process)? This has to be a separate process or can it be done?
    I'm thinking of a way of storing a cache point (frame number). This is the easiest way I think. If I press play in Layout it the trigger works perfectly fine so if I would store the frame number it switches I'm there but it isn't a rock solid method because if you don't play the animation or if you scrub to fast the cached point differs. My goal is to have it working rock solid on LWSN as well.
    To make my question shorter. Is it possible to bake the input of a node to an envelope before the actual render starts but after you press f10 or the specific frame starts rendering on a renderfarm?
    Last edited by Every4thPixel; 01-09-2017 at 10:11 AM.

  9. #24
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    7,876
    Even LW by itself is baking: see anim GI cache for instance..

  10. #25
    Cool! I understand. Thanks Sensei

  11. #26
    I'm again running into an issue. Here's what I'm doing:

    I'm storing a value while playing an animation. I made an inputfield in the nodes interface so I can see there is actually a value stored. This seem to work fine.
    Than I'm saving the scene. The values are saved. I checked the .lws in notepad++ and the values are there. But here's the problem. The 2 values that I add during the "openGL scanning" won't load. All 4 values that I'm saving are of the same type and similar. To detect whether I was overwriting the values during loading I removed the openGL scanning code so no new values would be saved or detected but the values the are clearly there in the .lws file won't show up in my node.
    Am I missing something or what am I doing wrong?

    The values that don't load are inst->v_storedValue; and inst->v_switchedAtFrame;



    Here is some of the code:

    XCALL_(static void)
    Evaluate(void *data, LWNodalAccess *na, NodeOutputID out, NodeValue Value)
    {
    Trigger_p inst = (Trigger_p)data;

    LWDVector triggeredv;
    double trigger = inst->v_trigg;
    double switz = inst->v_swi;
    double storedValueLocal = inst->v_storedValue;
    double switchedAtFrame = inst->v_switchedAtFrame;

    // evaluate node inputs
    //inputfuncs->evaluate(inst->trigg, na, &trigger); //works fine
    //inputfuncs->evaluate(inst->swi, na, &switz); //works fine
    //inputfuncs->evaluate(inst->storedValue, na, &storedValueLocal); // check value

    if (sceneinfo->rendermode == lwrm_None) {

    inputfuncs->evaluate(inst->trigg, na, &trigger); //works fine
    inputfuncs->evaluate(inst->swi, na, &switz); //works fine


    if (switz == 1 && inst->v_swbool == false) {

    //switchedAtFrame = timeinfo->frame;
    inst->v_switchedAtFrame = timeinfo->frame;
    inst->v_swbool = 1; // seems not to work

    inst->v_storedValue = trigger; // This updates the value used for F10 renders and LWSN an openGL
    storedValueLocal = trigger; // updates for F10 and LWSN only and should be saved

    triggeredv[0] = inst->v_storedValue;
    triggeredv[1] = inst->v_storedValue;
    triggeredv[2] = inst->v_storedValue;
    outputfuncs->setValue(Value, triggeredv);

    //char mess[32];
    //sprintf(mess, "%d ", inst->v_trigg);
    //Log(mess);

    }
    else if (switz == 0 && inst->v_swbool == false) {

    triggeredv[0] = trigger;
    triggeredv[1] = trigger;
    triggeredv[2] = trigger; // true on start of anim not triggered and while loading?

    outputfuncs->setValue(Value, triggeredv);
    }
    else if (inst->v_swbool == true) { // when triggered
    triggeredv[0] = inst->v_storedValue;
    triggeredv[1] = inst->v_storedValue;
    triggeredv[2] = inst->v_storedValue;

    outputfuncs->setValue(Value, triggeredv);
    }

    if (timeinfo->frame < inst->v_switchedAtFrame || timeinfo->frame == 0) {

    inst->v_swbool = false; //reset trigger
    }
    }

    if (sceneinfo->rendermode == lwrm_Scene || sceneinfo->rendermode == lwrm_Frame) {

    if (timeinfo->frame >= switchedAtFrame) {
    // triggered
    triggeredv[0] = storedValueLocal;
    triggeredv[1] = storedValueLocal;
    triggeredv[2] = storedValueLocal;
    outputfuncs->setValue(Value, triggeredv); // set output while rendering
    }
    else if (timeinfo->frame < switchedAtFrame) {
    // not triggered
    inputfuncs->evaluate(inst->trigg, na, &trigger);

    triggeredv[0] = trigger;
    triggeredv[1] = trigger;
    triggeredv[2] = trigger;
    outputfuncs->setValue(Value, triggeredv);
    }

    }

    }
    Last edited by Every4thPixel; 01-10-2017 at 08:01 AM.

  12. #27
    Does anyone see what wrong with this? If I did a lot of stupid stuff please tell me.

  13. #28
    creacon
    Join Date
    Nov 2005
    Location
    Belgium
    Posts
    1,299
    So the values in your instance are saved in the lws.
    When you load the scene, you put the values that are read from the file in a new instance?
    If you place a breakpoint right after you read the values, are they there?

    creacon.

    Quote Originally Posted by Every4thPixel View Post
    Does anyone see what wrong with this? If I did a lot of stupid stuff please tell me.

  14. #29
    I just added breakpoints in the load method and I think I'm doing something working here, but I not sure what it is. Should I break; after each case? Could it be the problem that if it finds a value in the first case it breaks out of the while loop and stops reading the rest of the code?
    Edit: I removed the break; command and now it does finally read in a value but it's something like -12958942 is stead of 73 and all the values are the same so there's still something wrong.

    Load(LWInstance instance, const LWLoadState *load)
    {
    Trigger_p inst = (Trigger_p)instance;
    LWID id;

    // Find the data blocks
    while ((id = LWLOAD_FIND(load, Trigg_Block)))
    {
    switch (id)
    {

    case ID_TR_TRIGG:
    {
    float fval;
    LWLOAD_FP(load, &fval, 1);
    inst->v_trigg = fval;
    }
    break;

    case ID_TR_SWI:
    {
    float fval;
    LWLOAD_FP(load, &fval, 1);
    inst->v_swi = fval;
    }
    break;

    case ID_TR_SWIAT:
    {
    float fval;
    LWLOAD_FP(load, &fval, 1);
    inst->v_switchedAtFrame = fval;
    }
    break;

    case ID_TR_SLV:
    {
    float fval;
    LWLOAD_FP(load, &fval, 1);
    inst->v_storedValue = fval;
    }
    break;
    }

    LWLOAD_END(load);
    }
    return NULL;
    }
    Last edited by Every4thPixel; 01-16-2017 at 06:45 AM.

  15. #30
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    7,876
    You are using break; outside of context...

    Instead of f.e.:


    case ID_TR_SLV:
    {
    float fval;
    LWLOAD_FP(load, &fval, 1);
    inst->v_storedValue = fval;
    }
    break;

    You should have:

    case ID_TR_SLV:
    {
    float fval = 0.0; // CLEAR IT!!! Just in case...
    LWLOAD_FP(load, &fval, 1);
    inst->v_storedValue = fval;
    break;
    }

    Don't see other obvious issues. Show Save() implementation..

Page 2 of 3 FirstFirst 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •