parenting two of the same type

Blitz3D Forums/Blitz3D Programming/parenting two of the same type

Ross C(Posted 2003) [#1]
hey ppl! I've got a potentially big problem here. i can't find a way to parent two types in the same collection together. I hope this can be done, or else i'll have to rework my whole animation shop :(

if it were arrays i could just do
EntityParent entity(0),entity(5)


Any ideas or help?


Pete Rigz(Posted 2003) [#2]
When I use types I like to give each new record a unique ID to make referencing easier in situations like this

If for example you have 20 records in a type, and you have given them a uniqueID from 1-20 you could do this...

objectiwantasparent=10
objectiwantaschild=4
for p.objects=each object
   if p\uniqueid=objectiwantasparent
      for c.objects=each objects
         if c\uniqueID=objectiwantaschild
            entityparent c\mesh,p\mesh
            exit
         end if
      next
      exit
   end if
next



Ross C(Posted 2003) [#3]
hi, thanks for the reply, but i'm sure how to go about doing that. My type structure holds all the entities.

e.entity=new entity
e\ent=createpivot()

is there any other way to get two types in the same collection to parent to one an other??


Ken Lynch(Posted 2003) [#4]
I think you'd need to have in your type something like:

type entity
Field entity
Field parent.entity
end type

But I've never tried this to see if it is possible.

It's not really clear what you are trying to do, a bit more explanation might help.


Ross C(Posted 2003) [#5]
ok, sorry.i have a bunch of pivots all stored in a type collection. my animation shop lets the user pick on entity then other and parents the two together.

The pivots are all in the one type collection. i need a way to say parent the first item in a type collection to say the fifth one. How do i do this, because i can only select one item at a time from the type collection, and i need to say

EntityParent e\ent,e\ent

the first one being at the beginning of the type and the second one being say fifth in the type


Ken Lynch(Posted 2003) [#6]
Well you could use different variables. Set e1.entity and e2.entity to point at the members of the type collection you want and then do.

EntityParent e1\ent, e2\ent


An example to parent the first with the last would be

e1.entity = First entity
e2.entity = Last entity

EntityParent e1\ent, e2\ent



big10p(Posted 2003) [#7]
Joker, surely your prog has code to pick the two entities with the mouse using CamerPick, or something. If so, you should have the two entity handles involved so you can just parent one to the other. The fact that you're storing the entity handles in a type doesn't matter - you don't have to access the entities using the ent field of the type to parent one ent to another. Or am I completely missing the point? Possibly. :)


Ross C(Posted 2003) [#8]
well, thanks first for the replys. this is how it works.

the user right clicks to put down a pivot. when this happens the program says

e.entity=new entity
e\ent=createsphere() ;<<to represent a pivot

so every time a pivot is made, it is placed directly within the type collection. the user then would click the first pivot and the code would jump to that point in the type collection by cycling thru them until it got to the right one.

The problem came when i clicked the next pivot, it lost the location of the last pivot selected in the type collection.

Ken, thanks for your ideas, but everytime i make a new entity, i would need to manually say
e3.entity=new entity
e4.entity=new entity


and since the number of pivots and entities is dynamic, i don't think it would be possible to keep track of them that way

but i solved it for anyone who's is interested (sorry guys for the poor explanation). here's what i did

findentity(child); <<child is the number assigned to the entity on creation in order to find it again

EntityParent e\ent,findentity(parent); << findentity(parent) will return the entity with the index number equal to the parent.



and that's that. thanks to the guy you helped me get that one :), and thank you to you'z for tryin to help. Much appreciated :D


Ken Lynch(Posted 2003) [#9]

Ken, thanks for your ideas, but everytime i make a new entity, i would need to manually say

e3.entity=new entity
e4.entity=new entity



No you don't need to do new entity all the time. Types are like a list

Item 1
Item 2
Item 3
Item 4

You only use New when you want to add to that list, I could say

e1.entity = First entity
e2.entity = Last entity


without using new as e1 and e2 are kind of pointers to items on the list.


Ross C(Posted 2003) [#10]
oh right, so if i have built up a type list

item 1
item 2
item 3
item 4

i could skip to the second one and say e1.entity=after e?, because i would be wanting to find one in the middle of the list as well.


Ken Lynch(Posted 2003) [#11]
Sort of. You can think of e.entity as a variable called e which has a value of custom type entity, so e can contain any one of the items in your list. Another quick example:

e.entity = First entity ; e points to the first item in the list
e = After e ; e now points to the second item in the list
e = After e ; e now points to the third item in the list


You can also do

e1.entity = First entity
e2.entity = First entity


So now you have two variables that both point to the same item in the list.


Ross C(Posted 2003) [#12]
oh rite, i wasn't really aware of that. with types i know enough to get me by, but thanks a lot for opening my eyes a bit more :)