#1 26-07-2010 16:54

From: UK
Registered: 09-11-2008
Posts: 189

Attach At Center?

I'm trying to create a CLEO Debugger (by combining scripts that I've made for debugging in the past) and it's going pretty well so far...


The little red dot refers to CornerA of the object, thus giving information on the central point of the object when rotating with the Z axis... This thing is created according to what I've needed in the past, so it provides useful information. A green one has been added to CornerB but didn't function in that screenshot.

The idea behind #MALE01 (who is going to be invisible) is that I could place him at the center of the object (between CornerA and CornerB) for easier rotation. Usually the object would rotate at it's natual center point (CornerA) but the plan is that it will rotate from the middle. The object is positioned accordingly with some math:

07E4: get_model TEMP1 dimensions_cornerA_to TEMP5 TEMP6 TEMP7 dimensions_cornerB_to TEMP2 TEMP3 TEMP4
0017: TEMP2 /= -2.0
0017: TEMP3 /= -2.0
0017: TEMP4 /= -2.0
0337: set_actor VAR2 visibility 1
04D7: set_actor VAR2 locked 1
0619: enable_actor VAR2 collision_detection 0
02AB: set_actor VAR2 immunities BP 1 FP 1 EP 1 CP 1 MP 1
069B: attach_object VAR1 to_actor VAR2 with_offset TEMP2 TEMP3 TEMP4 rotation 0.0 0.0 0.0

However, problems with rotation occur. In order to properly rotate the object while attached, 069B must be used. However the rotation is then relative to CornerA of the object, not the center.


What I need is some sort of math to get the value to pass to the with_offset in order to keep #MALE01 in the center of the object. This will mean rotating an object changes it's coords as well, but will ensure the most ease when changing the object rotation AND, due to my camera code centering on the actor (in order to view the center of the object) keep the camera in the right position, so rotating the object doesn't make it go off-screen.

Here's one of the codes I tried...

02F6: TEMP2 = sine VAR7
02F7: TEMP3 = cosine VAR6
0017: TEMP2 /= -2.0
0017: TEMP3 /= -2.0
0017: TEMP4 /= -2.0
069B: attach_object VAR1 to_actor VAR2 with_offset TEMP2 TEMP3 TEMP4 rotation VAR6 VAR7 VAR8

VAR6 is the X Angle.
VAR7 is the Y Angle.

I think the sin/cos things should be the other way round, but it seemed to do the opposite of what I wanted that way...


Board footer

Powered by FluxBB