Reflect/Mirror Model based on Primary Part

Hello there, I need help finding or making an algorithm function that reflects a model based on a models PrimaryPartCFrame. I’ve searched around the devforums but couldn’t quite find any resources to do this specific function. Here is a visualization to clarify what I am looking for.

Original Model:

Reflected Model:
image

The PrimaryPartCFrame you can see is the block with the big arrow on it, I would like reflect all the blocks part of the model from the Center of the PrimaryPart. This is an implementation that I would like to add as an in-game calculation with scripts, and not looking for a plugin.

I would appreciate any help, articles, and resources, thanks!

I guess you can use symmetry for this, taking count the arrow thing as a symetry line, you can simply rotate the parts 180 degrees, and reposition them, which is the tricky part.

To reposition them, we need to first to deal with the part’s local space so we need to do

local cframe = part.CFrame:ToObjectSpace(arrow.CFrame)

Instead of using the part’s normal cframe to do calculations we need to use this cframe variable.

Then, assuming that the arrow is always facing the Z direction, we can simply subtract the arrow’s C coord with the part’s X coord, and reposition the part with the same Z and same Y but the X coord has to be the result of the subtraction time 2.

for i, v in pairs (the parts) do
    local cframe = v.CFrame:ToObjectSpace(arrow.CFrame)
    local distance = math.abs(cframe.Position.X - arrow.Position.X)
    v.CFrame = CFrame.new(v.Position.X + distance*2, v.Position.Y, v.Position.Z) * CFrame.Angles(math.rad(180), 0, 0)

Not sure if this would work, but try it out and try to salvage some info from it

This will not work, the arrow’s rotation and position vary throughout the map, that it why I would preferabaly use the arrow’s CFrame for calculations.

Did you try it? It would work I think, because I’m using the local space of the arrow part (by using :ToObjectSpace()) which means rotation won’t affect anything.

Just take each part, go primaryPart.CFrame:ToObjectSpace(part.CFrame), dooo…

local components = {primaryPart.CFrame:ToObjectSpace(part.CFrame):GetComponents()}
components[1] = -components[1]
local newCFrame = primaryPart.CFrame * CFrame.new(unpack(components))

Reverses it on the X axis. Does not do rotation though.

@starmaq @anon66957764
I’ve tried both of these methods, they both seem to not have the outcome I am looking for and as well break models that are put onto this arrow plane. It is possible that I could be looking for a much complex algorithm that can solve for this, I will continue to do more research and try and find more solutions, in the mean time if anyone could still help get closer to a solution.

Here is a copy of the arrow to help base calculations off of: Arrow.rbxm (2.4 KB)

This is an example of the outcome from @starmaq method:


All the parts sort of seem to scatter.

This is an example of the outcome from @anon66957764 method:


It seems to rotate the whole model 180 degrees and sometimes breaks parts, example in the middle arrow with the yellow blocks was a parabola connected like rope, however the parts rotated in a way that disconnected this, similarly in the arrow with the green blocks, it seemed to break the bridge’s support beams.

Haha, I typed that in the textbox without any testing. I suppose I can start up a Studio instance and work on a better method.  S t a y   t u n e d

1 Like

Here you go.

Mirrorer.rbxm (9.3 KB)

I had to steal some code from @Stravant’s Model Reflect plugin, but I wrapped it in a somewhat convenient API.

1 Like