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 / My shoot function with dbCameraLook

Author
Message
tomtetlaw
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location:
Posted: 2nd Jul 2009 03:40 Edited at: 2nd Jul 2009 04:08
How come dbCameraLook* functions return value that arn't where the camera is looking? I'm looking at a cube, then i click and it positions a plane inside the cube :S

Heres my code:


Any help would be appreciated
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 2nd Jul 2009 06:12
I havent actually seen that command or used it, but to me, it looks like it should return a vector, rather than a position in world space. That means it will return to you, the direction that your camera is looking, not the position of where it is looking. Of course I could be totally wrong about that command, not having used it, so dont listen to much to me ..

But I think what you are trying to do is place an object at the place where the mouse was clicked ? is that right ?

If so then you would need to use the dbPickObject command and get the pick vectors with dbPickVectorX, Y and Z() .. or use some trig to figure out angles etc, which I wont attempt because I was always hopeless at trig in high school(read: slow, got the theory, just took my time doin it), dont think much is changed in that regard in the last 20 yrs and I may lead you down the wrong path if I try lol.

If it ain't broke.... DONT FIX IT !!!
tomtetlaw
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location:
Posted: 2nd Jul 2009 06:26
Nah, it returns a float
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 2nd Jul 2009 06:37
But the question is, what does the float it returns represent ?

Is it part of a vector, or a part of a co-ord in 3d space ? ...

If it is a 3d co-ord, how would the camera know how far along the z axis to look, what calculations are made internally to calculate that returned variable is what I mean.

Also, that command isnt in the documention I have for GDK, so im not sure how it would work, anybody know ?
It is listed in the header right underneath the CameraPosition and CameraAngle commands, I would have to guess its returning the X value of a vector.

If it ain't broke.... DONT FIX IT !!!
tomtetlaw
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location:
Posted: 2nd Jul 2009 06:55
So how would I get a 3D co-ordinate out of 3 vectors?
tomtetlaw
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location:
Posted: 2nd Jul 2009 07:10
I tried this code but no luck

Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 2nd Jul 2009 10:26
What is it that you are wanting to happen when you click the mouse ?

You want to place an object at the location you clicked in 3d space(in which case you would need another object to place it in relation to) ? or you want to place multiple objects around that location ?

Sorry to ask so many questions that seem basic, but to be able to code it, I'd need to know exactly what you want to do.

If it ain't broke.... DONT FIX IT !!!
tomtetlaw
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location:
Posted: 2nd Jul 2009 10:46
The first one
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 2nd Jul 2009 12:56
Ok, to place an object in 3D space, you need to do so in relation to another object if you want to do it with a mouse click...

you get what are known as Pick Vectors.. here is an example of creating an object and placing it where the mouse is clicked on a large plain.

Here is a complete example program for you, just copy paste it into a new empty DarkGDK Game project and it will run.



If it ain't broke.... DONT FIX IT !!!
tomtetlaw
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location:
Posted: 2nd Jul 2009 13:28
Hmm, it's not working.. heres my code, also my playermodel doesn't show up :S

Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 2nd Jul 2009 14:22
A good idea would be to go though your code, line by line and have a look at exactly what you are asking the compiler to do. Double check that you are asking it to do things that arent impossible. You need to be very careful of your logic in programming.

Check if dbMouseClick can return 2, at the same time as its returning 1... I dont think it can

If it ain't broke.... DONT FIX IT !!!
tomtetlaw
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location:
Posted: 2nd Jul 2009 14:35
So how would i be able to say: if both mouse buttons are pressed->shoot
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 2nd Jul 2009 14:41
Quote: "if both mouse buttons are pressed->shoot "


return values

1= left mouse button
2= right mouse button
3= both buttons
4= mouse wheel.

does that help?

Dark Physics makes any hot drink go cold.
tomtetlaw
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location:
Posted: 2nd Jul 2009 14:57
Thanks HowDo and MistaWilson!

Your posts have helped me heaps
tomtetlaw
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location:
Posted: 2nd Jul 2009 15:00
I have looked all through my code, and I don't see why my code isn't working properly :S
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 2nd Jul 2009 16:10


doesnt make sense programatically... thats where you are asking if the function dbMouseClick has returned both 1 and 2 at the same time...

If you want to check for both buttons being pressed you need to check for dbMouseClick == 3 as HowDo said above.

Without seeing all of the code its hard to see what else you might have mixed up.

Really though, when you are first starting out with C++, the fact that its an Object Oriented Language can throw people. It doesnt need to be used that way, and those features are best left unused, until you have a firm grip on the very basics. There is nothing wrong with not using an object oriented design and just having a structured prototype/function design when you are learning the language.
Once you have all the basics firmly under your belt, then learning how to encapsulate your programs into objects properly and to make code re-usable is a great idea, but only after you've learnt the basics of how to structure a program in C/C++.
The above is just my opinion, and you are entitled to ignore it completely if you like.. and if im off target with my assesment of your being a relative beginner to using C++ I do apologise.

If it ain't broke.... DONT FIX IT !!!
tomtetlaw
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location:
Posted: 3rd Jul 2009 01:53 Edited at: 3rd Jul 2009 02:14
Ok, well I striped down my code, and now this is what it is:



But whenever I run it, everything shows up alright, but i get this really weird flickering of the screen, I don't know what caused it, I've tried removing certain commands, but with no luck . Can someone please help me to find out the cause of this problem.

Login to post a reply

Server time is: 2024-10-01 06:02:21
Your offset time is: 2024-10-01 06:02:21