So... I Rewrote The Math In Clone's Module3D... Again

Last year, I modified CloneTrooper1019’s Module3D to better handle distortion, and ended up running faster.
However, that modified version caused parts to shake when changing the camera angle. For the release of Ultimate Boxing, I wanted to fix that. Now I present Module3D V4, for lack of a better name.

Also did a stress test on it with 20 parts, and it is actually faster, again. Rather than doing a lot of screen position calls, the position is calculated once, and the angle needed to go against the Field Of View is calculated and applied.


(@maximum_adhd)

20 Likes

So… What’s the purpose of this? Set a part to camera on a GUI? Also, that amount of math is not required to do this little. Also calling things like “GuiObj.AbsoluteSize.X” multiple times is very inefficient too. You could’ve also easily created a CFrame from a single out vector from camera. Also didn’t need to calculate the position every time, could’ve done it for when only the frame moved, stored the CFrame in object space and would just need to multiply that CFrame with camera CFrame. If you wanted to go to extreme efficiency, you could expand the CFrame*CFrame calculation and fit it all in with Lua to just update with a CFrame.new.

I couldn’t figure out a simpler method that allowed the front of the object to face the camera (for example, the sides are a lot more visible with the red parts than the blue parts)

Hmmm… I never actually thought of doing that. I may look into it again in the future if I feel the need for it to run faster, but I don’t know how to constantly check the AbsoluteSize and AbsolutePostiion without a loop, unless .Changed fires with it.

Not exactly something I am good with. I think I will leave it up to someone like AxisAngle to figure that out.
If anyone wants to rewrite it to be even more efficient, go ahead. This pretty much suits my needs as is… well, except if you play at an extreme aspect ratio, such as a 3 WQHD multi monitor setup.

You know what would be the most efficient? Just get a part which follows the exact camera CFrame and then weld those models to that part, make it all non-collide and that’s it. Roblox would handle it a thousand times faster than you ever could.

If I am understanding that correctly, that is somewhat how Clone did his (Camera’s CFrame with adjusting the position), and causes a lot of distortion.

No, what I’m saying would give the same result as yours.

I don’t really have the time to experiment with new ideas now. If you want to try it, feel free.
Remember: It should account for changes in frame sizes, positions, as well as screen sizes.

I’ll give it a try when I have time but the last thing I said should be fairly simple. Also I’m pretty sure that AbsoluteSize and AbsolutePosition should fire the .Changed event.

Just checked, it does fire.

[code]
local Gui = Instance.new(“ScreenGui”)
Gui.Parent = script

local Frame = Instance.new(“Frame”)
Frame.Size = UDim2.new(0.2,0,0.2,0)
Frame.Position = UDim2.new(0.1,0,0.1,0)
Frame.Parent = Gui

Frame.Changed:connect(function(Property)
print(Property)
end)[/code]

Does this have a work around to the objects clipping through other objects? Like if you moved your camera through the baseplate?

It doesn’t have a built in work around for clipping, however, you can scale down your objects to small sizes, like 0.2 studs tall, to force the objects to be super close to your camera.

Pushed out a small update to this to fix wrong FieldOfViews being calculated at extreme aspect ratios.
Before (front is facing left):

After (front is facing front):

I am probably going to try to create another version (Version 5) using the Changed methods pointed out above. If I do that, it will probably be tomorrow, and a new thread will be made.

Edit: And by tomorrow, I mean now.