Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

3 Dimensional Chat / [SOLVED] 3D clone object placement array

Author
Message
xcode77
5
Years of Service
User Offline
Joined: 31st Jul 2018
Location:
Posted: 3rd Jun 2020 00:36
I've managed to put a train track on my 3D plane using cloning and it's all working fine with:


This obviously is a terrible way to code it although it works, especially I'm going to need at least 80 pieces of rail track on the 3D plane.
Any suggestions on how to improve coding it? possibly an array?
A random placement array won't cut it because I need to place each object end-to-end (watched TGC youtube tut to understand that)
Also, I presume I'm using CloneObject to save memory, is this a correct presumption?
Thanks in advance for any help

The author of this post has marked a post as an answer.

Go to answer

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 3rd Jun 2020 03:20 Edited at: 3rd Jun 2020 03:27
This post has been marked by the post author as the answer.
i think you're looking for InstanceObject if you're just re-using the same object (which would share some attributes of the original) to save memory.

otherwise, the array itself won't necessarily simplify placement but, if you're going to modify/remove/replace the objects, you'll do well to keep track of them (pun intended ).

without knowing much of your endeavor, see the function inside:

...which helps place multiple sections of track while keeping the object numbers stored in an array for future reference.

and, Tip: this 3D Board has historically been used for dialogue about modelling itself. you'll receive more exposure to inquiries like this using the Studio or Classic boards, instead
xcode77
5
Years of Service
User Offline
Joined: 31st Jul 2018
Location:
Posted: 3rd Jun 2020 09:58 Edited at: 3rd Jun 2020 10:02
Thanks for your reply. I understand what your code does and looks good making a ton of blocks,
sorry but what I'm not getting why I'm making a createObjectBox to instance, can I not just instance my object "rail.obj"?
I tried to put in my my track object (rail.obj) as the createObjectBox ID, but got really weird results.

nice pun
I'd better try and 'track' down where I'm messing up

Forgot to say, I won't be modifying/changing/removing the track after it's laid, for this scene at least it's going to be static.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 3rd Jun 2020 13:30
i created the box as a placeholder for the demonstration only; you would absolutely be using your own objects (rail.obj, etc) and instancing them/that.

it dawned on me after i wrote the above that you may be looking for a simple 2d array to hold your map/world/what have you. that would make things much easier and is probably what you were after in the first place.

i don't have time to write an example right now but there are examples of map editors throughout the forums.
xcode77
5
Years of Service
User Offline
Joined: 31st Jul 2018
Location:
Posted: 5th Jun 2020 08:27
Managed to solve where to put the code after a bit of trial and error.
Thanks again, it's working well now.

Login to post a reply

Server time is: 2024-04-20 03:27:15
Your offset time is: 2024-04-20 03:27:15