At 1:24 PM +0100 1/31/02, Ola Arwidsson wrote:
I want to create a lot of small cubes with textures, (like dice)
and put them on a floor in my Rb3DSpace.
Now I create each cube by making an new object-from-pict for every
side in the cube, then putting all of these together in a
"cubeGroup". I then move this group, and append it to the
Rb3DSpace.Objects.
This is a good first approach. But it's worth noting that these are
very inefficient cubes -- much better would be a single TriMesh for
each cube. Are these textures something you have to compute on the
fly, or are they known ahead of time (so that you could paste them
into a 3D modeling program)?
It would be no problem to paste them into a 3D-modelling program. If
you know any program that I can use for this I would be glad. The
program I'm writing is mainly to test if speed and quality of Rb3D is
good enough for a game, so I'ts good if I do things in quite an
efficient way. (right now the program easily uses 100Mb of system
memory, and is slow,) But paying a lot of bucks or time just to get a
3D modelling program isn't worth it either. (yet).
In my case the most convenient would would be
secondCube= new Group3D
secondcube= firstCube.Clone
secondCube.MoveForward..../ Roll / Yaw
Leave off the first line. It does no good to say
foo = Something
foo = SomethingElse
since on the second line, you're completely undoing the effect of
the first line. So, all you need is secondcube=firstCube.Clone,
then move it wherever.
Well, thanks for noting, I haven't really understod when I need to
use New, to actually get an object. From dev. manual I think I read
that a declaration like 'Dim foo As anObject' only give a reference
(pointer?!) to an object, so I would need a New to actually create
the object. And this is true for all objects, except controls? And
most things are control, thats why so few New's are needed?
(I code above I undersand that Clone gives a new object3d.)
Apparently Clone cannot be done for a group ("no such method" error)
Not true. A Group3D is an Object3D, so it has all the same methods
defined (and more). But note that the result of the Clone method is
of type Object3D, so to store this in a Group3D you'd need to
typecast it.
(Though now that I think about it, though someGroup.Clone does
compile and run, I'm not sure how sensible the results are -- it
frankly never occurred to me that someone would try to use it this
way, so I'm not sure I've tested it.)
When I didn't get this through the compiler I thought it was "not
meant to be", because in a clone of a group, the group should be new,
but maybe the individual objects was not cloned, and a reference like
theNewGroup.Item(1).Yaw should turn also object 1 in theFirstGroup.
I'll try it again.
so I tried to clone each individual side in the cube, like
secondCube= new Group3D
secondCube.Append firstCube.Item(0).Clone // copy side 1
secondCube.Append firstCube.Item(0).Clone // copy side 2
Actually, your comments don't match your code here. You're copying
the first side (Item(0)) each time.
Just a typing mistake, in my code everything has other names.
This way I get a cube, but the textures are all looking very
strange, often only part of each texture is drawn.
Hmm. That's very odd. Can you reproduce this in a simple app?
Clearly you've found a bug but it's hard to tell from this exactly
where it is.
I'll try some more and let you know.
Is guess there are much more efficient ways to create a cube?
Quite so, especially if the textures don't need to change at runtime.
--
|