BASIC

Author Topic: Clone object  (Read 4594 times)

MrTAToad

  • Guest
Clone object
« on: 2012-Feb-25 »
Would be handy if a 3D object could be cloned, rather than having to (re)load the same object over and over.

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: Clone object
« Reply #1 on: 2012-Feb-25 »
Why clone/reload a object? You can load it one time and draw it over and over again, just like sprites.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Offline fuzzy70

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 828
  • Look left, Look right, LOOK OUT!!
    • View Profile
Re: Clone object
« Reply #2 on: 2012-Feb-25 »
Do you mean "Instancing" type clones?

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

MrTAToad

  • Guest
Re: Clone object
« Reply #3 on: 2012-Feb-25 »
Oh yes, usually I do use the same object multiple times...

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10723
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Clone object
« Reply #4 on: 2012-Mar-15 »
Why would you?

Offline mentalthink

  • Prof. Inline
  • *****
  • Posts: 3366
  • Integrated Brain
    • View Profile
Re: Clone object
« Reply #5 on: 2012-Mar-15 »
I think Clone, consume less memory... or something... I read in some render engines... almost are Unbiased renders... speaks about million of clones of 3d meshes whitout consume more memory or CPU, I´m not understand this think, but if they talk abouit this I think it´s thru...

Will be very interesting have this Clone Command, and don´t consume anything in te device... if it´s possible, how I say, I don´t have any idea about this advanced things in programming.

Offline fuzzy70

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 828
  • Look left, Look right, LOOK OUT!!
    • View Profile
Re: Clone object
« Reply #6 on: 2012-Mar-15 »
Clones are useful for things like trees etc, Why model 50 different trees when you can make 2-3 & clone them with say a random rotation & then you have your forest with a minimal memory footprint.

Here is a picture I created that is made from 1 flat plane (the floor) & 1 cube which I cloned.

Lee



[attachment deleted by admin]
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: Clone object
« Reply #7 on: 2012-Mar-15 »
But you wont need a new clone command for that, just load (or create) one cube and draw it thousand times...
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Offline fuzzy70

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 828
  • Look left, Look right, LOOK OUT!!
    • View Profile
Re: Clone object
« Reply #8 on: 2012-Mar-16 »
But you wont need a new clone command for that, just load (or create) one cube and draw it thousand times...

Then obviously I do not understand the original question of this post. The picture I posted is an object type called a cloner & you feed it whatever you want, could be 1 cube or any number of objects & you tell it what to do with them like scale/rotate etc, amount of clones plus other options all from 1 set of parameters. That to me sounds like a clone command

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 930
  • KodeSource
    • View Profile
    • KodeSource
Re: Clone object
« Reply #9 on: 2012-Mar-16 »
Ya, I wasn't too sure what the original request meant either.

Right now with GLBasic, you can load ONE model into memory, and in the SAME frame, draw it as many times as you want, at different locations, each with it's own scale and rotation.  Kinda like a cloned object.

I'm not sure how GLBasic / OpenGL handles this behind the scenes however.  It may transfer one copy of the model for each clone to the OpenGL framework, repeating this each frame, which may be time and memory consuming.  It would be nice to transfer just ONE copy and get OpenGL to use that copy for all instances.  I don't know.  It'd be nice if it kept it in OpenGL between frames so it doesn't have to move it to OpenGL each frame (is that what a 'Vertex Buffer Object' is?)

Or, maybe a function to 'copy' a model in GLBasic.  Then you can alter this 'copy' using the GLBasic vertex commands perhaps to give it a unique feature (color / texture, or different vertex locations, more/less vertices, etc).  But I don't think that is why MrTAToad wanted this.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Offline fuzzy70

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 828
  • Look left, Look right, LOOK OUT!!
    • View Profile
Re: Clone object
« Reply #10 on: 2012-Mar-16 »
The example I posted the object that is being cloned is only stored once, the only extra data that is stored is the position/rotation etc of the clones. With a simple cube obviously the memory savings are very small as it only consists of 8 points & 12 polys. My example uses a rounded cube with 248 points & 266 polys & is cloned 100 times  so the memory saving is considerably more, also the screen updates are noticeably quicker then having 100 manually placed items. It is using openGL as if I switch the prefs to software rendering I get bounding boxes instead of the object along with huge slow down when I rotate the scene.

I tried looking on google & found some examples but was hard to work out what was best, along with some using hardware shaders & what version of openGL supports what it all got more & more confusing to me  :D

Think I will just stick to my modelling/rendering packages with regards to 3D for the present time  =D

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

MrTAToad

  • Guest
Re: Clone object
« Reply #11 on: 2012-Mar-20 »
It probably wasn't a good suggestion :)