generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Opposites and Rotation

Previous Thread :: Next Thread 
IntelligentBeing is not online. IntelligentBeing
Joined: 11 Jul 2013
Total Posts: 523
10 Feb 2016 04:21 PM
CFrame.new(game.Workspace.Part2.CFrame.p * Vector3.new(-1,1,1),game.Workspace.Part1.Position + game.Workspace.Part2.CFrame.lookVector * Vector3.new(-1,1,1))

Positioning is perfect, my issue is the rotation.
What that top code does is reverse a part in order to successfully create a "mirror".
My problem is the rotation isn't reversed correctly. How can I fix this?
Report Abuse
IntelligentBeing is not online. IntelligentBeing
Joined: 11 Jul 2013
Total Posts: 523
10 Feb 2016 05:33 PM
Bump
Report Abuse
EgoMoose is not online. EgoMoose
Joined: 04 Feb 2009
Total Posts: 2896
10 Feb 2016 05:36 PM
Ahh, this is an interesting one. The way I'd approach is it via altering the CFrame matrix.

Give me a few mins to type up an answer, hopefully I won't get ninja'd!
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
10 Feb 2016 05:39 PM
Try this?
CFrame.new(game.Workspace.Part2.CFrame.p * Vector3.new(-1,1,1),game.Workspace.Part1.Position + -game.Workspace.Part2.CFrame.lookVector * Vector3.new(-1,1,1))


Report Abuse
IntelligentBeing is not online. IntelligentBeing
Joined: 11 Jul 2013
Total Posts: 523
10 Feb 2016 05:57 PM
@Tynezz
Nope! Made it worse tbh!
Report Abuse
EgoMoose is not online. EgoMoose
Joined: 04 Feb 2009
Total Posts: 2896
10 Feb 2016 06:19 PM
A CFrame's matrix is made up of 12 components like this:

CFrame.new(x, y, z, r00, r01, r02, r10, r11, r12, r20, r21, r22);

For now, let's just ignore x, y, and z. They're simply positional values and that's pretty straight forward.
What we care about is r00, r01, r02, r10, r11, r12, r20, r21, r22. These our our CFrame's rotation components and they
actually represent 3 seperate directional vectors. They're easier to see if we order them like this

r00, r01, r02,
r10, r11, r12,
r20, r21, r22

Each vertical column is a seperate unit vector.

The first column represents the facing direction of the right surface
The second column represents the facing direction of the top surface
The third column represents the facing direction of the back surface

As such we can conclude that:

local rightSurface = Vector3.new(r00, r10, r20);
local topSurface = Vector3.new(r01, r11, r21);
local backSurface = Vector3.new(r02, r12, r22);

Since we know that it's just a matter of fliping our matrix around 180 degrees. So by thinking a bit and applying some negatives:

CFrame.new(x ,y, z , r00, -r01, -r02, -r10, r11, r12, -r20, r21, r22);

Problem is that's a world space so it'll seem kinda arbitary, also we didn't move the position which we might as well do while we're at it.
In short here's our final outcome:

function reflect(cf, mirror)
-- get components in object space
local x, y, z, r00, r01, r02, r10, r11, r12, r20, r21, r22 = mirror.CFrame:toObjectSpace(cf):components();
-- reflect in object space and convert to world space
return mirror.CFrame:toWorldSpace(CFrame.new(-x ,y, z , r00, -r01, -r02, -r10, r11, r12, -r20, r21, r22));
end;

You could prob do it with vectors alone via the dot/cross product but I haven't tried that yet.

Sorry for the long wait!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image