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
User


Joined: 06 Feb 2013
Posts: 72

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: 11357

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 Specifying indices of triangle vertic... antiro42 General 1 Thu Dec 21, 2017 12:44 pm View latest post
No new posts Why not const pointers in array setters Bruno Oliveira General 1 Mon May 29, 2017 12:47 pm View latest post
No new posts Setting vertex attribute array of float Bruno Oliveira General 1 Mon Mar 20, 2017 9:55 am View latest post
No new posts Draw vertex as Circle with color give... Bruno Oliveira General 7 Mon Jan 02, 2017 7:22 pm View latest post
No new posts Converting 3d Models to OSG type umadevi2193 General 2 Mon Oct 24, 2016 9:06 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