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 

Creating an array of same type a given one


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


Joined: 06 Feb 2013
Posts: 103

PostPosted: Fri Jan 26, 2018 3:47 pm    Post subject:
Creating an array of same type a given one
Reply with quote

Hi all,

I have to copy data from given arrays (i.e. geometry->getTexCoordArrayList())
into new arrays of the same type. So I have to do something like

    osg::Geometry::ArrayList textureCoords = geometry->getTexCoordArrayList();     osg::Geometry::ArrayList textureCoordsNew(textureCoords.size());
Quote:
for (int i=0; i<textureCoordsNew.size(); i++)
textureCoordsNeu[i] = new ???

  // Do some manipulation and resorting

geometry->setTexCoordArrayList(textureCoordsNew);


Has anybody a hint for me how to solve this?

Many thanks in advance.

- Werner -


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12149

PostPosted: Fri Jan 26, 2018 4:11 pm    Post subject:
Creating an array of same type a given one
Reply with quote

Hi Werner,

All osg::Obejct subclasses implement a cloneType() or clone() method
that you can use to create a copy of the same type or do a
shallow/deep copy respectively. This clone being just a virtual
function in a base class return a pointer to osg::Object* so you'll
need to do a cast.

There is also a osg::clone() and osg::cloneType() templates that do
the clone and return the the same type pointer so it does the cast
making it a bit more convineint ot use.

So do something like

osg::ref_ptr<osg::Array> texCoordArrayClone =
osg::clone(texCoordSource, osg::CopyOp::DEEP_COPY);

Robert.

On 26 January 2018 at 15:44, Werner Modenbach
<> wrote:
Quote:
Hi all,

I have to copy data from given arrays (i.e.
geometry->getTexCoordArrayList())
into new arrays of the same type. So I have to do something like

osg::Geometry::ArrayList textureCoords =
geometry->getTexCoordArrayList();

osg::Geometry::ArrayList textureCoordsNew(textureCoords.size());

for (int i=0; i<textureCoordsNew.size(); i++)
textureCoordsNeu[i] = new ???

// Do some manipulation and resorting

geometry->setTexCoordArrayList(textureCoordsNew);

Has anybody a hint for me how to solve this?

Many thanks in advance.

- Werner -






------------------
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 About Interleaved Array Support mp3butcher General 4 Tue Oct 09, 2018 11:13 pm View latest post
No new posts osgDB::OutputStream write array optim... Farshid Lashkari Submission 2 Thu Sep 20, 2018 11:17 pm View latest post
No new posts axis / axes with color array doesn't ... Steal General 0 Wed Sep 05, 2018 4:07 pm View latest post
No new posts decent font without free type plugin OmegaDoom General 0 Mon Jun 25, 2018 12:12 pm View latest post
No new posts EXTERNAL: Re: Array of structs Rowley, Marlin R General 0 Wed Apr 18, 2018 2:41 pm 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