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.

Newcomers DBPro Corner / Object angle....landscape

Author
Message
Chiwawa
16
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 14th Oct 2002 07:40
rem Calculate four X+Z coordinates for each corner
foot#=110
ta#=wrapvalue(a#-45)
frontleftx#=newxvalue(x#,ta#,foot#) : frontleftz#=newzvalue(z#,ta#,foot#)
ta#=wrapvalue(a#+45)
frontrightx#=newxvalue(x#,ta#,foot#) : frontrightz#=newzvalue(z#,ta#,foot#)
ta#=wrapvalue(a#+225)
backleftx#=newxvalue(x#,ta#,foot#) : backleftz#=newzvalue(z#,ta#,foot#)
ta#=wrapvalue(a#+135)
backrightx#=newxvalue(x#,ta#,foot#) : backrightz#=newzvalue(z#,ta#,foot#)

rem Calculate degree of tilting from corner heights
frontlefth#=get ground height(1,frontleftx#-mx#,frontleftz#-mz#)
frontrighth#=get ground height(1,frontrightx#-mx#,frontrightz#-mz#)
backlefth#=get ground height(1,backleftx#-mx#,backleftz#-mz#)
backrighth#=get ground height(1,backrightx#-mx#,backrightz#-mz#)
across#=((frontrighth#-frontlefth#)+(backrighth#-backlefth#))/2.0
length#=((backlefth#-frontlefth#)+(backrighth#-frontrighth#))/2.0

rem Update tank model
h#=get ground height(1,x#-mx#,z#-mz#)
trackh#=(frontlefth#+frontrighth#+backlefth#+backrighth#)/4.0
if trackh#>h# then h#=trackh#
position object 1,x#,h#,z#
yrotate object 1,a#
rotate object 2,wrapvalue(length#/4.0),0,wrapvalue(across#/4.0)



ok here is the code in tank demo ...and i dont understand the last line.....lengt# is not an angle..it is an height...then..wtf dividing lenght# and across# by 4...how it can work..i dont understand..
Milamber
16
Years of Service
User Offline
Joined: 27th Sep 2002
Location: Australia
Posted: 14th Oct 2002 11:24
You're jumping head first into one of the most complex code segments I've ever seen. There's a lot of maths involved in that. What you're dealing with there is 3d geometry. Don't worry, just play around with maths formulae and it should eventually make sense. Or, just start trying to make some really fancy way of doing something and make your own section of inexplicable code. In DB v1.13 I tried making manual sliding polygon collision handling and THAT was complex AND fun .

System Specs: AMD Athlon 1700+ XP, GA-7VRX motherboard, 128MB DDR RAM, GeForce2 MX400 64MB VRAM
Chiwawa
16
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 14th Oct 2002 23:37
i dont know why i posted that here ...but im not new DB....anyway ...i understand all the code here except some part...i commented the code...






rem calculate the X and Z of each corner
foot#=110
ta#=wrapvalue(a#-45)
frontleftx#=newxvalue(x#,ta#,foot#) : frontleftz#=newzvalue(z#,ta#,foot#)
ta#=wrapvalue(a#+45)
frontrightx#=newxvalue(x#,ta#,foot#) : frontrightz#=newzvalue(z#,ta#,foot#)
ta#=wrapvalue(a#+225)
backleftx#=newxvalue(x#,ta#,foot#) : backleftz#=newzvalue(z#,ta#,foot#)
ta#=wrapvalue(a#+135)
backrightx#=newxvalue(x#,ta#,foot#) : backrightz#=newzvalue(z#,ta#,foot#)

rem he seem to calculate the height of each corner
frontlefth#=get ground height(1,frontleftx#-mx#,frontleftz#-mz#)
frontrighth#=get ground height(1,frontrightx#-mx#,frontrightz#-mz#)
backlefth#=get ground height(1,backleftx#-mx#,backleftz#-mz#)
backrighth#=get ground height(1,backrightx#-mx#,backrightz#-mz#)

rem here he seem to calculate the average of the....the height between 2 corner..it make sens...
across#=((frontrighth#-frontlefth#)+(backrighth#-backlefth#))/2.0
length#=((backlefth#-frontlefth#)+(backrighth#-frontrighth#))/2.0


rem here he check if the tank model is lower than the landscape if yes he .....
h#=get ground height(1,x#-mx#,z#-mz#)
trackh#=(frontlefth#+frontrighth#+backlefth#+backrighth#)/4.0
if trackh#>h# then h#=trackh#

rem here he position the object corectly and rotate it on y axis
position object 1,x#,h#,z#
yrotate object 1,a#

rem but HERE is the....im so confuse...
rem rotate object 2,wrapvalue(length#/4.0),0,wrapvalue(across#/4.0)


the lines who should be here are something like...
rem i take simple pytagore math...and trygonometry to find the real angle..
az#=wrapvalue(asin(across#/sqrt(2*110^2)))
ax#=wrapvalue(asin(length#/sqrt(2*110^2)))
rotate object 2,ax#,0,az#


rem try to replay the last line by MY 3 line...it work very well like the original line...damn im so proud lol...it work the first time ..i CANT figure how the original line work!!!

ho and it the Tank demo 2 in DB
and the line to replace is the line #276 or close to it..

plz help me...
Chiwawa
16
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 14th Oct 2002 23:40
and ...im maybe not too clear then i was meaning:

replace this line:
rem rotate object 2,wrapvalue(length#/4.0),0,wrapvalue(across#/4.0)

by these lines:
az#=wrapvalue(asin(across#/sqrt(2*110^2)))
ax#=wrapvalue(asin(length#/sqrt(2*110^2)))
rotate object 2,ax#,0,az#


and i tested it ..and it work..but what is the similarity of ..the original and mine???
Milamber
16
Years of Service
User Offline
Joined: 27th Sep 2002
Location: Australia
Posted: 16th Oct 2002 08:09
The math may be more complex, but it probably just takes a shortcut. Compare the values of ax# and az# to the values used by the original line, and they're probably exactly the same.

System Specs: AMD Athlon 1700+ XP, GA-7VRX motherboard, 128MB DDR RAM, GeForce2 MX400 64MB VRAM

Login to post a reply

Server time is: 2019-07-19 08:07:56
Your offset time is: 2019-07-19 08:07:56