Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Make On face?

Author
Message
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 28th Jun 2009 15:04
Hello, Say I have a 6 sided cube in 3d space, I am able to fly around the cube and click each face with the mouse and retrieve its model number.

How would I go about making it so that when a face got clicked another cube was placed up against it?

Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 28th Jun 2009 18:41
you can use the dbPickObject command, probably in a similar way to what you are using it to get the object number of the object you are clicking...

You just work out a point in 3dspace from the position of your camera, and the pickvector of the object(retrieved when pickobject is called).

The below code will give you the X, Y, Z world co-ords of the place on an object that you click, that is in the range of g_iObjnum_Start and g_iObjnum_End



If it ain't broke.... DONT FIX IT !!!
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 28th Jun 2009 21:14
If you use sparky's to cast the ray, it will give you the index of the face which the ray hit.

kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 29th Jun 2009 03:40
Would you mind using an example with sparkys please?

kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 29th Jun 2009 14:07
I tried to use the way posted by mista wilson but it mesed with my camera for some reason.

Is there any way to have a ghost object that sort of snapped to a grid?

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 30th Jun 2009 00:23
There is another way:
Use 'dbPickObject' to get the cube that was clicked. get pick vector x/y/z will give you the exact position relative to the camera, so add on the camera position, and subtract the clicked object position to make the coordinates local. Then take those x,y and z values, and find the one which is the largest (either negative or positive) and set it to 1 or -1 depending on the original sign. Then set the other two values to zero. Multiply all 3 coordinates by the size of 1 cube, and add them to the position of the clicked cube, and make the new cube at that position.

kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 30th Jun 2009 03:47 Edited at: 30th Jun 2009 03:49


See how the blocks are inside other blocks? I don't want that =[

EDIT:
Code used to get those results:


EDIT: EDIT:
i've tried to play around with the code but that gets the best results so far..

kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 30th Jun 2009 05:21
I got it to work on my own using a completely different method! thx

Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 30th Jun 2009 16:00
Im glad you got it to work, but just so you know for the future, the reason the boxes were inside each other, is to do with where and how you are placing them, once you have the pickvectors...

The pickvectors give you the co-ords of where the mouse clicked, you still need to take into account your second objects point of origin and its size, offset, rotation etc aswell as how far from the first object's point of origin you clicked, to make sure it lines up with the other object properly.

If it ain't broke.... DONT FIX IT !!!
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 1st Jul 2009 00:36
yeah it just sat there and thought real hard about it and tried some stuff and it works perfectly! im posting a wip of this game so far since i think tis ready

Login to post a reply

Server time is: 2024-10-01 05:49:00
Your offset time is: 2024-10-01 05:49:00