DOS Games Message Board
DOS Games Discussion
A message board to talk about DOS games, get help, and find old games.
Do NOT post warez or abandonware requests please
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
NEW! DOSGames.com has been massively upgraded to v2.0 with TONS of new features!
Check out the new design and dozens of new features including online play!


Qbasic4.5 Codes 03: A useful 3D rotation function.

 
Post new topic   Reply to topic    DOS Games Discussion Forum Index -> Game Creation
Author Message
NeonAmd64
Experienced Member
Experienced Member


Offline
Joined: 20 Mar 2006
Posts: 84
Location: Next to you, if not then who

PostPosted: Thu Apr 13, 2006 11:19 am     Post subject: Qbasic4.5 Codes 03: A useful 3D rotation function. Reply with quote

Complex Complex and complex.... Nothing is easy in my life but I will try to make it easy for you as much as I can...

This is a code to rotate a point the in a 3D world which can be useful for 3D games:

Description: The function will rotate a point in its axes.

Caution:
The code will acquire the cosine table sub routine to rotate the point of course in little height speed. [You can refere to Qbasic4.5 Codes 01 high speed Cosine and Sine] under Game Creation board of this forum.

Here is the code:

This will make the arrays and the variables that are required:
Code:
DIM SHARED cose!(360), sine!(360)
DIM SHARED Xrotate!, Yrotate!, Zrotate!


This is a cos table sub routine:
Code:
DEFSNG A-Z
SUB cosine.table
RA = (180 / (22 / 7))
FOR i = 0 TO 360
cose!(i) = COS(i / RA)
sine!(i) = SIN(i / RA)
NEXT i
END SUB


This is the function that you need to rotate a 3D point the scene:
Code:
SUB D3d.rotate (xpROT!, ypROT!, zproT!, xROT%, yROT%, zroT%)
xROT% = xROT% - (INT(xROT% / 360) * 360): IF xROT% < 0 THEN xROT% = xROT% + 360
yROT% = yROT% - (INT(yROT% / 360) * 360): IF yROT% < 0 THEN yROT% = yROT% + 360
zroT% = zroT% - (INT(zroT% / 360) * 360): IF zroT% < 0 THEN zroT% = zroT% + 360
X.X! = xpROT!
Y.X! = (cose!(xROT%) * ypROT!) - (sine!(xROT%) * zproT!)
Z.X! = (sine!(xROT%) * ypROT!) + (cose!(xROT%) * zproT!)
X.Y! = (cose!(yROT%) * X.X!) + (sine!(yROT%) * Z.X!)
Y.Y! = Y.X!
Z.Y! = (cose!(yROT%) * Z.X!) - (sine!(yROT%) * X.X!)
xrotate! = (cose!(zroT%) * X.Y!) - (sine!(zroT%) * Y.Y!)
Yrotate! = (sine!(zroT%) * X.Y!) + (cose!(zroT%) * Y.Y!)
Zrotate! = Z.Y!
END SUB


Done… Happy

I think a program in basic can be converted to any other language. useful heh.. Laughing
So If explanation is needed then ask me.. I know you wouldn’t because you are clever .. Happy

I had created lots of codes during my life and I am happy to share it with you…. If anyone is interested then take it ... and send me at least Personal message..

Are you interested in what I have then goto
http://neonamd64.atspace.com/
Back to top
dosraider
Admin
Admin


Offline
Joined: 15 Mar 2005
Posts: 9245
Location: ROTFLMAO in Belgium.

PostPosted: Thu Apr 13, 2006 12:15 pm     Post subject: Reply with quote

RAR wrote:

! D:\temp\testingQB\d2dshootinggame.part01.rar: Unexpected end of archive
! D:\temp\testingQB\d2dshootinggame.part02.rar: Unexpected end of archive
! D:\temp\testingQB\d2dshootinggame.part03.rar: Unexpected end of archive
! D:\temp\testingQB\d2dshootinggame.part04.rar: Unexpected end of archive
! D:\temp\testingQB\d2dshootinggame.part05.rar: Unexpected end of archive


