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 

A problem with regard to std:istream on Android


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
first_gle
Newbie


Joined: 30 Mar 2017
Posts: 6

PostPosted: Fri May 26, 2017 6:11 am    Post subject:
A problem with regard to std:istream on Android
Reply with quote

Hi All,
I'm trying to make osgEarth run on Android (OSG 3.2 & osgEarth 2.3). Now the earth can display on Android system. But I run into a problem with regard to std:istream. I tried to load an osgb file by the following code
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile("/sdcard/WV/Models/tk.osgb");
the variable node's value is always be NULL. I step into this line and traced down to file ReaderWriterOSG2.cpp
virtual ReadResult readNode( const std::string& file, const Options* options ) const
{
ReadResult result = ReadResult::FILE_LOADED;
std::string fileName = file;
std::ios::openmode mode = std::ios::in;
Options* local_opt = prepareReading( result, fileName, mode, options );
if ( !result.success() ) return result;

osgDB::ifstream istream( fileName.c_str(), mode );
return readNode( istream, local_opt );
}

virtual ReadResult readNode( std::istream& fin, const Options* options ) const
{
osg::ref_ptr<InputIterator> ii = readInputIterator(fin, options);
if ( !ii ) return ReadResult::FILE_NOT_HANDLED;

InputStream is( options );
if ( is.start(ii.get())!=InputStream::READ_SCENE )
{
CATCH_EXCEPTION(is);
return ReadResult::FILE_NOT_HANDLED;
}

is.decompress(); CATCH_EXCEPTION(is);
osg::Node* node = dynamic_cast<osg::Node*>(is.readObject()); CATCH_EXCEPTION(is);
return node;
}


the debugger couldn't step into the function readNode( std::istream& fin, const Options* options ). But on windows it works.


Can anybody tell me how to solve this problem?


Dev Environment:
Visual Studio 2017
Android 7.0
Android NDK64 r13b
Arch arm64-v8a


Best regards.


Glen



Quote:




------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
kornerr
Appreciator


Joined: 01 Oct 2013
Posts: 238

PostPosted: Sat May 27, 2017 9:18 am    Post subject:
A problem with regard to std:istream on Android
Reply with quote

Hi.

Are you sure /sdcard path is valid at all? Different Android versions
use different sdcard paths. Use getExternalStorageDirectory():
https://stackoverflow.com/a/21230946/3404710
Note that you need a special permission to read from external storage, too.


2017-05-26 13:06 GMT+07:00 龚来恩 <>:
Quote:
Hi All,
I'm trying to make osgEarth run on Android (OSG 3.2 & osgEarth 2.3). Now
the earth can display on Android system. But I run into a problem with
regard to std:istream. I tried to load an osgb file by the following code
osg::ref_ptr<osg::Node> node =
osgDB::readNodeFile("/sdcard/WV/Models/tk.osgb");
the variable node's value is always be NULL. I step into this line and
traced down to file ReaderWriterOSG2.cpp
virtual ReadResult readNode( const std::string& file, const Options* options
) const
{
ReadResult result = ReadResult::FILE_LOADED;
std::string fileName = file;
std::ios::openmode mode = std::ios::in;
Options* local_opt = prepareReading( result, fileName, mode, options
);
if ( !result.success() ) return result;

osgDB::ifstream istream( fileName.c_str(), mode );
return readNode( istream, local_opt );
}

virtual ReadResult readNode( std::istream& fin, const Options* options )
const
{
osg::ref_ptr<InputIterator> ii = readInputIterator(fin, options);
if ( !ii ) return ReadResult::FILE_NOT_HANDLED;

InputStream is( options );
if ( is.start(ii.get())!=InputStream::READ_SCENE )
{
CATCH_EXCEPTION(is);
return ReadResult::FILE_NOT_HANDLED;
}

is.decompress(); CATCH_EXCEPTION(is);
osg::Node* node = dynamic_cast<osg::Node*>(is.readObject());
CATCH_EXCEPTION(is);
return node;
}

