realbasic-games
[Top] [All Lists]

Re: How to find a Group3D in a RB3DSpace

To: realbasic-games at lists dot realsoftware dot com
Subject: Re: How to find a Group3D in a RB3DSpace
From: "Heinz J. Gattringer" <heinzjos at uio dot satnet dot net>
Date: Sat, 19 Feb 2005 15:15:50 -0500
Delivered-to: realbasic-games at lists dot realsoftware dot com
References: <20050219180019 dot 6E676739937 at lists dot realsoftware dot com>
On Feb 19, 2005, at 1:00 PM, realbasic-games-request at lists dot realsoftware dot com wrote:

I havn't read the topic from the beginning but according to my own
experience, the best thing to do to find an object in an array is to
have an ID property (an ID is a unique number delivered to any new
object when it is created) since you re using your own subclass of
Group3D, just add an integer call ID and have a global that would keep
track of what was the last ID you assigned, this would give something
like this:

(Have a global integer called for example LastID)
when creating your Group3D:

------------------------------------------------------------
Dim m As New MyObject

'fill m with what you need

m.ID = LastID
LastID = LastID + 1
m.Object3D.Append ACloneOfTheObject

Your suggestion sounds logical and I am sure it would work. It seems a bit redundant though for my purposes since all MyObjects are strored in an array anyway, so the index of that array provides an unique enough identifier for the objects, without the need for a new property ID. And I believe it would not solve the problem.

I think what it really comes down to is this: when the player clicks on an object in the Rb3DSpace I store that object in the local variable 'which' by way of "which = me.FindObject(x,y)". I then compare the object 'which' to all objects in the build in Rb3DSpace.Objects array. For some reason the
if Rb3DSpace.Objects.item(id)=which
comparison is always true when 'which' is a Group3D and it is compared to another Group3D in the Rb3DSpace.Objects array (by the way, at this time they all share the same cloned geometry). That way I always end up with the index-number of the first Group3D appended to the Rb3DSpace. With just plain Object3Ds (that is, when the player clicks on an object that is an independent Object3D) the comparison works fine, I end up with the index I need and can move on with my life. So it is the Group3Dobject1=Group3Dobject2 comparison that is creating the fuzz I believe.

For now I think I will solve the problem by using Object3D entities only. And during the construction of 'aggregate' or multi-part objects I will do something along the lines you suggest. I will give all Object3D objects an identifying property (call it groupID if you want), that will hold a number identifying the aggregate object they belong to. This GroupID number will have to be exactly the same as the array index number of the aggregat object in the MyObjects array. That way, my comparison line would end up like this
if Rb3DSpace.Objects.item(i)=which then
   id=which.groupID
   exit
end if

Thanks for your interest,
Heinz Jose

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>