OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

OceanExample - MakeTransform - Much different results with different boat model


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> osgOcean [osgOcean]
View previous topic :: View next topic  
Author Message
tim (tim paige)
User


Joined: 25 Feb 2009
Posts: 31
Location: San Diego

PostPosted: Tue Mar 01, 2011 10:12 pm    Post subject:
OceanExample - MakeTransform - Much different results with different boat model
Reply with quote

Hi,

I need help understanding what may be at play here...

With the testCollision option to secure a boat for myself on the ocean, I promptly used a different boat I got from a collada dae file (a wooden dory from google sketchup 3dwarehouse), and ignored the one coming with the example because it was white and devoid of interesting texture.

Iwas surprised to see my boat (finally when I figured out where it was) merrily bouncy along... not on the ocean surface, mind you... but moving up and down what would look like 20 feet in the air.

So... please help me understand what I will have to watch out for using different models... and how to allow for and correct for these differences?

I tried changing the scale returned from GetOceanSurfaceHeightAt(), and to no avail... then I tried just using 0 in the makeTranslate just to shut it up... and was surprised when it just ignored me and kept bobbing up and down in the air. I guess something else is responsible for positioning the boat on the surface? And NOT the node update visitor boatPositionCallback?

search google's 3d warehouse for "A wooden rowboat complete with oars, oar holders, beverage cabinet, and seats"

I would like to know how to get this boat out of the air, and into the water. It seems so.... strange.
Thank you!

Then... I'd like to keep water out of my boat... but first things first!

...Seeking UNDERStanding in an UnderWaterWorld

Cheers,
tim
Back to top
View user's profile Send private message
tim (tim paige)
User


Joined: 25 Feb 2009
Posts: 31
Location: San Diego

PostPosted: Fri Mar 04, 2011 12:39 am    Post subject:
Reply with quote

Hi,

well...
I finally got my boat INTO the water after findiing that the one supplied with the example was perfectly happy sitting IN the water instead of floating around in the air...

I also got a shark model which exhibited the same characteristic of floating 10 feet ABOVE the water instead of IN it... so I applied a negative value of 1.5 to 2 to each of the models z axis height parameters with regard to the matrixTraslate in the callback to get them in the water...

I still would like to know the whys and wherefors and how comes surrounding this effect.... do different models have built in heights with respect to 0,0,0?

Thank you!

Cheers,
tim
Back to top
View user's profile Send private message
Skylark (Jean-Sébastien Guay)
Professional


Joined: 05 Jan 2009
Posts: 2249

PostPosted: Fri Mar 04, 2011 2:49 am    Post subject:
OceanExample - MakeTransform - Much different results with different boat model
Reply with quote

Hi Tim,

Quote:
I still would like to know the whys and wherefors and how comes surrounding this effect.... do different models have built in heights with respect to 0,0,0?

It all depends on how the model was built in the modeling program...
Clearly if one model's local origin (its own (0,0,0)) is 10 meters below
the bottom of the hull, then when just naively placing it in the scene
at the world origin, it will look like it's floating in the air...

If you can't load the boat model in a modeling program, you can easily
make a model that is just a plane at Z=0. Then load that along with your
boat model, and see if the boat model floats high above that plane.

There are a few solutions you could adopt to make sure this doesn't
happen. You could make sure your models are built with a local origin
that makes sense. For a boat it could be the center in XY, and Z at the
"normal" waterline. For a car it might be in the center in XY, and Z at
the bottom of the wheels.

Or you could make a small function that would find the bounding box of
the model (try the osg::ComputeBoundsVisitor) and then from that tries
to find a correct position to move the local origin to, using a
MatrixTransform to decorate your model's subgraph and setting that
matrix to translate the local origin. For example if your boat was 10m
higher than you wanted, the MatrixTransform would have a translation by
(0,0,-10). Then you just pass that node as the new root of the model,
and from then on the model will be placed correctly. This offset could
also be stored in a config file, or you can save out the transform I
just mentioned and use that instead of your previous model with a bad
local origin.

So, it's all about how your data was created. Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay
http://www.cm-labs.com/
http://whitestar02.webhop.org/


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Kim Bale
Guest





PostPosted: Fri Mar 04, 2011 9:04 am    Post subject:
OceanExample - MakeTransform - Much different results with different boat model
Reply with quote

Quote:
Or you could make a small function that would find the bounding box of the model


There's an app for that Smile


http://code.google.com/p/osgworks/ 


osgwbvv: A bounding volume visualizer to display bounding spheres and boxes.


K.

On 4 March 2011 02:49, Jean-Sébastien Guay < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi Tim,

Quote:
I still would like to know  the whys and wherefors and how comes surrounding this effect.... do different models have built in heights with respect to 0,0,0?


It all depends on how the model was built in the modeling program... Clearly if one model's local origin (its own (0,0,0)) is 10 meters below the bottom of the hull, then when just naively placing it in the scene at the world origin, it will look like it's floating in the air...

If you can't load the boat model in a modeling program, you can easily make a model that is just a plane at Z=0. Then load that along with your boat model, and see if the boat model floats high above that plane.

