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 / how do i position my object right in front of me (fps style)

Author
Message
bushido
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location:
Posted: 13th Jan 2008 22:22
heres code dbLoadObject ("H-Colt-Static.x",-20); and i don't get how you would put this in front of you directly

Real men don't need sigs
bushido
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location:
Posted: 13th Jan 2008 22:53
okay playing around with the camera i cannot find out anything *rips hair out of head*

Real men don't need sigs
tempicek
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: Prague
Posted: 13th Jan 2008 22:57
A stupid, but working solution would be to Move the camera forward, then read its location and then move it back. Finally you can use the obtained position to place your object.



If you know the camera direction, you can make it easier:

"Position = CamDirection * 10 + CamPosition"
bushido
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location:
Posted: 13th Jan 2008 23:02 Edited at: 13th Jan 2008 23:06
okay the x's i have no idea what to put in..... and i object doesnt even work

Real men don't need sigs
tempicek
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: Prague
Posted: 13th Jan 2008 23:06
??? I gave you the exact code. What would you put into x? There's the assignment:

x = dbCameraPositionX();
bushido
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location:
Posted: 13th Jan 2008 23:06
i dont know!!!!!!!!! thats what im asking

Real men don't need sigs
bushido
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location:
Posted: 13th Jan 2008 23:09
okay i dont get the code at all i dont know what to put in

Real men don't need sigs
tempicek
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: Prague
Posted: 13th Jan 2008 23:10
Ok, the code again:

dbMoveCamera( 10 );
x = dbCameraPositionX();
y = dbCameraPositionY();
z = dbCameraPositionZ();
dbMoveCamera( -10 );
dbMoveCamera( 10 );
dbPositionObject( iObject, x, y, z );

Place it into your program, replace "iObject" with your object identifier and tada What part you didn't get?
bushido
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location:
Posted: 13th Jan 2008 23:12
a error saying cannot convert H-Colt-Static.x into a int at char 38

Real men don't need sigs
bushido
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location:
Posted: 13th Jan 2008 23:12
and it says x y z are all undefined....

Real men don't need sigs
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 13th Jan 2008 23:12
tempicek

Your solution is not stupid but rather the easiest method to accomplish the task and requires no complex math. I have used this approach for years in DBPro even though I do understand Vector Math

Codger

System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem
bushido
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location:
Posted: 13th Jan 2008 23:14
What the hell is vector math?

Real men don't need sigs
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 13th Jan 2008 23:15
bushido

You really need to work your way through the examples and tutorials

System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem
bushido
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location:
Posted: 13th Jan 2008 23:16 Edited at: 13th Jan 2008 23:31
help!

Real men don't need sigs
bushido
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location:
Posted: 13th Jan 2008 23:38
okay x y z is the only thing that is undefined so how do i say what it is here code


Real men don't need sigs
tempicek
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: Prague
Posted: 14th Jan 2008 00:37
Quote: "okay x y z is the only thing that is undefined so how do i say what it is here code"


Sorry, I thought you know C++ at least. x, y and z are variables, supposed to be floats so you can define them (before using them) like this:

float x, y, z;

However, you will have a lot more problems if you don't start with learning C++. Then you can continue with some GDK tutorials as Codger suggested.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
bushido
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location:
Posted: 14th Jan 2008 16:15 Edited at: 14th Jan 2008 16:16
okay now my program runs fine i just don't have the gun positioned in front of me * rips hair out of head * i have a book called begging c++ through game programing by Micheal Dawson

Real men don't need sigs
tempicek
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: Prague
Posted: 14th Jan 2008 16:42
Quote: "i have a book called begging c++ through game programing by Micheal Dawson"


There you start! And if you have any concrete questions, ask here.
bushido
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location:
Posted: 14th Jan 2008 19:49
thanks i didn't know how much c++ you had to use in darkgdk i was very unsure

Real men don't need sigs
tempicek
16
Years of Service
User Offline
Joined: 27th Nov 2007
Location: Prague
Posted: 14th Jan 2008 20:24
GDK is just a library, it isn't language or environment, so for everything you write with it you need C++ skills. You can use every little bit of knowledge
Pharoseer
17
Years of Service
User Offline
Joined: 21st Feb 2007
Location: Right behind you
Posted: 15th Jan 2008 10:42
Hey guys, can't you just use dbLockObjectOn() to prevent something from moving out from in front of the camera? Or am I missing the point of the question? Here's an example showing what I mean:

Hope this helps,

-Frank

SynReaper
16
Years of Service
User Offline
Joined: 15th Jan 2008
Location:
Posted: 16th Jan 2008 01:13
I am assuming that you want a simple camera-follow-object routine. Without knowing too much c++ language, or creating too many functions to handle the vector calculations, you can use a combo of some of the built-in functions of GDK. The example code below goes into your main loop prior to dbSync ( ).

I am also new to c++ as I haven't used this language since 1993 and also have not ever had to enter a code snippet in a forum, so any advice or comments would be appreciated.




// Correct the elevation positioning of the object to follow

dbPositionObject ( ObjectToFollowID, dbObjectPositionX ( ObjectToFollowID ), dbGetTerrainGroundHeight ( 1, dbObjectPositionX ( ObjectToFollowID ), dbObjectPositionZ ( ObjectToFollowID ) ), dbObjectPositionZ ( ObjectToFollowID ) );

// Place the camera in the exact position of the object to follow

dbPositionCamera ( dbObjectPositionX ( ObjectToFollowID ), dbObjectPositionY ( ObjectToFollowID ), dbObjectPositionZ ( ObjectToFollowID ) ) ;

// Set the camera angles to the same angles as the object to follow

dbRotateCamera ( dbObjectAngleX ( ObjectToFollowID ) , dbObjectAngleY ( ObjectToFollowID ), dbObjectAngleZ ( ObjectToFollowID ) );

// Move the camera behind the object
// Note that some objects have a reversed Z axis. With a reversed axis, you just need to reverse this number and rotate the camera Y axis by 180 degrees (opposite direction).

dbMoveCamera ( -20 );

// Correct the camera elevation positioning (adding elevation to compensate for the object's height)

dbPositionCamera ( dbCameraPositionX ( ), dbCameraPositionY ( ) + dbObjectSizeY ( ObjectToFollowID ), dbCameraPositionZ ( ) ) ;

dbSync ( );


-- 010100110111100101101110010100100110010101100001011100000110010101110010
The Guru
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location:
Posted: 13th Feb 2008 14:22
Hello,

Could you please help me add that camera script you posted to this script - i would like the pistol to be positioned in front of the camera, FPS style. However, i am not sure where to place the code in the existing camera function. Thanks



Thanks In Advance!

Login to post a reply

Server time is: 2024-10-08 15:45:03
Your offset time is: 2024-10-08 15:45:03