Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Moving Exterior Meshes to Interior via Script


Reneer
 Share

Recommended Posts

Hello everyone,

I'm currently trying to design a system that moves exterior meshes (such as statics, lights, furniture, etc) from the exterior worldspace to a (random) vanilla interior cell. Currently the script works as it is supposed to - objects are successfully moved from the exterior to the interior. However, a problem arises when the interior mesh is rotated in regards to its exterior mesh - if the interior mesh is rotated by X degrees, then all the moved exterior meshes will be off by that X degree.

Here are some screenshots in order to illustrate the problem:

Exterior Mesh:

EXteriorMesh.jpg

Interior mesh:

InteriorMesh.jpg

And here is the requisite code to accomplish this (note the trigonometry, which I was trying to use to move the meshes in respect to the Z angle of the interior door mesh):


		if (objectref != 0)		

;				if (player.GetInSameCell objectref == 0)

					; good...

					set objectx to objectref.GetPos X

					set objecty to objectref.GetPos Y

					set objectz to objectref.GetPos Z


					if (objectref.GetObjectType == 28)

						if (objectz < lowestzpoint)

							set lowestzpoint to objectz

							if (lowestzpoint < parentcellwaterheight)

								set lowestzpoint to (parentcellwaterheight + 100)

							endif

						endif

					endif


					set rotation to 0

					player.SetAngle Z exteriordoorzrot

					set rotation to (player.GetHeadingAngle objectref)

					set rotation to (rotation + (exteriordoorzrot - interiordoorzrot))

					Print "Player getheading: " + $rotation


					set objectxrot to objectref.GetAngle X

					set objectyrot to objectref.GetAngle Y

					set objectzrot to objectref.GetAngle Z		


					set tempdistance to exteriordoorref.GetDistance objectref - player.GetDistance exteriordoorref


					if (rotation < 0)	

						set newobjectx to interiordoorx - ((cos rotation) * tempdistance)

						set newobjecty to interiordoory + ((sin rotation) * tempdistance)

					endif


					if (rotation > 0)

						set newobjectx to interiordoorx + ((cos rotation) * tempdistance)

						set newobjecty to interiordoory - ((sin rotation) * tempdistance)

					endif


;					set tempdistancex to (objectx - exteriordoorx)

;					set tempdistancex to (abs tempdistancex)

;					set tempdistancex to ((cos rotation) * tempdistance) + tempdistancex


;					set tempdistancey to (objecty - exteriordoory)

;					set tempdistancey to (abs tempdistancey)

;					set tempdistancey to ((sin rotation) * tempdistance) + tempdistancey


					set tempdistancez to (objectz - exteriordoorz)

;					set tempdistancez to (abs tempdistancez)


;					Print "Exteriordoorref cell: " + $exteriordoorref.GetParentCell + ", objectref cell: " + $objectref.GetParentCell + ", interiorcell: " + $interiorcell


					if (objectref.GetObjectType == 28 && exteriordoorref.GetDistance objectref <= 400)

						; probably the exterior mesh of the house...

						set objectref to Apple

						set objectref to GetNextRef

						GoTo 1

					endif


					if (tempdistance <= 8000)

						; also good...

;						PrintC "RenIntStaticsNodeQuestScript: Moving exterior item to interior space..."

;						set newobjectx to (interiordoorx + tempdistancex)

;						set newobjecty to (interiordoory + tempdistancey)

						set newobjectz to (interiordoorz + tempdistancez)

						let tempobjectref := objectref.GetBaseObject

						let tempobjectref := interiordoorref.PlaceAtMe tempobjectref 1 0 0				


						if (objectzrot > 360)

							set objectzrot to (objectzrot - 360)

						endif

						if (objectzrot < 0)

							set objectzrot to (objectzrot + 360)

						endif


						let arraysize := (ar_Size intobjectreference) + 1


						ar_Resize intobjectreference arraysize


						ar_Insert intobjectreference arraysize tempobjectref


						tempobjectref.SetPos X newobjectx

						tempobjectref.SetPos Y newobjecty

						tempobjectref.SetPos Z newobjectz 

						tempobjectref.SetAngle X objectxrot

						tempobjectref.SetAngle Y objectyrot

						tempobjectref.SetAngle Z objectzrot

							Print "Exterior door x, y, z: " + $exteriordoorx + " " + $exteriordoory + " " + $exteriordoorz + ", z-angle: " + $exteriordoorzrot

							Print "Object x, y, z: " + $objectx + " " + $objecty + " " + $objectz + ", cell: " + $exteriorcell + ", tempdistance: " + $tempdistance

							Print "Tempdistancex: " + $tempdistancex + ", tempdistancey: " + $tempdistancey + ", tempdistancez: " + $tempdistancez

							Print "Interior door x, y, z: " + $interiordoorx + " " + $interiordoory + " " + $interiordoorz + ", z-angle: " + $interiordoorzrot

							Print "Placed object (" + $tempobjectref.GetFormIDString + ") at position: " + $newobjectx + ", " + $newobjecty + ", " + $newobjectz + " in cell: " + $interiorcell + ", rotation: " + $rotation

					endif

;				endif

			set objectref to Apple

			set objectref to GetNextRef

			GoTo 1

		endif

So, anyone have any inkling of how I might accomplish this? ^.^

Edit: Updated the script a bit. Uses unit circle stuff, but it's still a smidgen off... plus the added meshes still aren't being properly rotated to reflect the rotation change in the interior mesh.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...