Reflecting Model

How does Starvant’s Model Reflect Plugin actually work??

I really need to code a function that reflects a given model horizontally or vertically, what is the algorithm, how do i do it?

I have checked starvant’s plugin code and i got lost pretty fast (No comments explaining each function what it does :frowning:)


That’s likely because he didn’t really expect anyone to view his code. I’ll check out the source in a while if I can.

1 Like

EDIT: I thought you meant how to use the plugin. Oops.

I use Model Reflect on a daily basis; basically you select a model or a group of parts (CSG not supported) and when you click the plugin itself, your cursor will have a blue studded plate attached to it. If you want to reflect it horizontally (i.e left to right), select any plane or axis perpendicular to the baseplate (given you have one).

1 Like

I haven’t used Stravant’s Model Reflect plugin, but I wrote a script that (I assume) has the same effect. Simply put, to flip symmetrical objects, all you have to do is to flip their position and orientation. This means that for basic parts, cylinders etc. it will work fine. For a more advanced object like a mesh it is much more difficult (i.e. you need a second mesh), and what I wrote only covers the first instance. Welds are also another edge case that I didn’t need to deal with, as I wasn’t making a generalised plugin.

Basically, you want to flip their CFrame across a certain axis:

    local function newCFrame(pos,vx,vy,vz)
      return, pos.y, pos.z, vx.x, vy.x, vz.x, vx.y, vy.y, vz.y, vx.z, vy.z, vz.z)

    local function flipVector(vec)
      return vec *,1,-1)

    local function flipCFrame(cfr)
      return newCFrame(

I was only writing it for a specific case, so this specifically flips across the Z axis (the plane along the X & Y axes), and it would need some alteration to work on other axes. You’d need to add a lot of stuff to get it to reflect across an arbitrary plane, but this is a start. To be honest I wrote it a long time ago and can’t remember the exact process I went through when figuring it out, and it’s late so I won’t be doing it now haha.

To flip a part would be simple:

    part.CFrame = flipCFrame(part.CFrame)

Flipping a model is just a matter of flipping every single part in the model. If you want to flip something along an arbitrary plane, or flipping objects more complex (flipping Velocities, RotVelocities, Welds, etc.) you’ll have to edit what’s there and add a lot of extra stuff.

It’s not exactly what you’re looking for, but hope it’s some help.