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: Thu, 17 Feb 2005 19:50:01 -0500
Delivered-to: realbasic-games at lists dot realsoftware dot com
References: <20050217180022 dot B059172FCEA at lists dot realsoftware dot com>
On Feb 17, 2005, at 1:00 PM, realbasic-games-request at lists dot realsoftware dot com wrote:

No, that's not the case.  Remember that a Group3D IsA Object3D.  So,
Rb3DSpace.Objects.Item(4) may be a Group3D or it may be some other
sort of Object3D.

 The funny thing is that all Group3D objects return a index of 0
(not nil, since they are the first objects I appended to the
RB3D-Space), and the next appended object3D returns it's logically
following index number.

I don't understand what you mean by "returns" -- I see the index as
something you plug into the Item accessor to look up an object, not
something you get back from some other method.

Greetings,
Firstly excuse my inaccurate use of language (my professional medium is rather plants and dirt, not OOP). After reading your suggestions I looked very closely at what is happening. You are right (of course). The index of the Rb3DSpace in fact correctly reflects each Groupd3D appended to it. The actual problem is this: In the game there are a number of objects the user can control (for this example let's asume they are three). They are stored in an global array. The array has been declared to be of MyObjects type. MyObjects is a subclass of Group3D and has a bunch of additional properties. I use the array index to refer to the object the user has currently selected and is getting instructions. I tried following code to select the object the user has clicked on in the Rb3DSpace MouseUp event (MouseDown simply returns true):
  Dim which as Object3D
  dim id as integer

  which=me.FindObject(x,y)
  if which=nil then return
for id=0 to NumMyObjects // this property stores the number of user-controlable objects in the game
    if MyObjectsArray(id)=which then exit
  next
  if id=NumShips+1 then Return
and so on // the rest of the code handles the change over to the selected object , which i hoped to be MyObjectsArray(id).

The thing is, the 3D geometry of all the Group3D objects stored in MyObjectsArray is the same (they are cloned). Because of this I suspect the comparison "if MyObjectsArray(id)=which" resolves to true for all the objects in the array, and thus I was always ending up with the index id=0, which missled me to believe all the indexes of the Group3D objects were 0.

I run a hoop around this problem by using this comparison instead:
if MyObjectArray(id).Position.x=which.Position.x and MyObjectArray(i).Position.z=which.Position.z then exit // y-dimension has no relevance As mentioned, this works, but if the player clicks on the gunturret of the Group3D there is no selection, because the coordinates are different.

No, all positions are global, and BTW, if you just want the position
clicked you should be using FindPoint, not FindObject.  But see above
-- the correct solution really is to use FindObject and not worry about the point clicked at all.

Yes, confirmed that too, so I would need to do a comparison to the gunturret-coordinates too, but I was hoping to avoid this. I don't like to many if, if ,if lines in my code.

Cool, I'm excited about your project too. Have any screen shots to share?

Well, I might have something available as soon as it may be deemed worhty to be shown around (maybe 1 or 2 months). For now imagine nicely rendered, detailless objects with elegant animation in a vast, as of yet empty expanse. I was more advanced in the spritesurface version, but I needed to take a few steps back to recode for Rb3DSpace. Catching up fast, though.

Cheers,
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>