Jump to content

Calling nodes in C sharp


photo

Recommended Posts

Hello everuone,

 

I am making a boat simulator in C#. The problem is that I had defined in the editor one rigid body (boat) and 10 childs dummy nodes associated to the boat. I need to obtain the water height in each point to calculate hydrostatics in the flush function. How I have to declare these nodes to acces to them in the flush function. Thank you very much.

 

Best Regards 

 

Ignacio

Link to comment

Hi Ignacio,
 
It seems that you need to use Editor functionality to get Nodes from the world. I assume that you already have nodes called "boat" (with 10 children) and "water" in your world, so you can use following code to get the height of the water in these points:

public override int flush() {

    Node boatNode = Editor.get().getNodeByName("boat");
    if (boatNode == null) {
        return 1;
    }

    Node waterNode = Editor.get().getNodeByName("water");
    if (waterNode == null || waterNode.getType() != Node.OBJECT_WATER_GLOBAL) {
        return 1;
    }

    ObjectWaterGlobal water = ObjectWaterGlobal.create(waterNode);

    for (int i = 0; i < boatNode.getNumChildren(); i++) {
        Node testPointNode = boatNode.getChild(i);
        float height = water.getHeight(testPointNode.getNodeWorldPosition());
        Log.message("Node {0}, relative height: {1}\n", testPointNode.getName(), height);
    }

    return 1;
}

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Thank you for your help, I didn't see the reply.  That's answer also the other topic. This will help me to solve the water object problem I have with the code.

 

Thanks again.

 

Best Regards

 

Ignacio

Link to comment
×
×
  • Create New...