Shocked
Back to top
Dosser
Way too much free time
Way too much free time


Offline
Joined: 02 Jan 2005
Posts: 462
Location: BEHIND YOU

PostPosted: Thu Apr 13, 2006 7:59 pm     Post subject: Reply with quote

Looks interesting:
-what do x.x, y.y, x.y etc represent?
-Have you tested it yet? Put it on a cube model or something and see what happens.
-Also, is it a problem that you can only do integer rotations? A large object might look a little 'clunky' as it rotates.
-rotation is probably the hardest function to do, but have you got others as well? Transposition (moving an object left, right, up, down as if they are strafing), and scaling (shrinking / expanding as if the player is moving towards / away from it) are also important 3D functions.
Back to top
NeonAmd64
Experienced Member
Experienced Member


Offline
Joined: 20 Mar 2006
Posts: 84
Location: Next to you, if not then who

PostPosted: Fri Apr 14, 2006 8:54 am     Post subject: Web Host files error not mine Reply with quote

dosraider

My apology for this error but this is not my mistake, it is the web host mistake. It tries to embed its ads in the html file…. Cool

Never mind, now I updated the files. Happy You can start downloading:
http://neonamd64.atspace.com/game.html

My apology for the delay... Ashamed
and thank you for the last advice Happy

Remember : you have to see the sentence “replace the extension ".jpg" with ".rar"


Last edited by NeonAmd64 on Mon Dec 18, 2006 9:30 am; edited 2 times in total
Back to top
NeonAmd64
Experienced Member
Experienced Member


Offline
Joined: 20 Mar 2006
Posts: 84
Location: Next to you, if not then who

PostPosted: Fri Apr 14, 2006 9:22 am     Post subject: Dosser Reply with quote

Now, I can see .... hmmm.... Ok Happy

Dosser

Quote:
what do x.x, y.y, x.y etc represent?


Here is an explanation in brief,
ROT : is a function input. It is standing for "rotation";.
So xROT% is the rotation around the x axes ...etc
pROT: is a function input. It is standing for "Point position for rotation".
So xpROT% is the x position of the point referenced to world position...etc

X.X!, Y.X!, Z.X!, X.Y!,Y.Y! and Z.Y! all are temporary variables .. it is usefull instead of this:
Result% = (XP*(YP+((Xani/100)*1000))+cos(sin(tan(123454)*ang1)*ange3+pos1&.......I give up. :Angry:

xrotate!, yrotate!, zrotate! I call them general variables; they are used to get the resultant position of the point.

Quote:
Have you tested it yet? Put it on a cube model or something and see what happens.


Like to see it in such an application then download my final 3D object Editor package..

Quote:
-Also, is it a problem that you can only do integer rotations? A large object might look a little 'clunky' as it rotates


You are right on the line but understanding the variable purpose and how the function works then you will be in safe side. Happy

Remember, angles use an integer value, which is enough, but the position should be in real value.

Quote:
-rotation is probably the hardest function to do, but have you got others as well? Transposition (moving an object left, right, up, down as if they are strafing), and scaling (shrinking / expanding as if the player is moving towards / away from it) are also important 3D functions.


Try my 3D Editor Package and you will see what I have;

And sooner or later I will give my effort to provide you with what you need to create the 3D world .. all in Qbasic..
don't worry... Happy

Interested in basic game programming then I will support you... Happy

Direct link:
http://neonamd64.atspace.com/qbas.html
Doesn't work then goto:
http://www.freewebs.com/neonamd64/qbas.html
Back to top
Display posts from previous:   
Post new topic   Reply to topic    DOS Games Discussion Forum Index -> Game Creation All times are GMT - 5 Hours
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group and Ask an Expert
Also powered by Darren and the other admin and mods' hard work! ;)