There are a few solutions you could adopt to make sure this doesn't happen. You could make sure your models are built with a local origin that makes sense. For a boat it could be the center in XY, and Z at the "normal" waterline. For a car it might be in the center in XY, and Z at the bottom of the wheels.

Or you could make a small function that would find the bounding box of the model (try the osg::ComputeBoundsVisitor) and then from that tries to find a correct position to move the local origin to, using a MatrixTransform to decorate your model's subgraph and setting that matrix to translate the local origin. For example if your boat was 10m higher than you wanted, the MatrixTransform would have a translation by (0,0,-10). Then you just pass that node as the new root of the model, and from then on the model will be placed correctly. This offset could also be stored in a config file, or you can save out the transform I just mentioned and use that instead of your previous model with a bad local origin.

So, it's all about how your data was created. Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay     (
Only registered users can see emails on this board!
Get registred or enter the forums!
)
                              http://www.cm-labs.com/
                       http://whitestar02.webhop.org/

_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




------------------
Post generated by Mail2Forum
Back to top
tim (tim paige)
User


Joined: 25 Feb 2009
Posts: 31
Location: San Diego

PostPosted: Fri Mar 04, 2011 8:04 pm    Post subject:
Notes thankfully taken...
Reply with quote

J.S, Kim...

Thank you!
I wasn't expecting multiple models to exhibit the same behaviour. I'll try some different types other than collada models to see how they do.

I'll see about the bounding box idea... sounds useful... Thanks for the tips.

I'll keep studying... there is much I would like to do with this over and under water world... mostly under, but I'm really interested in my own project of building a nice underwater vehicle with navigation, sonar, inertial guidance and hopefully without tether... of course I need to start with tether so far, and will have to learn much to get there.

As part of the design... modeling came into play, and I am trying to get up to speed. OSGOcean will be a neat way of realizing part of my hopes.

A small step in this direction is trying to place my vehicle model into the environment and be able to control its multiple motors within OSGOcean.
Ahhh.... so much time and so little to do.

I did a small bit of Blender, then switched to sketchup for speed, and then found the relationship of it to collada. I'll get it over here soon.

I'm a diver, and so found e-diving on the net... and the Venus underwater simulator project sounds great. Hope to know enough to help some day.

Thanks for the basics. Looking forward to lights, cameras and ACTION!

Cheers,
tim
Back to top
View user's profile Send private message
tim (tim paige)
User


Joined: 25 Feb 2009
Posts: 31
Location: San Diego

PostPosted: Thu Mar 17, 2011 12:56 am    Post subject:
Follow up (just because) on model position in real world
Reply with quote

Hi,

Here's what I've done so far towards this end (height of model vs reality)...
Code:

if(boat.valid())
{
    boat->setNodeMask( scene->getOceanScene()->getNormalSceneMask() |
        scene->getOceanScene()->getReflectedSceneMask() |
        scene->getOceanScene()->getRefractedSceneMask() );

    osg::ref_ptr<osg::PositionAttitudeTransform> boatTransform = new osg::PositionAttitudeTransform;
    //Name that NODE!
   //Hmmm... there seems to be some discussion on wether to use the node of the
   //        transform or the node of the boat! (which... I wonder?...)
    boatTransform->setName("BOAT");
    boatTransform->addChild(boat.get());
   //This I did for my collada models... and it seems to help... but still needs "tweaking"
   //Like... "You've... got (to bail)" (sorry... old movie)
    const osg::BoundingSphere& bs = boat->getBound();
    boatTransform->setPivotPoint(bs.center());
    //I want my boat pointing in a direction I can manipulate easily... "y"
    osg::Vec3 boatPosit(0,100,1.5);
    boatTransform->setPosition( boatPosit );
    boatTransform->setAttitude(osg::Quat( osg::DegreesToRadians(90.0) , osg::Vec3(0,0,1) ));
   //I hope this is the right thing to do...
    boatTransform->setUpdateCallback( new BoatPositionCallback(scene->getOceanScene()) );

    scene->getOceanScene()->addChild(boatTransform.get());   
}

[


The above stuff at least landed my collada boat in the water... and then...
"tweaking" for the appropriate waterline.

Oh... I left the "hmmm... " note in there because I started using a PositionAttitudeTransform in my call back for a camera lately... and there has been a discussion on using the transform or its child when adding the node... (sigh)

Thank you!
Please comment if you feel any need... because I need a disturbance in the force...

Cheers,
tim
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> osgOcean [osgOcean] All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Convert .obj model into .osg model darshanpopat Plugins [osgPlugins] 1 Thu Mar 30, 2017 1:57 pm View latest post
No new posts issue with 3ds model after upgrading ... filnet General 5 Thu Feb 09, 2017 1:27 pm View latest post
No new posts About Boat Movement Rambabu General 3 Mon Dec 19, 2016 10:43 am View latest post
No new posts Upon Clicking the mouse left button t... Rambabu General 6 Mon Dec 05, 2016 7:34 am View latest post
No new posts Rendering 3d Model using osgEarth. umadevi2193 General 2 Mon Nov 21, 2016 9:37 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP