Gibby Posted March 15, 2015 Share Posted March 15, 2015 Greets All:I have a network-friendly submarine nearly finished but have an issue with waterblocks for which I've searched the net as well as the source code to solve:I have a waterblock in my level: new WaterBlock(theOcean) { gridElementSize = "5"; gridSize = "5"; density = "1"; ...blahblahblah then in my commands.cs, I need to find the surface height so I do it like this: ...blahblahblah if(isObject(theOcean)) { %id = theOcean.getID(); %surface = %id.getSurfaceHeight(); echo("water block id: "@%id@" surface level is: "@%surface); } ...blahblahblah which gives me a console error: Unknown command getSurfaceHeight in line 134 in waterBlock.h, I see in the public: virtual F32 getSurfaceHeight( const Point2F &pos ) const; and this same code is in waterPlane and river - yet i can't seem to get a surfaceHeight from anything in the waterObject class- what am I missing? Quote Link to comment Share on other sites More sharing options...
JeffH Posted March 15, 2015 Share Posted March 15, 2015 Is it actually exposed to TorqueScript? I don't see DefineConsoleMethod anywhere. Quote Link to comment Share on other sites More sharing options...
rlranft Posted March 15, 2015 Share Posted March 15, 2015 Yeah, have to add this in Engine/source/environment/waterBlock.cpp :// up at the top with the other includes: #include "console/engineAPI.h" // .... // down at the bottom of the file: DefineEngineMethod(WaterBlock, getSurfaceHeight, F32, (const Point2F pos), , "@brief Return the height of the waterblock surface at position pos.") { return object->getSurfaceHeight(pos); } Note that it takes a Point2F parameter - so %obj.getSurfaceHeight("0.0 0.0");should get us the surface height at the center of the waterblock. I guess you could just default it to // up at the top with the other includes: DefineEngineMethod(WaterBlock, getSurfaceHeightAtCenter, F32, (), , "@brief Return the height of the waterblock surface at position 0.0, 0.0.") { Point2F pos = Point2F(0.0, 0.0); return object->getSurfaceHeight(pos); }I was thinking that you could make it a read-only property and just call this in the "getter," but hell, might as well just do this.By the way - that compiles, but I haven't tested it.... Quote Link to comment Share on other sites More sharing options...
Gibby Posted March 15, 2015 Author Share Posted March 15, 2015 Yeah, have to add this in Engine/source/environment/waterBlock.cpp :// up at the top with the other includes: #include "console/engineAPI.h" // .... // down at the bottom of the file: DefineEngineMethod(WaterBlock, getSurfaceHeight, F32, (const Point2F pos), , "@brief Return the height of the waterblock surface at position pos.") { return object->getSurfaceHeight(pos); } Oh duh, kinda missing a big piece......and yeah works like a charm, thank you!!! Quote Link to comment Share on other sites More sharing options...
rlranft Posted March 16, 2015 Share Posted March 16, 2015 Well, I don't think it's a "duh" moment - I think that might have been in a resource some time back because I remembered it being in there too. I had to go look, and when I saw it wasn't there I figured I'd drop it here. Quote Link to comment Share on other sites More sharing options...
Gibby Posted March 16, 2015 Author Share Posted March 16, 2015 Well in any event, it enabled me to get the submarine playable. I'm having to re-rig it to get some other functionality enabled, will post a blog detailing the rigging and video of it in action... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.