Notifications
Clear all

[Closed] Specifying separate origin for objects in export script

Hi all,

I’m still working on my export script for the X-Plane obj specification. And a couple of things are still bugging me.

When exporting 3d Cockpit models, there’s the ability to specify animation parameters…The tags are ANIM_trans and ANIM_rotate.

ANIM_begin

   			This command marks the beginning of an animation subsection.		 			All further geometry commands are affected by the animation 			commands between this ANIM_begin and the command until an 			ANIM_end is encountered.
   		[b]ANIM_end[/b]
   			This defines the end of an animation section.  Geometry 			following this is not affected by the animation commands.
   		[b]ANIM_rotate <x> <y> <z> <r1> <r2> <v1> <v2> <dataref>[/b]
   			This defines a rotation command.  X, Y and Z define 			an axis of rotation - they should form a unit-length  			vector.  r1 and r2 represent the angle of counterclockwise 			rotation when the dataref is at its minimum and maximum values 			respectively, when looking down at the 'arrow' of the vector. 			(So if the vector is 0,1,0 then a positive rotation is counterclockwise 			when viewed from above.).  v1 and v2 are the minimum and maximum dataref 			values for calibration purposes.  Dataref is the string name  			of a sim dataref.
   		[b]ANIM_trans <x1> <y1> <z1> <x2> <y2> <z2> <v1> <v2> <dataref>[/b]
   			This defines a translation command.  x,y,z 1 and 2 are two 			offset distances, for when the dataref is at its minimum and 			maximum values; v1 and v2 are the expected min and max for the 			dataref and dataref is the string name of the dataref.

The ANIM_trans is pretty easy to figure out…you have a distance for minimum and a distance for maximum, the values from the dataref, and the dataref itself. for example, a throttle animation sequence looks like this:


ANIM_begin
ANIM_trans 0.000000 0.000000 0.000000 0.000000 0.000000 -0.135000 0.000000 1.000000 sim/flightmodel/engine/ENGN_thro[0]
TRIS 0 165 // F-18E_Throttle01
ANIM_end

which basically means the throttle is at its origin if the throtte value is 0 and it moves -.135 meters along the z axis if the throttle value is 1 (full)

Easy stuff…

Problem comes when you try to do a rotation…you use the ANIM_trans to specify the origin of the rotation, because its usually not going to be the same origin as the object itself which is usually 0,0,0.

here’s an example of a throttle that rotates instead of slides:


ANIM_trans 0.400000 0.760000 4.000000 0.400000 0.760000 4.000000 0.000000 0.000000 none
ANIM_rotate 1.000000 0.000000 0.000000 0.000000 -60.000000 0.000000 1.000000 sim/flightmodel/engine/ENGN_thro[1]
ANIM_trans -0.400000 -0.760000 -4.000000 -0.400000 -0.760000 -4.000000 0.000000 0.000000 none

the ANIM_trans specifies that the rotation will occur .4, .76, 4 from the origin of the object…This is what I need to be able to specify somehow via my plugin…should I use a dummy? or a simplemod center???

The problem is further complicated by the fact that prior to exporting the geometry I grab a copy of it in memory and perform a scale and rotate so it matches the scale and origin of the simulator…using the following code:


		tmesh = snapshotAsMesh allobj[i]
		curMeshName = allobj[i].name

		if ScaleConv.state == true then
		(
			scale tmesh [.0254,.0254,.0254]
		)
		if RotXNeg90.state == true then
		(
			rot_XNeg90 = eulerangles -90 0 0
			rotate tmesh rot_XNeg90
		)

tmesh is what I perform all of my exports on…

Any ideas on how to specify a separate origin and pull its difference to apply to the ANIM_trans for rotations?

3 Replies

I think a dummy would be better for specifying the rotation origin…I’ve used dummy’s before in other scripts such as the old NWMax for neverwinternights. I just don’t know how to implement them, and what happens to them when I scale and rotate my selection?

If I use a dummy the issues would be A) How would the script know there’s a dummy for rotation B) Does the dummy follow the scale/rotation

I imagine the parent/child relationship might be somewhere to start? Make the dummy a child of the mesh that will be rotating? Would I want to have the rotation paramters (like the dataref and whatnot) as scripted properties of the dummy or as a separate simplemod for rotation?

Nobody has any ideas?