Solar Eclipse model?!

Blitz3D Forums/Blitz3D Programming/Solar Eclipse model?!

sonokong(Posted 2007) [#1]
I'm trying to make a solar eclipse simulation with Blitz3D. Is there anyway I can make the "sun" radiate light?

Thanks.


sonokong(Posted 2007) [#2]
Anyone there?


jfk EO-11110(Posted 2007) [#3]
You're not very patient, right :)

Did you browse the code archives for special effects?


sonokong(Posted 2007) [#4]
Yes, you're quite accurate. I'm not very patient AT ALL.


sonokong(Posted 2007) [#5]
Bugger. The code archives include a lot of special effects, but I can't find the one I need.


sonokong(Posted 2007) [#6]
...


jfk EO-11110(Posted 2007) [#7]
I think this would be pretty easy when you scale up a sprite and some spheres. Add some additionally blended stuff, and there it is, your blinding eclipse.


sonokong(Posted 2007) [#8]
Right...I'll ask if I have anymore questions.


sonokong(Posted 2007) [#9]
Tell me, what's wrong with this?
I can't see the earth...
Graphics3D 640,480
SetBuffer BackBuffer()


light=CreateLight()

camera=CreateCamera()
PositionEntity camera, 0,0,-7

sun=CreateSphere (16)
PositionEntity nucleus, 0,0,1
tex=LoadTexture( "thesun.jpg" )
EntityTexture sun,tex

;glow setup
s=1
Global sizex=640/s
Global sizey=480/s
Global glowtexture=CreateTexture (384,384,256)
Global sp=CreateSprite(camera)
MoveEntity sp,-.25,-0.06,1.18
EntityAlpha sp,.32
ScaleTexture glowtexture,GraphicsWidth()/sizex,GraphicsHeight()/sizey
EntityTexture sp,glowtexture
TextureBlend glowtexture, 5
While Not KeyDown( 1 )
TurnEntity sun,0.5,0.5,0.5
RenderWorld
CopyRect 0,0,sizex,sizey,0,0,BackBuffer(),TextureBuffer(glowtexture)
CameraViewport camera,0,0,GraphicsWidth(),GraphicsHeight()

Wend

pivot=CreatePivot()
PositionEntity pivot,0,0,1
orbit=CreateSphere(16,pivot)
tex1=LoadTexture( "orbit.jpg" )
EntityTexture orbit, tex1
ScaleEntity orbit, 0.3,0.3,0.3
PositionEntity orbit,4,0,0
While Not KeyDown (1)
TurnEntity pivot,0,3,0

pitch#=pitch#+1 yaw#=yaw#+1 roll#=roll#+0
RotateEntity sun,pitch#,yaw#,roll#

RenderWorld
Flip

Wend

End


jfk EO-11110(Posted 2007) [#10]
If you post sourcecode then make sure it's the code you actually tried to run. This code looks like it was never run in Blitz because:

you use POsitionEntity Nucleus, without to ever create or load such an entity.
Plus:
CreateTexture (384,384,256)... for texture sizes use only power-of-2 values: 2,4,8,16,32,64,128,256,512,1024..., eg:
CreateTexture(512,128,256)

Additionally: you can't see the earth, but I also don't see an entity named earth. Did you mean the orbit thing?

And:
instead of
TextureBlend glowtexture, 5
use
TextureBlend glowtexture, 3
I think that's more glow-ish


sonokong(Posted 2007) [#11]
Okay, I'll try the changes. Yes, earth is the orbit thing.


sonokong(Posted 2007) [#12]
Thanks.


_PJ_(Posted 2007) [#13]
Not trying to sound offensive, but here's a few tips to help you out when asking for help here:

1) Try and be patient! People will respond if they are able!

2) When posting code, as jfk mentioned, use the code you're actually working with, otherwise, it's not going to work regardless, and it's harder for anyone else to see whaat may be the problem (especially as the code gets more and more complex)

3) Also, when posting code, Use the {code} and {/code} (with square bracets) to give your code
A clearer depiction


4) Try to indent and format your code more easily, also, use ';' to give remarks and comments to help identify what does what.

Now, to answer some of your questions:

1) Lights in Blitz merely affect the surfaces they interact with, they do not actually emanate any visible rays or diffusion. This is often synthesised by use of Sprites.

2)I have made some alterations to your code (and annotated them) so at least, currently, it works to an extent:

Graphics3D 640,480
SetBuffer BackBuffer()
light=CreateLight(1) ;Lights need to have a type set. 1-3 for various types of Light.
camera=CreateCamera()
PositionEntity camera, 0,0,-7

sun=CreateSphere (16)
PositionEntity sun, 0,0,1  ;---------------------------changed 'nucleus' to SUN
tex=LoadTexture( "thesun.jpg" )
EntityTexture sun,tex

;glow setup
s=1
Global sizex=640/s
Global sizey=480/s
Global glowtexture=CreateTexture (384,384,256)
Global sp=CreateSprite(camera)
MoveEntity sp,-.25,-0.06,1.18
EntityAlpha sp,.32
ScaleTexture glowtexture,GraphicsWidth()/sizex,GraphicsHeight()/sizey
EntityTexture sp,glowtexture
TextureBlend glowtexture, 5
While Not KeyDown(57) ; - I have changed this to the SPACEBAR, otherwise, the second loop thinks you're still pressing ESCAPE!
TurnEntity sun,0.5,0.5,0.5
RenderWorld
Flip			;	Since you are working in the BackBuffer, you need To use Flip To display the Render!
CopyRect 0,0,sizex,sizey,0,0,BackBuffer(),TextureBuffer(glowtexture)
CameraViewport camera,0,0,GraphicsWidth(),GraphicsHeight()
Wend 

pivot=CreatePivot()
PositionEntity pivot,0,0,1
orbit=CreateSphere(16,pivot)
tex1=LoadTexture( "orbit.jpg" )
EntityTexture orbit, tex1
ScaleEntity orbit, 0.3,0.3,0.3
PositionEntity orbit,4,0,0
While Not KeyDown (1)
TurnEntity pivot,0,3,0

pitch#=pitch#+1 yaw#=yaw#+1 roll#=roll#+0
RotateEntity sun,pitch#,yaw#,roll# 

RenderWorld
Flip

Wend

End 




sonokong(Posted 2007) [#14]
Whoa. Thanks! That really solved a lot of my problems with the code. Would you happen to know why the orbit isn't showing?


sonokong(Posted 2007) [#15]
Hmmm...


jfk EO-11110(Posted 2007) [#16]
No offence, you need to learn how to debug these peanut things by your own. Use for example PointEntity camera, orbit, and/or EntityOrder to test if the orbit can be seen at all, or where it is etc.

Maybe it couldn't load the texture and therefor remained black?


sonokong(Posted 2007) [#17]
Don't worry. I don't take that offensively. I'm positive that it loaded the texture and I'll try out what you just said.


_PJ_(Posted 2007) [#18]
In the code I wrote above, 'orbit' is tyhe object handle for the 'earth' or satellite that gfoes around the 'nucleus' or 'sun'. It DOES show when I run it.

To check that the texture loaded, add in this line:

If Not (Tex1) Runtime Error "Texture Did Not Load Correctly"

Just after

Tex1 = LoadTexture("orbit.jpg")



sonokong(Posted 2007) [#19]
It doesn't work. Blitz3D doesn't understand "Runtime Error." I'm beginning to think that something's wrong with Blitz3D itself on my computer. Currently I'm putting the program to the test. Please reply if you know anything on this.


LAB[au](Posted 2007) [#20]
RuntimeError in one word will be recognized


b32(Posted 2007) [#21]
When I tried it, I can see the orbit, but only after pressing space first to enter the 2nd loop.
I used a brush instead of the texture, because I didn't have the orbit.jpg texture:
tex1=CreateBrush(255, 0, 0);LoadTexture( "orbit.jpg" )
PaintMesh orbit, tex1



_PJ_(Posted 2007) [#22]
Yes, sorry my fault for the typo. It should be RuntimeError as one word.

And yes, you need to press SPACE to enter the second loop, I assumed that was intended from the original code.


sonokong(Posted 2007) [#23]
i see


_PJ_(Posted 2007) [#24]
IS it working how you expected, sonokong?


sonokong(Posted 2007) [#25]
Yes and no. I created the second loop intentionally, but all this time even after entering it the orbit doesn't appear.


b32(Posted 2007) [#26]
Try commenting out the line:
EntityTexture orbit, tex1


sonokong(Posted 2007) [#27]
What?


b32(Posted 2007) [#28]
Place a ; before the line.


_PJ_(Posted 2007) [#29]
You need to be a little more specific, there have been numerous sugegstions to help you out, which have you tried?

Providing the texture exists and is loaded, the code I posted works fine (So long as you press the space bar).