This is not as good as I first thought. Ground objects are missing. statics that make up the ground are missing. In my code, it's as if everything below a certain point are found to be intersecting with the AABB (rough) and not placed. Any ideas?
🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Coordinates intersecting - ballpark answer needed
You might share your code, sounds like some folks here might have some familarity with the system(s) you are interacting with. Without code and context it's hard to idea.
Quite true, quite true. Here's the function that calculates position of objects to be placed in the interior cell:
ScriptName FnPopulatePlacementArray
;
Ref rObjectRef
Ref rInteriorDoor
Ref rExteriorDoor
Float fAngleFunc
Float fIntDoorX
Float fIntDoorY
Float fIntDoorZ
Float fIntDoorZRot
Float fExtDoorX
Float fExtDoorY
Float fExtDoorZ
Float fExtDoorZRot
Float fObjX
Float fObjY
Float fObjZ
Float fObjZRot
Float fTempX
Float fTempY
Float fTempZ
Short bDoneFlor
Short bDoneCont
Short bDoneActi
Short bDoneFurn
Short bDoneStat
Short bDoneTree
Short bDoneLite
;
Begin Function { rInteriorDoor, rExteriorDoor, fAngleFunc }
Let fIntDoorX := rInteriorDoor.GetPos X
Let fIntDoorY := rInteriorDoor.GetPos Y
Let fIntDoorZ := rInteriorDoor.GetPos Z
Let fIntDoorZRot := rInteriorDoor.GetAngle Z
Let fExtDoorX := rExteriorDoor.GetPos X
Let fExtDoorY := rExteriorDoor.GetPos Y
Let fExtDoorZ := rExteriorDoor.GetPos Z
Let fExtDoorZRot := rExteriorDoor.GetAngle Z
if (fIntDoorZRot > 360)
Let fIntDoorZRot -= 360
endif
if (fIntDoorZRot < 0)
Let fIntDoorZRot += 360
endif
if (fExtDoorZRot > 360)
Let fExtDoorZRot -= 360
endif
if (fExtDoorZRot < 0)
Let fExtDoorZRot += 360
endif
Label 1
if (rObjectRef != 0)
;start deploy
Let fObjX := rObjectRef.GetPos X ; objectx
Let fObjY := rObjectRef.GetPos Y
Let fObjZ := rObjectRef.GetPos Z
Let fTempX := (fObjX - fExtDoorX) ; tempdistancex
Let fTempY := (fObjY - fExtDoorY)
Let fTempZ := (fObjZ - fExtDoorZ)
; Let tempdistancehyp := (tempdistancex * tempdistancex + tempdistancey * tempdistancey)
; Let tempdistancehyp := sqrt tempdistancehyp
; Store base object:
ar_Append DynLODq.avToPlace ( rObjectRef.GetBaseObject )
; Store object's X position:
ar_Append DynLODq.avToPlace ( fIntDoorX + fTempX * Cos fAngleFunc + fTempY * Sin fAngleFunc ) ; newobjectx
; Store object's Y position:
ar_Append DynLODq.avToPlace ( fIntDoorY - fTempX * Sin fAngleFunc + fTempY * Cos fAngleFunc )
; Store object's Z position:
ar_Append DynLODq.avToPlace ( fIntDoorZ + fTempZ )
; Store objects X rotation:
ar_Append DynLODq.avToPlace ( rObjectRef.GetAngle X ) ; objectxrot
; Store object's Y rotation:
ar_Append DynLODq.avToPlace ( rObjectRef.GetAngle Y )
; Store object's Z rotation:
Let fObjZRot := rObjectRef.GetAngle Z
Let fObjZRot := (fAngleFunc + fObjZRot) % 360
if (fObjZRot > 360)
Let fObjZRot -= 360
endif
if (fObjZRot < 0)
Let fObjZRot += 360
endif
ar_Append DynLODq.avToPlace ( fObjZRot )
; Store object's scale:
ar_Append DynLODq.avToPlace ( rObjectRef.GetScale )
Let fTempX := (fObjX - fExtDoorX) + fIntDoorX
Let fTempY := (fObjY - fExtDoorY) + fIntDoorY
Let fTempZ := (fObjZ - fExtDoorZ) + fIntDoorZ
Let rObjectRef := Apple
Let rObjectRef := GetNextRef
Goto 1
else
Let rObjectRef := Apple
if (bDoneStat == 0)
Let rObjectRef := GetFirstRef 28 2
; Let objecttypecode := 28
Let bDoneStat := 1
Goto 1
endif
if (bDoneTree == 0)
Let rObjectRef := GetFirstRef 30 1
; Let objecttypecode := 30
Let bDoneTree := 1
Goto 1
endif
if (bDoneLite == 0)
Let rObjectRef := GetFirstRef 26
; Let objecttypecode := 26
Let bDoneLite := 1
Goto 1
endif
if (bDoneFlor == 0)
Let rObjectRef := GetFirstRef 31
; Let objecttypecode := 31
Let bDoneFlor := 1
Goto 1
endif
if (bDoneCont == 0)
Let rObjectRef := GetFirstRef 23
; Let objecttypecode := 23
Let bDoneCont := 1
Goto 1
endif
if (bDoneActi == 0)
Let rObjectRef := GetFirstRef 18
; Let objecttypecode := 18
Let bDoneActi := 1
Goto 1
endif
if (bDoneFurn == 0)
Let rObjectRef := GetFirstRef 32
; Let objecttypecode := 32
Let bDoneFurn := 1
Goto 1
endif
endif
End
Here's the function that takes the calculations for XYZ and actually places the objects:
ScriptName FnPlaceInteriorObjects
;
Array_var avIter
Short iIterKey
Ref rBigMesh
Ref rInsideDoor
Ref rIterTemp
Ref rToPlace
Float fMeshX
Float fMeshY
Float fMeshZ
Float fMSize
Float fPSize
Float fXPos
Float fYPos
Float fZPos
Float fXRot
Float fYRot
Float fZRot
Float fScal
;
Begin _Function { rBigMesh, rInsideDoor }
Let fMeshX := rBigMesh.GetPos "X"
Let fMeshY := rBigMesh.GetPos "Y"
Let fMeshZ := rBigMesh.GetPos "Z"
Let fMSize := rBigMesh.GetEditorSize
Let avIter := ar_Construct "StringMap"
ForEach avIter <- DynLODq.avToPlace
Let iIterKey := avIter["key"]
If ( iIterKey ) == 0 || ( iIterKey % 8 ) == 0
Let rIterTemp := *avIter
Let fPSize := GetEditorSize rIterTemp
Continue
Endif
If ( iIterKey ) == 1 || ( iIterKey % 8 ) == 1 ; X position
Let fXPos := *avIter
Continue
Elseif ( iIterKey ) == 2 || ( iIterKey % 8 ) == 2 ; Y position
Let fYPos := *avIter
Continue
Elseif ( iIterKey ) == 3 || ( iIterKey % 8 ) == 3 ; Z position
Let fZPos := *avIter
Continue
Elseif ( iIterKey ) == 4 || ( iIterKey % 8 ) == 4 ; X rotation
Let fXRot := *avIter
Continue
Elseif ( iIterKey ) == 5 || ( iIterKey % 8 ) == 5 ; Y rotation
Let fYRot := *avIter
Continue
Elseif ( iIterKey ) == 6 || ( iIterKey % 8 ) == 6 ; Z rotation
Let fZRot := *avIter
Continue
Elseif ( iIterKey ) == 7 || ( iIterKey % 8 ) == 7 ; Scale
Let fScal := *avIter
Endif
; "fMeshX/Y/Z" should be the center point of interior mesh along corresponding axes,
; the above should be <= X/Y/Z length divided by 2
If Abs(fXPos - fMeshX) <= 915 / 2 && Abs(fYPos - fMeshY) <= fMSize / 2 && Abs(fZPos - fMeshZ) <= fMSize / 2
Continue
Endif
Let rToPlace := rInsideDoor.PlaceAtMe rIterTemp 1, 0, 0
rToPlace.SetPos "X" fXPos
rToPlace.SetPos "Y" fYPos
rToPlace.SetPos "Z" fZPos
rToPlace.SetAngle "X" fXRot
rToPlace.SetAngle "Y" fYRot
rToPlace.SetAngle "Z" fZRot
rToPlace.SetScale fScal
Loop
End
Any help would be appreciated.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement