Different speed in two spheres using TurnEntity
Blitz3D Forums/Blitz3D Beginners Area/Different speed in two spheres using TurnEntity
| ||
I am making a solar system for experiment but I don't know how to do two or more planets go to different speeds, For Example, variable for mars w\CenterYawAdd#[5] = 1 and variable for earth w\CenterYawAdd#[3] = 2 . How Can I do those two body go to this differents speeds using TurnEntity. O perhaps there were a better way? I apreciate help for to understanding this question easy for experts coders, but difficult to me actually. My code: Graphics3D 640,480,16,2 SetBuffer BackBuffer() Global xx# Type system Field name$ [12] Field x# [12] Field y# [12] Field z# [12] Field CenterPitchAdd#[12] Field CenterYawAdd#[12] Field CenterRollAdd#[12] End Type ; variables types w.system = New system w\name$ [0] = "Sun" w\x#[0] = 0 w\y#[0] = 0 w\z#[0] = 20 w\CenterPitchAdd#[0] = 0 w\CenterYawAdd#[0] = 1 w\CenterRollAdd#[0] = 0 w\name$ [3] = "Earth" w\x#[3] = 0 w\y#[3] = 0 w\z#[3] = 5 w\CenterPitchAdd#[3] = 0 w\CenterYawAdd#[3] = 2 w\CenterRollAdd#[3] = 0 w\name$ [4] = "Moon" w\x#[4] = 0 w\y#[4] = 0 w\z#[4] = 5 w\CenterPitchAdd#[4] = 0 w\CenterYawAdd#[4] = 1 w\CenterRollAdd#[4] =0 w\name$ [5] = "Mars" w\x#[5] = 0 w\y#[5] = 0 w\z#[5] = 8 w\CenterPitchAdd#[5] = 0 w\CenterYawAdd#[5] = 1 w\CenterRollAdd#[5] =0 ; Entitys sun=CreateSphere(32) ScaleEntity sun, 2, 2, 2 EntityColor sun,255,255,0 earth=CreateSphere(32,sun) ScaleEntity earth, 1, 1, 1 EntityColor earth,0,255,0 moon=CreateSphere(32,earth) ScaleEntity moon, .5, .5, .5 EntityColor moon,100,100,100 mars=CreateSphere(32,sun) ScaleEntity mars, .7, .7, .7 EntityColor mars,255,0,0 camera=CreateCamera() lite = CreateLight() light=CreateLight(1) ;create ligth ; Main program While Not KeyDown( 1 ) ; Change position values depending on key pressed If KeyDown( 203 )=True Then For j=0 To 12 w\x#[j]=w\x#[j]-0.1 Next EndIf If KeyDown( 205 )=True Then For j=0 To 12 w\x#[j]=w\x#[j]+0.1 Next EndIf If KeyDown( 208)=True Then For j=0 To 12 w\y#[j]=w\y#[j]-0.1 Next EndIf If KeyDown( 200 )=True Then For j=0 To 12 w\y#[j]=w\y#[j]+0.1 Next EndIf If KeyDown( 44 )=True Then For j=0 To 12 w\z#[j]=w\z#[j]-0.1 Next EndIf If KeyDown( 30 )=True Then For j=0 To 12 w\z#[j]=w\z#[j]+0.1 Next EndIf LightColor lite,255,0,0 ; Position using position values PositionEntity sun,w\x#[0],w\y#[0],w\z#[0] PositionEntity earth,w\x#[3],w\y#[3],w\z#[3] PositionEntity moon,w\x#[4],w\y#[4],w\z#[4] PositionEntity mars,w\x#[5],w\y#[5],w\z#[5] PointEntity lite,moon ;light TurnEntity sun, w\CenterPitchAdd#[0], w\CenterYawAdd#[0], w\CenterRollAdd#[0] TurnEntity earth, w\CenterPitchAdd#[3], w\CenterYawAdd#[3], w\CenterRollAdd#[3] ; how can I to do mars go to different speed than earth ???? x#=x#+0.1 RotateEntity earth,0,x# ,0 RenderWorld Flip Wend |
| ||
You're thinking to hard! Try this code, no math, no media, almost no thinking involved. It can even actually get simpler but I've already got it typed. Use the ESC key to quit the program. |
| ||
Yes Drak, your are rigth. It is hard to me becouse I am new in Blitz3D and new in making types and it is hard to me still. And I was too confused last 3 days for this question. I see your code is better than mine and more clear, and now I am going to sleep, but tomorrow I will experiment with your example and I am sure that I will be able to understand it and to adapt to for my purpose. A good example!!! Thanks a lot!!! |
| ||
P.S. Might want to check an astronomy book for accurate rotations. A Jupiter day is less than 10 hours, while Venus' day is longer than its year! |
| ||
In my case, it does not matter actualy becouse I only am doing code for experiment with Blitz3D and its 3D commands. This solar system is only a way to be a little more skilled in 3D world. I am trying with ideas extracted from real world or it would be to difficult to understand concept of 3D. A true astronomy program is too far to do by me still. I know it. |