Jump to content


Photo

3d-to-2d And 2d-to-3d Conversion


  • Please log in to reply
53 replies to this topic

#41 Phantom107

Phantom107

    Engineer

  • GMC Member
  • 2599 posts
  • Version:GM:Studio

Posted 13 July 2010 - 09:37 AM

Is that all of the code? With just a code snipplet, all I can do is guess.

1. Execute Convert_Prepare every step.

If this is your camera code...
d3d_set_projection_ext(x,y,16,xto,yto,zto,0,0,1,45,1.6,1,32000);
... then these are the arguments required for Convert_Prepare:
Convert_Prepare(x,y,16,xto,yto,zto,0,0,1,45,1.6); // <- same arguments as d3d_set_projection_ext except for znear and zfar
2. Then use Convert_3d or Convert_2d depending on what you'd want to convert.

If all else fails, compare your code to the code in my example and see what you did different (or forgot).

  • 0

#42 GMkizzle

GMkizzle

    GMC Member

  • GMC Member
  • 374 posts

Posted 13 July 2010 - 10:07 AM

I placed the right arguments in convert prepare script and i already tried calling it every step.
Here is my gmk: Move to mouse
Mirror: Download .gmk

Maybe you can find whats wrong :/ Sorry for very messy, unorganised or nooby code :/
  • 0

#43 Phantom107

Phantom107

    Engineer

  • GMC Member
  • 2599 posts
  • Version:GM:Studio

Posted 13 July 2010 - 10:47 AM

Fixed and working: link.

I changed a couple of things:

  • Your grass texture mas making my eyes bleed so I replaced it with a nice one from my texture archive.
  • I put in the conversion scripts as used in this example and removed yours. (Obviously I prefer the scripts used in this example)
  • I fixed the movement of your player. This prevents the camera from being super-jumpy when standing still.
  • Aspect is defined as width/height, not height/width!
  • I made the click commands happen from the camera object, this is easier programming when using conversions.
Enjoy!

  • 0

#44 GMkizzle

GMkizzle

    GMC Member

  • GMC Member
  • 374 posts

Posted 15 July 2010 - 06:32 AM

Thankyou very much! sorry i didnt post straight away, school has been holding me up. thanks again.
  • 0

#45 wioneo

wioneo

    The Profet

  • New Member
  • 526 posts

Posted 05 August 2010 - 07:53 AM

Thank you for this example, but do you have any ideas on how to modify this method to be used to detect a point on a rotatable surface at varying z values and to have the mouse independent of the camera? I'm making an animation editor for personal use and at the moment I'm using a dropdown list to select parts to edit which is significantly slower than simply clicking.
  • 0

#46 Phantom107

Phantom107

    Engineer

  • GMC Member
  • 2599 posts
  • Version:GM:Studio

Posted 05 August 2010 - 06:33 PM

Thank you for this example, but do you have any ideas on how to modify this method to be used to detect a point on a rotatable surface at varying z values and to have the mouse independent of the camera? I'm making an animation editor for personal use and at the moment I'm using a dropdown list to select parts to edit which is significantly slower than simply clicking.

For this you would need to use a collision dll and cast a ray against your model. In theory this could be combined with this example, first use 2d-to-3d to find a direction and then cast a ray using the collision dll.
  • 0

#47 ck2k

ck2k

    GMC Member

  • New Member
  • 68 posts

Posted 19 August 2010 - 05:08 PM

Awesome, works perfect!
Thanks :)

Edited by ck2k, 19 August 2010 - 05:12 PM.

  • 0

#48 ShubhamBansod

ShubhamBansod

    Pokemon Master

  • GMC Member
  • 257 posts
  • Version:GM8

Posted 30 May 2012 - 05:52 PM

nyc example but i have a question...
if want to add buttons in screen which is mouse clickable ....what can i do...the cursor is stuckeD in the centre of screen..
  • 0

#49 jflorek

jflorek

    GMC Member

  • GMC Member
  • 40 posts
  • Version:GM8

Posted 31 May 2012 - 06:17 PM

This script was probably meant for an FPS... although there is a similar version of it by icuurd<some#s>, although I think it was actually made by yourself... Idk where it is though.
  • 0

#50 Phantom107

Phantom107

    Engineer

  • GMC Member
  • 2599 posts
  • Version:GM:Studio

Posted 31 May 2012 - 09:08 PM

The mouse is being reset to the center of the screen. If you stop it being reset, you can do the 2d-to-3d on every position on the screen as you see fit.

As for the clickable buttons, I am not sure if you want them locked in place or hovering above 3d items and such. You won't need these scripts for the former.
  • 0

#51 ShubhamBansod

ShubhamBansod

    Pokemon Master

  • GMC Member
  • 257 posts
  • Version:GM8

Posted 01 June 2012 - 09:17 AM

Ohh.....:'((
ok
now i m telling what i,m working on....
i m creating a 3d room creator with rhe help of your example...as it was the bestest for pointing in a 3d field...i add a odj_cpu which create a 3d object when mb_left is preesed ....when we press key's' it saves the .3dlvl file which contain the x,y,z location of the object ...any by preesing key'l' it will load it.....then i realise if i add some buttons on screen for save and load by d3d_...._ortho ...it is good....please panthom107 ...your the only one who can help me ....do some thing....soon i will,upload my example...for ur help...:'((
  • 0

#52 Phantom107

Phantom107

    Engineer

  • GMC Member
  • 2599 posts
  • Version:GM:Studio

Posted 01 June 2012 - 07:16 PM

I don't understand your question?

- You can stop the repositioning of the mouse by getting rid of the code that does that. It's in the step event.
- You should call an ortho projection when all other drawing is finished in the room. Then draw your 2D buttons.
  • 0

#53 Research

Research

    GMC Member

  • GMC Member
  • 81 posts

Posted 24 December 2012 - 03:09 PM

This not work in GMS.
I could not find the problem.
Can someone help me?

http://imageshack.us...8/17038843.png/

Edited by Research, 24 December 2012 - 03:19 PM.

  • 0

#54 programmmer5

programmmer5

    GMC Member

  • GMC Member
  • 359 posts

Posted 01 February 2013 - 03:44 PM

OK i see that it works with
d3d_set_projection_ext()
but is there anyway it can work with just
d3d_set_projection()
?
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users