3d space...homeworld like..

Blitz3D Forums/Blitz3D Programming/3d space...homeworld like..

darklordz(Posted 2004) [#1]
Ive been working on trying to get a 3d space enviorment thats homeworld like. I did this by creating a huge flipped 3d sphere mesh and parenting it to the camera. And creating a star debris field using some code from the code acrc. but it still doesnt look right. Does any body have any idea how i should go about this?


gburgess(Posted 2004) [#2]
Homeworld seems to use some kind of cunning polygon-based system for it's backdrops. Guess you'd need to write an editor to make them well.


Ross C(Posted 2004) [#3]
Yeah, a standard 3d sphere really isn't enough. I gave up trying to make a space enviroment. Didn't really have an ideas to go on :)


darklordz(Posted 2004) [#4]
Mine looks quite ok but i needed it to look a bit more flashy....So adding flares and some sprites would be in order.... It's just that if i parent the sphere (flipped) to the camera and i move the ship it looks cool, but i need to be able to restrict the ship from moving to far.

How big can the biggest sphere be?


darklordz(Posted 2004) [#5]
[edit double post]


mearrin69(Posted 2004) [#6]
I'd think you'd do it just like a skybox. The camera shouldn't move in relation to the sphere at all. Local phenomenon - dust clouds, etc. - should all be separate entities.
M


darklordz(Posted 2004) [#7]
the space debris code i use is fine but a bit outdated and also i need it all to move to if the camera moves the sphere goes along with it creating the illusing ur in a static place while ur not realy because the debris will seem to be moving instead....


Paul "Taiphoz"(Posted 2004) [#8]
Id use a skybox. in fact I should say I did use a skybox. And it looked awsome with some nice nebula clouds on it.

What I did was use entity order to draw the skybox first ignoring its order. then everything else on top of it. this let me make the skybox smaller.

I then just positioned the skybox at the same pos as the cam, this also meant I could rotate pan do what i liked to the cam and the skybox didnt rotate or pan with it.

Hope this helps.


_PJ_(Posted 2004) [#9]
No need for a HUGE skybox/sphere mesh. A smaller one EntityOrdered worked okay for me. I've not seen 'Homeworld', so I am not exactly sure on what effects etc. they have. I have also modified the starfield code in the archives too for added effect. Now I have also populated my space-sectors with Planets and stations, asteroids etc. it all looks quite aesthetic (Still not Eve-Online standard though! I can post some screenies when I get home... My project is to be open source anyway, so if any of my code may be helpful - you're welcome!


darklordz(Posted 2004) [#10]
Cool can't wait..


Pepsi(Posted 2004) [#11]
Hi darklordz, The homeworld space scenery also interests me and I keep putting off trying to mimic that. To me, it looks like multisegmented sphere where it actaully uses the vertex colors to achieve those perty nebulas. Like Glenny-boy mentioned, I would need to make a specific editor for this where I could select any vertice I want and apply a vertex color. I probably would have it so I can somehow move any of the sphere's vertices so I can have more freedom to design the nebula scene. Anyways, still haven't had time to do it lately.


_PJ_(Posted 2004) [#12]
Sounds like good stuff, Todd - bit techy :) good luck!

Here's my efforts...

COPYAND PASTEhttp://homepage.ntlworld.com/r.chowdhury/GalacticSkybox1.PNG****************************************Large pics

COPYANDPASTEhttp://homepage.ntlworld.com/r.chowdhury/GalacticSkybox2.PNG****************************************Large pics


Pepsi(Posted 2004) [#13]
Thanks, hrmm... since I got today off, I'll go ahead and start one and post the code here to share.

For simple sakes, what I'm aiming for is:

- Create a custom inverted sphere.
- Camera location always in center of sphere, but rotates to view different parts of the sphere.
- Seperate list that holds what vertices the sphere's polys connect to. Ie: we need a way to weld and unweld shared vertices on the fly.
- To select a vertex to edit, select a sphere's poly first and highlight poly's vertices to select. When vertex is picked, we now have options to change vertex color and/or alpha, change position, weld and unweld.
- ofcoarse, a little load/save .b3d routine.
- no gui, need to actually finish this. :)

Should be fun to do. Let's see... :)


Pepsi(Posted 2004) [#14]
Nice pictures, Malice! very perty.

if you look here:
http://games.sierra.com/games/homeworld/hw/screenshots/

This is what darklordz and me is after. Looking closely at the nebula, it has a polygon mesh look to it.


rhuk(Posted 2004) [#15]
Looking good Malice! Nice nebula effects. I'm doing a 3d space shooter with homeworld type sky sphere's also. Mine doen't look as good as yours though. Also I see you've implemented an 'Elite' style minimap system. I was planning on doing the very same thing!


darklordz(Posted 2004) [#16]
@Todd

What i did whas
- Create Inverted Sphere
- Texture it with some nice nebula texture.
- Generate a light source from a point in the sphere
- Use the light source to create flares
- Parent the inverted sphere to the camera
- Create a starfield / space debris (not bound to camera)
- Move player trough the space but due to the sphere beeing parented to the cam it looks like ur standing still...but moving trough the stars says otherwise.. :S

also you know when you move the flares move as well (in the right direction) well homeworks has that as well only not with flares but with it's background scenery... it has a great effect. My main pc broke so i don't have my sources i'll try and rewrite soon (i lose my 180 GB HD/My GFORCE/My Monitor) the pc overheated and melted everything... 3/5 fans were defective...

also check this
http://www.homeworld2.sierra.com/gallery.php

there are some movies you could stream to get a better grip of what im trying to achieve...


Pepsi(Posted 2004) [#17]

Move player trough the space but due to the sphere beeing parented to the cam it looks like ur standing still...but moving trough the stars says otherwise..



Ahhh... just get your current camera positon coordinates and then PositionEntity the sphere to those same coordinates in your main loop. This will make the sphere follow you around without it also being "locked" with your camera's rotation via parenting.


darklordz(Posted 2004) [#18]
the problem is i cant get the sphere to be like absolute so eventualy if it's not parented the player moves out of the sphere... :S witch is not my intention ....

wount the position entity become a bit jittery?


Pepsi(Posted 2004) [#19]
Thats the only way I can think of doing it off the top of me head. :\ Every now and then, I catch a post about floating point inaccuracy problems when people are trying to make a open space game like elite and homeworld. But, I haven't had the chance to do my own open space game to experience these problems first hand yet.

Unless it has something to do when scaling the size of the sphere to be bigger, It's hard for me to see why when an entity like a sphere for space graphics would not be positioned exactly with the camera position with the EntityPosition function. I never experience jittery problems when I have done something similar as for a sky to move around at camera position while walking around on a terrain.

If scaling cause the problem of floating point inaccurcies on the sphere's position, then try if you haven't already by leaving the sphere unscaled and do a EntityOrder on it so it will render behind everthing else.


Pepsi(Posted 2004) [#20]
Forgot to mention you could try ScaleMesh instead of ScaleEntity on your sphere if you haven't tried that.


_PJ_(Posted 2004) [#21]
Thanks guys! :)

I have the skybox parented to a special pivot. All the movement etc. is done on the pivot, (this also allows me to change cameras and camera views).



If scaling cause the problem of floating point inaccurcies on the sphere's position, then try if you haven't already by leaving the sphere unscaled and do a EntityOrder on it so it will render behind everthing else.



Yeah - I agree, it's probably having this huge sphere again. Also, this means you'll need large camera-range. So it may even be some clipping effects. I would definitely have a smaller sphere (with a diameter about 1.5xthe longest dimension of your spaceship)
-------------------

with regards to the homeworld screenies, they look good, but dont appear to have a distinct advantage over a simple skybox method.

(This is what I am aiming for)


darklordz(Posted 2004) [#22]
Well i redid the source a bit in like 30 mins.... It all works and looks cool but there are some minor glitches i included the source so you can modify it as you wish hope u guys like it here are some ingame screenies....

click to enlarge....



the source only 200K
the build 600K

code from main file (not with includes)
note: changing the dist value will inclrease the size of the sphere, fogrange and camrange

; 3D Space Debris Demo
; By R.Baldewsingh :)
; ----------------------------
; The following code is just a simple
; demonstration of how i would create
; homeworld space. i lost my original
; code so this is a quick rewrite. I
; have used libs from others and my-
; self, many thanks! 1 thing that is
; still missing is the lensflares...
; ----------------------------

AppTitle "3D Space Demo"
Graphics3D 640,480,32,2
SetBuffer BackBuffer()
HidePointer

Include "bloom.bb"
Include "sdloader.bb"

Global PRNT%,CHILD%,CAMERA%,LIGHT%,SPHERE%,SPHERE_TEX1%,SPHERE_TEX2%
Global VEL#,MXS#,MYS#,BLURIMAGE%,BLURTEXTURE%,SW%,SH%

Global ENABLEBLUR% = 1
Global NSTR% = 1000
Global DIST% = 3000

Global FONT% = LoadFont("Tahoma",14) : SetFont(FONT%)

SpaceMapSetup_Load()   ; Initialize the DLoader
SpaceMapSetup_Create() ; Create Cam/Piv/Space Scene
SpaceDebris_Create%()  ; Setup Debris / Starfield (thankx rob)
BlurImage_Create()     ; Full Screen Motion Blur (thankx arkon)
InitGlow(CAMERA%)      ; FakeHDR (thankx naama)

While Not KeyHit(1)
	SpaceMapSetup_Update()
	SpaceDebris_Update%()
	Player_Update()
	
	If ENABLEBLUR% = 1 
		BlurImage_Update(.5)
		RenderGlow(0,5,1,1)
	Else
		RenderGlow(0,2,4,5)
	EndIf
	
	UpdateWorld
	RenderWorld
	
	Color 0,0,0
	Rect 0,0,GraphicsWidth(),40
	Rect 0,GraphicsHeight()-40,GraphicsWidth(),GraphicsHeight()
	Color 255,255,255
	Text 20,15,"3D Space Demo"
	
	If KeyHit(67) Then SaveScreenshot() ; F9

	Flip
Wend	

Function SpaceDebris_Create%()
	For I = 1 To NSTR%
		TMP% = CreateSprite()
		EntityAutoFade TMP%,DIST%/4,DIST%/2
		PositionEntity TMP%,Rnd(-DIST%,DIST%),Rnd(-DIST%,DIST%),Rnd(-DIST%,DIST%)
		EntityParent TMP%,PRNT%
	Next
End Function

Function SpaceDebris_Update%()
	For I=1 To CountChildren(PRNT%)
		CHILD% = GetChild(PRNT%,I)
		If EntityDistance(CHILD%,CAMERA%)>DIST%
			PositionEntity CHILD%,EntityX(CAMERA%),EntityY(CAMERA%),EntityZ(CAMERA%)
			RotateEntity CHILD%,EntityPitch(CAMERA%),EntityYaw(CAMERA%),0
			MoveEntity CHILD%,Rnd(-500,500),Rnd(-500,500),DIST%/2
		EndIf
	Next
End Function

Function SpaceMapSetup_Create()
	Dload_Do_Load()
	CAMERA% = CreateCamera()
	CameraRange CAMERA%,1,DIST%
	CameraFogMode CAMERA%,1
	CameraFogColor CAMERA%,0,0,0
	CameraFogRange CAMERA%,1,DIST%
	PRNT% = CreatePivot()
	
	LIGHT% = CreateLight(1,CAMERA%)
	RotateEntity LIGHT,45,0,0
	
	SPHERE% = CreateSphere(32,PRNT%)
	SPHERE_TEX1% = Dload_Get_Handle(1)
	SPHERE_TEX2% = Dload_Get_Handle(2)
	EntityTexture(SPHERE%,SPHERE_TEX2%)
	EntityTexture(SPHERE%,SPHERE_TEX1%)
	
	FlipMesh SPHERE%
	ScaleMesh SPHERE%,DIST%,DIST%,DIST%
End Function

Function SpaceMapSetup_Update()
	; Have to Add Code here that Positions Sphere in right place so cam doesnt fly out of it....
End Function

Function SpaceMapSetup_Load()
	Dload_Add_Item("gfx\neb_zero.jpg",FILE_TEX%)
	Dload_Add_Item("gfx\neb_one.jpg",FILE_TEX%)
End Function

Function Player_Update%()
	MXS#=MouseXSpeed()
	MYS#=MouseYSpeed()
	MoveMouse GraphicsWidth()/2,GraphicsHeight()/2

	If MouseDown(1)
		VEL#=VEL#+1
	EndIf
	VEL=VEL/1.05
	
	TurnEntity CAMERA%,MYS#,-MXS#,0
	MoveEntity CAMERA%,0,0,VEL#
End Function

Function BlurImage_Create()
	Local CAM% = CreateCamera()
	CameraClsMode CAM%, 0, 0
	CameraRange CAM%, 0.1, 1.5
	MoveEntity CAM%, 0, 0, 10000

	SW% = GraphicsWidth()
	SH% = GraphicsHeight()

	Local SPR%= CreateMesh(CAM%)
	Local SF% = CreateSurface(spr)
	AddVertex SF%, -1, 1, 0, 0, 0
	AddVertex SF%, 1, 1, 0, 1, 0
	AddVertex SF%, -1, -1, 0, 0, 1
	AddVertex SF%, 1, -1, 0, 1, 1
	AddTriangle SF%, 0, 1, 2
	AddTriangle SF%, 3, 2, 1
	EntityFX SPR%, 17
	ScaleEntity SPR%, 1024.0 / Float(SW%), 1024.0 / Float(SW%), 1
	PositionEntity SPR%, 0, 0, 1.0001
	EntityOrder SPR%, -100000
	EntityBlend SPR%, 1
	BLURIMAGE% = SPR%

	BLURTEXTURE% = CreateTexture(1024, 1024, 256)
	EntityTexture SPR%, BLURTEXTURE%
End Function

Function BlurImage_Update(POWER#)
	EntityAlpha BLURIMAGE%, POWER#
	CopyRect  SW% / 2 - 512, SH% / 2 - 512, 1024, 1024, 0, 0, BackBuffer(), TextureBuffer(BLURTEXTURE%)	
End Function

Function SaveScreenshot()
    iFileNumber% = 0
    Repeat
        iFileNumber = iFileNumber + 1
        sFileName$ = "Screenshot" + String$("0", 3 - Len(Str$(iFileNumber))) + iFileNumber + ".bmp"
    Until Not(FileType(sFileName))   
    SaveBuffer FrontBuffer(), sFileName
End Function



_PJ_(Posted 2004) [#23]
Wow! Eagle nebula is that? Looks good, especially with that blur-effect! Instead of creating sprites, I have copied a little circular one, and coloured them too, not sure how efficient this is.


darklordz(Posted 2004) [#24]
efficient ... no! better perhaps... :)


rhuk(Posted 2004) [#25]
Your spacesphere is suffering from the same problems I have, namely the texture gets pulled together at the top and bottom of the sphere. There was a post on here recently on how to polar coords in photoshop to modify the texture to minimize this effect.

Check out sswift's comments in this thread: http://www.blitzbasic.com/Community/posts.php?topic=31747


_PJ_(Posted 2004) [#26]
Again, sounds like an awful lot of hassle, which I circumvented because it's a cosmos skyshpere, so the majority of it is black, with equatorial nebulae which, if distorted a little - still look like nebulae :)

Of course, rhuk, those ideas are a lot more professional.


darklordz(Posted 2004) [#27]
Thanks rhuk. Like i said i coded this in what like 30 mins. I'll redo the texture in photoshop. Also i used texturemaker to make this seamles but it didnt realy work it's just a matter of correcting the texture cords...

thanks again!

@Malice...who said im not a pro =)


maximo(Posted 2004) [#28]
I like space thing you conjured up darky, keep it up ;)


darklordz(Posted 2004) [#29]
I updated the demo. I fixed a bug in the static data loader
and i corrected the textures. Also i tought that in homeworld space was brownish i should try it as well so i did and it looks better i think....

Almost forgot Thanks Mr. Swift somehow polar distorthing thingy slipped my notice in adobe :P


eBusiness(Posted 2004) [#30]
Real space looks black, if you havn't noticed. But I must admit that Homeworld space looks cooler.


_PJ_(Posted 2004) [#31]
Things like skyboxes and the debris-fields, although highly unrealistic, make games much more playable. Debris-fields give the impression of speed and movement - so the player can actually see that they ARE moving, and skysphere's and backdrops are valuable aids in orientation. We dont realise how much we use these things whilst playing games, but we do!


darklordz(Posted 2004) [#32]
heh like i said they space in HOMEWORLD! was brown.... Not Black witch my space initialy was so i altered it and it looks better also i just finished modeling a spaceship (no textures) in record time 7 mins :P and it looks awesome in the space ... i'll update more later after ive writtin a spawing and control functions//




Kepu(Posted 2011) [#33]
Meybe I am late, but

Where I can find sdloader.bb