the debugger couldn't step into the function readNode( std::istream& fin,
const Options* options ). But on windows it works.

Can anybody tell me how to solve this problem?

Dev Environment:
Visual Studio 2017
Android 7.0
Android NDK64 r13b
Arch arm64-v8a

Best regards.

Glen









------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
first_gle
Newbie


Joined: 30 Mar 2017
Posts: 6

PostPosted: Sat May 27, 2017 11:23 pm    Post subject:
A problem with regard to std:istream on Android
Reply with quote

Hi michael,
The osg format file can be loaded. The problem has to do with std::istream >> operator reading binary stream.------------------ 原始邮件 ------------------发件人: "michael kapelko" <>;
发送时间: 2017年5月27日(星期六) 17:13
收件人: "OpenSceneGraph Users" <>;
主题: Re: A problem with regard to std:istream on Android

Hi.Are you sure /sdcard path is valid at all? Different Android versionsuse different sdcard paths. Use getExternalStorageDirectory():https://stackoverflow.com/a/21230946/3404710Note that you need a special permission to read from external storage, too.2017-05-26 13:06 GMT+07:00 龚来恩 <>:> Hi All,> I'm trying to make osgEarth run on Android (OSG 3.2 & osgEarth 2.3). Now> the earth can display on Android system. But I run into a problem with> regard to std:istream. I tried to load an osgb file by the following code> osg::ref_ptr<osg::Node> node => osgDB::readNodeFile("/sdcard/WV/Models/tk.osgb");> the variable node's value is always be NULL. I step into this line and> traced down to file ReaderWriterOSG2.cpp> virtual ReadResult readNode( const std::string& file, const Options* options> ) const> {> ReadResult result = ReadResult::FILE_LOADED;> std::string fileName = file;> std::ios::openmode mode = std::ios::in;> Options* local_opt = prepareReading( result, fileName, mode, options> );> if ( !result.success() ) return result;>> osgDB::ifstream istream( fileName.c_str(), mode );> return readNode( istream, local_opt );> }>> virtual ReadResult readNode( std::istream& fin, const Options* options )> const> {> osg::ref_ptr<InputIterator> ii = readInputIterator(fin, options);> if ( !ii ) return ReadResult::FILE_NOT_HANDLED;>> InputStream is( options );> if ( is.start(ii.get())!=InputStream::READ_SCENE )> {> CATCH_EXCEPTION(is);> return ReadResult::FILE_NOT_HANDLED;> }>> is.decompress(); CATCH_EXCEPTION(is);> osg::Node* node = dynamic_cast<osg::Node*>(is.readObject());> CATCH_EXCEPTION(is);> return node;> }>> the debugger couldn't step into the function readNode( std::istream& fin,> const Options* options ). But on windows it works.>> Can anybody tell me how to solve this problem?>> Dev Environment:> Visual Studio 2017> Android 7.0> Android NDK64 r13b> Arch arm64-v8a>> Best regards.>> Glen>>> _______________________________________________> osg-users mailing list> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org>>> _______________________________________________> osg-users mailing list> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org>_______________________________________________osg-users mailing ://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General 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 Osg 3.4.1 - Tutorial 12 Fails on Mac ... digitorus General 1 Sat Nov 04, 2017 12:32 pm View latest post
No new posts BVH and model axis centering: a model... Paradox Plugins [osgPlugins] 0 Mon Oct 16, 2017 4:27 pm View latest post
No new posts Problem With Osg Texture Colors! Bobykhani General [forum] 1 Tue Oct 10, 2017 8:20 am View latest post
No new posts OpenSceneGraph static linking for And... tanshihaj Build system [build] 1 Thu Sep 21, 2017 12:56 pm View latest post
No new posts Problem compiling OSG 3.4.1 osgDB 64 bit tonyor Build system [build] 0 Thu Sep 21, 2017 12:41 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