Jump to content

Change in VEX code from H12.5 to H13?


dszs

Recommended Posts

Hi guys,

             I have a vex based flocking system that was done in H11 and now I would like to migrate to H13, however I get a compliation when I ran it in H13:

steerSolver:215:23-30: Error 1029: Invalid type in explicit cast: void to matrix
steerSolver:215:32-37: Error 1066: No matching function for rotate(matrix; float; vector). Candidates are: void rotate(matrix3 &; float; vector), void rotate(matrix &; float; vector)
steerSolver:216:31-33: Warning 2018: Using uninitialized variable: rot
steerSolver:261:32-39: Error 1029: Invalid type in explicit cast: void to matrix
steerSolver:261:41-46: Error 1066: No matching function for rotate(matrix; float; vector). Candidates are: void rotate(matrix3 &; float; vector), void rotate(matrix &; float; vector)
steerSolver:263:43-47: Warning 2018: Using uninitialized variable: newUp
steerSolver:269:9-20: Error 1066: No matching function for addattribute(string; vector; int). Candidates are: void addattribute(string; matrix3; ... ), void addattribute(string; matrix; ... ), void addattribute(string; float; ... ), void addattribute(string; int; ... ), void addattribute(string; vector4; ... ), void addattribute(string; string; ... ), void addattribute(string; vector; ... ), void addattribute(string; float[]; int; ... )

I tested it in H12.5 and it was working. Is there a major change in H13 that causes this? Thanks for taking your time to answer!

 

-Darren

Link to comment
Share on other sites

Hi Edward, sorry for the late reply! Didn't have access to my code as it was in the office!

 

The offending line looks like this :

    // contrain the turn angle in this simulation step
    float turnAngle = getAngleBetween(forward(), newVel);
    if (turnAngle > radians(maxTurn)) {
        turnAngle = radians(maxTurn);
        matrix identM = ident();
        matrix rot =  (matrix) rotate( identM, radians(maxTurn), axis);
        turnVel = forward() * rot;
                  
        // new vel direction is turnVel
        //newVel = turnVel * length(newVel);
        
    }

The weird thing is, in H12.5, it reports an error but it is still able to execute :unsure:

 

Link to comment
Share on other sites

rotate() returns void, so try something like this:

    // contrain the turn angle in this simulation step
    float turnAngle = getAngleBetween(forward(), newVel);
    if (turnAngle > radians(maxTurn)) {
        turnAngle = radians(maxTurn);
        matrix identM = ident();
        rotate( identM, radians(maxTurn), axis);
        turnVel = forward() * identM;
                  
        // new vel direction is turnVel
        //newVel = turnVel * length(newVel);
        
    }
Link to comment
Share on other sites

Hi rayman, it works! Thanks.

Can I ask another question?

There is another section which have the same problem. I already tried with the above method but it still returns the same error

  
         vector newUp =  up() * rotate(upRot, turnAngle, forward());
        //vector newUp = up() + steer * (1-upInertia);
        newUp = (targetUp * (upInertia) + newUp  ) / 2;
        setUp( cross(cross( forward(), newUp ), forward()) );
    
        vector heading = {0,0,0};
        //import("heading", heading, 0);
        heading = normalize( (normalize(oldForward) + turnVel) / 2 );
        addattribute("heading", heading, 0);
    }

Is there something I did wrong?
 

Edited by dszs
Link to comment
Share on other sites

  • 6 months later...

rotate doesn't return a value, it updates the matrix you supply as the first value.  you need to split up that line to first rotate your matrix and then multiply your up vector by your rotated matrix.

 

rotate(upRot, turnAngle, forward());

vector newUp = up() * upRot;

Link to comment
Share on other sites

  • 3 weeks later...

Hi Dszs !!   I also met the same problem , I still confuse why the code cannot be compiled, could you paste the result you have modified of this part:

attachicon.gifQQ图片20151007181426.png

 

Hi,

Sorry for the late reply! Hope it's not too late to clarify stuff. I don't have the original code anymore. But what fathom mentioned is exactly what you should be doing 

 

rotate doesn't return a value, it updates the matrix you supply as the first value.  you need to split up that line to first rotate your matrix and then multiply your up vector by your rotated matrix.

 

rotate(upRot, turnAngle, forward());

vector newUp = up() * upRot;

 

- Darren

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...