Welcome Guest Search | Active Topics | Members | Log In | Register

Transfer an object from one scene to Another Options
SnipeyX
Posted: Tuesday, May 03, 2011 4:52:55 PM
Rank: Advanced Member

Joined: 1/28/2009
Posts: 111
Points: 333
Location: USA
Is there a way to take an object out of one scene, say a companion scene, and move it into the primary scene?

I've tried:
Code:

NovaScene nScene = PluginHelper.ActiveScene;
NovaScene companion = NovaEngine.CreateScene("CompanionScene");
companion.Load("source.mxb");
nScene.CompanionScene = companion;

NovaObject testObj  = companion.GetObject("testBox");
NovaObject newObj = (NovaObject)testObj.Clone(true, Vertice.Nova.NovaResourceManager.GenerateGuid( i, nScene ));
nScene.Objects.Add(newObj);

That seems like it works, when I refresh the entities browser the new objects are listed, but nothing new is rendered. Perhaps there is another step beyond nScene.Objects.Add?

I also tried:
Code:

NovaObject obj = nScene.CreateObject("new");
obj.CreateFromMesh(testObj.OriginalMesh, true);

But I get a null reference error somewhere in the DirectX code. I am thinking it is because obj.Indices is empty, however I cannot assign to that, so I'm not sure how else to go about creating a new mesh.
?

I guess in the meantime I'll just go back to having everything in one scene and managing objects there, I kind of liked the flexibility of having a "source objects scene" and then an empty scene that could be populated via code though...
SnipeyX
Posted: Tuesday, May 03, 2011 5:02:25 PM
Rank: Advanced Member

Joined: 1/28/2009
Posts: 111
Points: 333
Location: USA
Found one way that works: obj.SetReferenceTo(testObj);
SnipeyX
Posted: Wednesday, May 11, 2011 7:03:44 PM
Rank: Advanced Member

Joined: 1/28/2009
Posts: 111
Points: 333
Location: USA
Of course, it looks like the .SetReferenceTo method isn't ideal because it doesn't transfer other object properties, like AdditionalMaterials. And on top of that, since I haven't found a way to assign additional materials via code, I don't think I have a workaround for that specific issue either. :(

Any help with either of these?
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS