Jump to content


Photo

d3d_set_perspective == inversed y?


  • Please log in to reply
11 replies to this topic

#1 _162820

_162820

    GMC Member

  • GMC Member
  • 73 posts

Posted 11 August 2012 - 11:48 AM

Hi!

I was creating a game and I decided to add a perspective to the game, but when I enabled 3D-mode, the y-axis was flipped, that so the room appear upside-down.
How do I revert it back to the original?

(I have tried tampering with some d3d_transform_add_rotation-functions, but when I did that, the y-axis was flipped back to the original, but then the controllers (left/right) and the direction/speed of view[0] was inverted).
What do I do? Does anybody of you know? :-)
  • 0

#2 xshortguy

xshortguy

    GMC Member

  • Global Moderators
  • 4186 posts
  • Version:GM:Studio

Posted 11 August 2012 - 12:15 PM

This is by design so that the 3D coordinate system is right-handed.
  • 0

#3 _162820

_162820

    GMC Member

  • GMC Member
  • 73 posts

Posted 11 August 2012 - 12:59 PM

Yes, but how do I solve my problem?
  • 0

#4 G-Games

G-Games

    GMC Member

  • GMC Member
  • 501 posts
  • Version:GM8

Posted 11 August 2012 - 02:35 PM

Have you tried using d3d_set_projection_ortho(0, 0, room_width, room_height, 180)?
  • 0

#5 _162820

_162820

    GMC Member

  • GMC Member
  • 73 posts

Posted 11 August 2012 - 05:14 PM

Well, when I tried to use the orthographic projection with 180 set to the angle; only the objects was turned around. Tiles were still drawed the opposite way.

I also tried to change "room_width" and "room_height" in the "w" and "h"-section of the function to "view_wview[0]" and "view_yview[0]", but then Game Maker ran upon an unexpected error wile running the game.

So, I still don't know what I do wrong. Do you have more ideas? :)
  • 0

#6 G-Games

G-Games

    GMC Member

  • GMC Member
  • 501 posts
  • Version:GM8

Posted 11 August 2012 - 05:51 PM

So how about this?:

d3d_set_projection_ext(0, 0, 0, room_width, room_height, 0, 0, 0, 0, 180, 0, 0, 5);

  • 0

#7 _162820

_162820

    GMC Member

  • GMC Member
  • 73 posts

Posted 12 August 2012 - 10:56 AM

Well, I don't know if it works. Game Maker does still end up with an unexpected error when I'm trying to use projections. :/
  • 0

#8 G-Games

G-Games

    GMC Member

  • GMC Member
  • 501 posts
  • Version:GM8

Posted 12 August 2012 - 11:06 AM

Weird. Well, in that case I think I don't have any other solutions. I'll try to find a solution for you, and if I find anything, you'll hear from me again. ;)

EDIT: Random thought: d3d_set_projection_perspective() still exists. Try: d3d_set_projection_perspective(0, 0, room_width, room_height, 180);.

Edited by G-Games, 12 August 2012 - 11:09 AM.

  • 0

#9 Tepi

Tepi

    GMC Member

  • Global Moderators
  • 4201 posts
  • Version:GM8.1

Posted 12 August 2012 - 03:03 PM

Here is a slightly modified version of a solution I had posted earlier:
var w,h;
w = view_wview;
h = view_hview;
d3d_set_projection(w/2+view_xview,h/2+view_yview,w, w/2+view_xview,h/2+view_yview,0,0,-1,0);

A word of warning though, the sprites will appear offset from the 0 level, if they have non-zero depth value (if this causes problems, you either need to use ortho projection for the 2D stuff and draw the 3D stuff separately with this projection, or draw all the sprites as 3D walls or undo the depth translation by means of d3d_transform_set_translation).
  • 0

#10 _162820

_162820

    GMC Member

  • GMC Member
  • 73 posts

Posted 12 August 2012 - 09:29 PM

I found Tepi's code to be working properly, but how do I do the same for tiles in the room? (they are still drawed upside down and moving in the opposite y-direction than the view[0]'s direction).
Moreover, the z-axis has been reversed, and I don't know how to solve that one. (setting "zfrom" from "w" to "-w" did help, but then the controllers (left-right) was inversed, again! ) --- (or should I just change everything related to drawing in the z-axis to a negative value instead of a positive?) :)
  • 0

#11 G-Games

G-Games

    GMC Member

  • GMC Member
  • 501 posts
  • Version:GM8

Posted 13 August 2012 - 05:28 PM

Well, my suggestion to fix the z-axis would be:

var w,h;
w = view_wview;
h = view_hview;
d3d_set_projection(w/2+view_xview,h/2+view_yview,w,
 w/2+view_xview,h/2+view_yview,0,0,-1,1);

0 transform to 1 at the zup.

Then about the tiles, just 180 degree turn your background and it should look fine. No need to use difficult coding for that. ;)
  • 0

#12 brac37

brac37

    GMC Member

  • GMC Member
  • 765 posts
  • Version:GM7

Posted 17 August 2012 - 08:18 PM

Flipping the image vertically can be done by negating the aspect variable of d3d_set_projection_ext. Other solutions do not flip but instead turn the image 180 degrees. Vertical flipping and turning 180 degrees add up to horizontal flipping.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users