3D Python Camera

Post your own tutorials, guides and demos.

Post » Sun Aug 28, 2011 12:20 am

Went ahead and posted the cap in my first post for those who are interested.

Anyway this cap relies on a formula I'm not even completely sure how it works, but it does. The formula can be found here.

Obviously, a few tweaks were made since this formula is meant to give the location of points, not objects with rotations; not mention the formula makes the center (0,0) instead of the top left. The formula for rotations was mostly guesswork, although it wasn't much different than it was for the single-axis-3dcameras that occasionaly permeate this board.
I should mention,there's a bit of a bandaid coding with camera pitching. The camera actually starts pointed at the sky (Or is it the ground?), if you catch my drift. It was a bit easier to code that way.

One of the big downsides to having a psudo-camera is that is makes rotating objects on a world basis with more than just yaw a huge challenge to implement with the tools construct offers. Since world rotations come before camera induced ones and construct is limited to a yaw-pitch-roll order of rotations, you can sanely do Yaw(Wld+Cam)-CamPitch, but not Pitch(Wld)+Yaw(Wld+Cam)+Pitch(Cam).

Python and Speed

Python has really been a timesaver, it's kinda nice being able to find and replace small parts of code without turning all of it into a warzone. The other great thing is that done right, it works with families, so I could possibly even make a formula and apply it to all 3d objects, sprites, and boxs, with only 3 lines of code.

Although from what I've heard, behaviors and plugins are the faster and less intensive. So I would probably say that any large project would definitely need them, either that or real 3d camera support.

chris, I would really like to see what inventive thing you cook up with this, and I would have no problem elaborating further on this and some other little experiments I've done if you're interested. Yarfapet2011-08-28 00:54:46
B
51
S
10
G
7
Posts: 184
Reputation: 6,825

Post » Sun Aug 28, 2011 1:11 am

Thanks for sharing his Yarfapet.

Im gonna see if a can work how the math works.

One thing i did get was an error message when i clicked on(selected) one of the 3d boxes(not during runtime)...but it doesnt crash, it just gives a warning?
B
19
S
6
G
7
Posts: 1,206
Reputation: 7,300

Post » Sun Aug 28, 2011 3:05 am

[QUOTE=chrisbrobs] Thanks for sharing his Yarfapet.

Im gonna see if a can work how the math works.

One thing i did get was an error message when i clicked on(selected) one of the 3d boxes(not during runtime)...but it doesnt crash, it just gives a warning?
[/QUOTE]

What did the warning say?
B
51
S
10
G
7
Posts: 184
Reputation: 6,825

Post » Sun Aug 28, 2011 7:42 am

I got an error also. It says:

"Error in Private Variables. The selected Object Type has 1 variables(not my spelling mistake!) but the selected instance has 2. Please report the bug to Scirra."

It happens when you click on WWall2.

zen

zenox982011-08-28 07:54:00
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,849
Reputation: 48,299

Post » Sun Aug 28, 2011 10:10 am

Sorry..I should have included it in my post, but it's the same as error that Zeno98 is getting.

The cap still WORKS, but if you try and alter the position of WWall2,
it triggers the error.

Do i have to install any extra files to run caps that use python?


B
19
S
6
G
7
Posts: 1,206
Reputation: 7,300

Post » Sun Aug 28, 2011 10:27 am

Usually, if the .cap needs particular python files, and if you haven't got python installed, or they aren't included by reference(e.g. sys.path=[System.AppPath + 'py3'] where the folder py3 has the needed files), then you get a traceback error (no module installed).

That's from my experience anyway.

zenzenox982011-08-28 10:28:45
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,849
Reputation: 48,299

Post » Sun Aug 28, 2011 12:25 pm

It's a bug, easy fix though. Just delete the original (Had to click it on the tool bar or Construct would crash). Then make a clone of the other blocks, container it with the blue map blocks, paint the 3d one as you please, and you should be good.

All you need to do to create new map pieces is create an object with a map family and one with a world family, set the world to destroy on startup ,and container them together and the rest will sort itself out.

Edit: Cap should be fixed now.Yarfapet2011-08-28 13:07:23
B
51
S
10
G
7
Posts: 184
Reputation: 6,825

Post » Sun Aug 28, 2011 1:05 pm

[QUOTE=Yarfapet] It's a bug, easy fix though. Just delete the original (Had to click it on the tool bar or Construct would crash). Then make a clone of the other blocks, container it with the blue map blocks, paint the 3d one as you please, and you should be good.

All you need to do to create new map pieces is create an object with a map family and one with a world family, set the world to destroy on startup ,and container them together and the rest will sort itself out.[/QUOTE]

-------------------------------------------------------

Any chance you could give a step by step on the above, I'm struggling to understand.
Why do i have to clone the blocks? (is it because of the container)
What do the blue map blocks do?
(I have mentioned 2 things here, but i'm not 10o% sure about the rest!)
B
19
S
6
G
7
Posts: 1,206
Reputation: 7,300

Post » Sun Aug 28, 2011 1:14 pm

[QUOTE=chrisbrobs] [QUOTE=Yarfapet] It's a bug, easy fix though. Just delete the original (Had to click it on the tool bar or Construct would crash). Then make a clone of the other blocks, container it with the blue map blocks, paint the 3d one as you please, and you should be good.

All you need to do to create new map pieces is create an object with a map family and one with a world family, set the world to destroy on startup ,and container them together and the rest will sort itself out.[/QUOTE]

-------------------------------------------------------

Any chance you could give a step by step on the above, I'm struggling to understand.
Why do i have to clone the blocks? (is it because of the container)
What do the blue map blocks do?
(I have mentioned 2 things here, but i'm not 10o% sure about the rest!)
[/QUOTE]

You're cloning one of the other blocks just to save time. You could also just make a new one and apply the "world" family

The map your looking at is an over head of the 3d world. Each of the blocks on the map represents one in the 3d world. The blue map blocks represent the blue 3d ones. If you alter the position or size of one, the 3d one will change accordingly. All the map blocks also have two PV's for the 3DHeight and 3DY. The latter being where the bottom of the block will be the later how high it extends upward.

The map is calculated at 1/4 world space to save space. So a map block 16px wide would create a 3dblock 64px wide. This does not apply to the map objects's private variables,
B
51
S
10
G
7
Posts: 184
Reputation: 6,825

Post » Sun Aug 28, 2011 3:53 pm

"It's a bug, easy fix though. Just delete the original (Had to click it on the tool bar or Construct would crash). Then make a clone of the other blocks, container it with the blue map blocks, paint the 3d one as you please, and you should be good."

Sorry....still having problems.

1, I deleted the WWall2(3dbox) by right clicking on it in the object list and choosing delete). Then i deleted and all the mwall2(sprites), but when i run the cap it crashes?.

2, "Had to click it on the tool bar" Whats the toolbar?

I am probably missing something simple...but i dont know what.

B
19
S
6
G
7
Posts: 1,206
Reputation: 7,300

PreviousNext

Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 2 guests