PDA

View Full Version : Help about 2 objects that go in touch


TheZag
06-13-2009, 12:05 PM
Where can I find a tutorial about:


An Object is Family A
Another Object can be A, B or C

AnObject = Family A
AnotherObject = Family A, or B or C

If "AnObject" HIT "AnotherObject"

If "AnotherObject" SameFamily than "AnObject"
then...

else

.....

etc. etc.

Does exist a tutorial about something like this ?

Thanks for any help or replyes.
Giuseppe

terrabite
06-13-2009, 12:20 PM
hi Guiseppe,

if you want to have "families" I think you would need to do that with metadata

you could have a variable named Family, and the value could be checked to see if it matched

but in your scene (unless this is a different project), since the images would change on the objects, it is the name of the images that need to be checked and images don't have metadata, only objects. I think you could store information and images in arrays, but that would be a lot of work.

how about naming your Images with the family name as a prefix? A_SomeImage.jpg, b_AnotherImage.jpg, C_Yetanother.jpg?

Sue

TheZag
06-13-2009, 12:27 PM
Thanks Sue !

...Family was just an example...
Each of ten pictures have a name, but I think is not "a name problem".
I just saw an example of the command under Animations, which is "Material Stage Image" : I think I can work on it...
It's very near to what I was looking for...
Now... A 2D Screen Blit, can "hit" a 3D Object ???
(do there is any sample about this?)

Giuseppe

terrabite
06-13-2009, 12:46 PM
you will need to do scripting- look at the code in the Assembler_Base scene, SceneObjectAniCallback- it is similar up to about line 16

if you set an icon (screen blit) to be the cursor when a person picks it and holds the mouse button down (drag and drop style),
when the person lets the mouse button up, you check for a match by
1-getting the x,y screen position of the cursor- GetCursorPos
2- getting the object that that position- PickObjectAtPoint
3- get the material on the object - GetObjectMaterialByIndex
4- get the image in its diffuse stage- GetStageInfoByIndex
5- getting the stage image for the cursor object's material
6- checking for a match in the names (in this example, the first character of the names- the "family"
if there *is* a match, you change the image in the hit object's material diffuse stage to match the icon's stage image
and if you wanted, you could change the icon to the one that used to be on the object

TheZag
06-13-2009, 01:04 PM
Really... really usefull...
Thanks a lot!
Giuseppe

TheZag
06-13-2009, 02:01 PM
you will need to do scripting- look at the code in the Assembler_Base scene, SceneObjectAniCallback- it is similar up to about line 16

if you set an icon (screen blit) to be the cursor when a person picks it and holds the mouse button down (drag and drop style),
when the person lets the mouse button up, you check for a match by
1-getting the x,y screen position of the cursor- GetCursorPos
2- getting the object that that position- PickObjectAtPoint
3- get the material on the object - GetObjectMaterialByIndex
4- get the image in its diffuse stage- GetStageInfoByIndex
5- getting the stage image for the cursor object's material
6- checking for a match in the names (in this example, the first character of the names- the "family"
if there *is* a match, you change the image in the hit object's material diffuse stage to match the icon's stage image
and if you wanted, you could change the icon to the one that used to be on the object


Which command you use to check the mouse status ?
(IsMouseButtonDown <button>) ???

It's strange but if I select 0, it works the right and not the left button.
If I select 2 just the contrary.

when it's written the command above return T, means also 1 ?
does this make sense ?:

(SetQ MouseStatus (IsMouseButtonDown 0) )

to check:

(If (/= MouseStatus T)
(progn
(SetQ MyPict (GetObjectMaterialByIndex <object> <index>))

(If (= MyPict 4)
(progn
... etc
(exit 1)
)
)
)
)

Does is it right ?

TheZag
06-14-2009, 03:21 AM
:(
I don't find any code in the Assembler_Base scene, inside "SceneObjectAniCallback".....

terrabite
06-14-2009, 08:04 AM
I think I see what happened- did you open the Assembler_Base file normally, or did you drag it in from the asset browser? When I dragged and dropped it from the asset browser. a lot of the code was missing!

Try opening it the normal way.

Here's the code that you need to see:

;*************** this callback deals with dropped on objects ****************

(if (= Mode 0)(Exit T)) ; you are not in drag N Drop mode, so exit

(if (= (GetCursorObject) "")(exit T)) ; you weren't dragging an object so leave callback


(TriggerAnimation (GetCursorObject) "Set as Cursor01" 1) ; reset the cursor

;*** get cursor position
(SetQ xxxx (nth 0 (GetCursorPos)))
(SetQ yyyy (nth 1 (GetCursorPos)))


;*** get the object at that position if there is one
(SetQ obj (PickObjectAtPoint xxxx yyyy))


;*** if there was nothing under the cursor, exit
(if (= Obj nil)(progn
(ObjectShowHide (strcat "Icon " Current) 1) ; show screen blit again
(setq current "") ; clear the cursor flag
(exit T) ; leave if the cursor was not over an object at all
)
)

TheZag
06-14-2009, 10:09 AM
Hello Sue.
Good morning... or afternoon.
Here in Italy are 5 past 7 p.m.

I'm working on it.

Did Ben send you the file I'm working on?

Anyway...
A question. This code you write in the "SceneObjectPick" section ?
Because I was thinking... There I have the "pick" (left mouse down) option = true.
But where the "mouse up" ???

Is it possible to discuss more through skype?
Thanks

TheZag
06-14-2009, 10:19 AM
Yes, you was right.
I found the code...