Faking z heights

For questions about using Classic.

Post » Mon Nov 23, 2009 4:55 pm

I have some objects set to a certain z height, how would I go about getting something like particles to show at that same x,y,and z?
Is there a formula for doing that, or perhaps it should be done via another layer set to a different scroll rate?
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Tue Nov 24, 2009 2:34 pm

Yeah, I'm pretty much screwed on that one I think.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Tue Nov 24, 2009 4:05 pm

There is a formula, but to do it properly is very complicated. Your best bet is to try and do everything with Z elevated sprites.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Tue Nov 24, 2009 5:43 pm

Well actually my current fix is to use just a separate layer, and no z heights for the sprites.
The only thing I'm really missing is how the drop shadow object is effected. Its not really a big issue even because I can offset it to compensate somewhat. The size of the drop shadow is the only thing I cant change, but I could even fix that by making my own out of a sprite. Dunno perhaps the ability to change the drop shadows size should be requested.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Wed Nov 25, 2009 9:07 am

EDIT: The following is assuming I understand your meaning correctly. Ignore otherwise :lol:.


Emulating Z height is actually pretty easy. Only thing you need to know is the Z co-ordinate of the Camera, which is 100.

[size=80:1zjus9qn]CameraZ is the Camera Z Co-ordinate
EmulatedZ is the Z height you wish to fake
Object.Value is the value you wish to offset by the emulated Z height[/size:1zjus9qn]

The basic formula is:
Object.Value * CameraZ / (CameraZ - EmulatedZ) or
Object.Value * 100 / (100 - EmulatedZ)

For anything that does not involve the X/Y axis (Size, acceleration, speed, etc):
Object.Value * 100 / (100 - EmulatedZ)
[size=80:1zjus9qn]Where Object.Value is the original value before any Z emulation.[/size:1zjus9qn]

For Object.X its:
((Object.Value('X') - DisplayWidth*0.5) * 100 / (100 - EmulatedZ)) + DisplayWidth*0.5
[size=80:1zjus9qn]Where Object.Value('X') is Object.X before any Z emulation.[/size:1zjus9qn]

For Object.Y its:
((Object.Value('Y') - DisplayHeight*0.5) * 100 / (100 - EmulatedZ)) + DisplayHeight*0.5
[size=80:1zjus9qn]Where Object.Value('Y') is Object.Y before any Z emulation.[/size:1zjus9qn]


The DisplayWidth and Height parts are basically telling the Z emulation where the Camera's X and Y are focusing, so it can emulate accordingly. Remove them if you want to see what I mean, the Z will be focused at 0,0 rather than the center of your screen.
B
2
S
2
G
5
Posts: 108
Reputation: 1,866

Post » Wed Nov 25, 2009 12:52 pm

So...
>Always
Particles set position to
((Sprite.X - DisplayWidth*0.5) * 100 / (100 - Sprite.ZElevation)) - DisplayWidth*0.5
((Sprite.Y - DisplayWidth*0.5) * 100 / (100 - Sprite.ZElevation)) - DisplayWidth*0.5

Was kinda off. My particles initial x,y were way off the layout.
I must be confusing something somewhere.


[quote:1atz9zia]Where Object.Value('X') is Object.X before any Z emulation.[/quote:1atz9zia]

Aren't they the same?
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Thu Nov 26, 2009 10:59 am

Yeah sorry about that, error on my part, should be:

>Always
Particles set position to
((Sprite.X - DisplayWidth*0.5) * 100 / (100 - Sprite.ZElevation)) + DisplayWidth*0.5
((Sprite.Y - DisplayHeight*0.5) * 100 / (100 - Sprite.ZElevation)) + DisplayHeight*0.5


By 'Where Object.Value('X') is Object.X before any Z emulation', what I'm really trying to say is don't do the following.

>Always
Particles set position to
((Particles.X - DisplayWidth*0.5) * 100 / (100 - Particles.Value('Z'))) + DisplayWidth*0.5
((Particles.Y - DisplayHeight*0.5) * 100 / (100 - Particles.Value('Z'))) + DisplayHeight*0.5

The 'Particles.X' would need to be what value X you want it to be pre-Z emulation, whereas here after a single tick it would be Z emulated, then Z emulated again, and again, exponentially, making it a complete mess. I hope that makes sense.
B
2
S
2
G
5
Posts: 108
Reputation: 1,866

Post » Thu Nov 26, 2009 2:03 pm

Thanks, that works better. Something is still a bit off tho, the particle object will start to leave the objects x,y after about 300 pixels.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Thu Nov 26, 2009 2:09 pm

[quote="newt":1a52934h]I have some objects set to a certain z height, how would I go about getting something like particles to show at that same x,y,and z?
Is there a formula for doing that, or perhaps it should be done via another layer set to a different scroll rate?[/quote:1a52934h]

well the easy way would be, create your own particle spawner. the math for scaling and movement to attach a non sprite to an object which is free in all dimensions is really complicated to tweak just right, and i don't really see the advantage of using a fake transformation of the particle object that'll look strange and out of place in your true 3d world. not to mention if youre setting the scroll and zoom settings for a layer to control one object, you wont be able to make any others ones, so youre stuck with one particle object. using sprites to make all your paritcles would allow
-multiple spawning sources
-its easier
-your particles can travel through all dimensions instead of just one.
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Thu Nov 26, 2009 4:28 pm

[quote:259roic0]well the easy way would be, create your own particle spawner. the math for scaling and movement to attach a non sprite to an object which is free in all dimensions is really complicated to tweak just right, and i don't really see the advantage of using a fake transformation of the particle object that'll look strange and out of place in your true 3d world. not to mention if youre setting the scroll and zoom settings for a layer to control one object, you wont be able to make any others ones, so youre stuck with one particle object. using sprites to make all your paritcles would allow
-multiple spawning sources
-its easier
-your particles can travel through all dimensions instead of just one.[/quote:259roic0]

I dont even want to think about how complicated a sprite emitter would be, plus I would think that would kill the frame rate at some point.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests