3d bubbles

Blitz3D Forums/Blitz3D Beginners Area/3d bubbles

Rubiks14(Posted 2005) [#1]
I was wondering how you would make bubbles in 3d(by using spheres). Would you use TranslateEntity or would it have to do anything with the texture or what? Thanks for all help.

Rubiks14


Rhyolite(Posted 2005) [#2]
You would use the texture to give the sphere the appearance of a bubble and use TranslateEntity to 'move' the bubble. You will most likely need to apply some 'Alpha' transparency to the bubble to make it semi-transparent (use EntityAlpha or similar).

Rhy :)


Rubiks14(Posted 2005) [#3]
that is what i meant alpha. don't know what i was thinking when i said translateentity, i guess i was thinking entitytransparency (it's been a long day). but anywat thank you for your reply


big10p(Posted 2005) [#4]
Depending on how detailed the bubbles need to be, you could probably do a good job without using a texture at all - just use alpha with a decent entity color and a high entity shininess setting.

You could also try alternately scaling them up/down a tiny amount on the Y axis, then the X axis to give them a bit of wobble. :)


Rubiks14(Posted 2005) [#5]
How would i do that? Would i just set up a loop?

Edit: Oh and just one more question. How would i tell blitz to make like a swirl of colors?


Ross C(Posted 2005) [#6]
Try using a spherical enviroment map on it too :o)


Anatoly(Posted 2005) [#7]
Or if they are just small bubbles under water you can just use bunch of small sprites with a pictures of a bubble on 'em...


big10p(Posted 2005) [#8]
How would i do that? Would i just set up a loop?
OK, here's a very simple example to give an idea of what I mean:

	Graphics3D 800,600,32
	SetBuffer BackBuffer()

	cam = CreateCamera()
	PositionEntity cam,0,0,-10
	CameraClsColor cam,200,50,150
	
	light = CreateLight()
	TurnEntity light,40,70,0
	
	bubble = CreateSphere(32)
	PositionEntity bubble,0,0,-5
	EntityColor bubble,0,100,200
	EntityAlpha bubble,.5
	EntityShininess bubble,1
	EntityBlend bubble,3
	
	ang# = 0.0
	
	While Not KeyHit(1)
	
		ScaleEntity bubble,1+(Sin(ang)*.05),1+(Cos(ang)*.05),1
		ang = (ang + 10) Mod 360.0

		RenderWorld
		Flip(1)

	Wend

	End


Oh and just one more question. How would i tell blitz to make like a swirl of colors?
Sorry, I'm not sure what you mean.


Rubiks14(Posted 2005) [#9]
ok what i meant by that is like have a mixture of colors without using a texture. you know like when u look at a balloon (or gas) in the sun how it has like a little swirl of colors like purple and darker colors.


Rook Zimbabwe(Posted 2005) [#10]
use a texture... a JPG or PNG or the like with your color scheme...


David819(Posted 2005) [#11]
He doesn't want to use a texture. i'm not sure you can do that in blitz unless you coded it in blitz with createtexture rather than with loadtexture.


jfk EO-11110(Posted 2005) [#12]
Using a sphere seems like a waste of Tris to me. If you have seen the bubbles of my FPS engine (underwater FX), I did them this way:
Sprites with a particle engine, using a simple but clean PNG or TGA texture (with Alpha Channel) of one bubble. THis way you can have a lot of bubbles and they look fine.

You may also try diffrent blending modes, eg: additive blending.


Rubiks14(Posted 2005) [#13]
He doesn't want to use a texture. i'm not sure you can do that in blitz unless you coded it in blitz with createtexture rather than with loadtexture.


ok thank you, i was just wondering if you could

Using a sphere seems like a waste of Tris to me. If you have seen the bubbles of my FPS engine (underwater FX), I did them this way:
Sprites with a particle engine, using a simple but clean PNG or TGA texture (with Alpha Channel) of one bubble. THis way you can have a lot of bubbles and they look fine.

You may also try diffrent blending modes, eg: additive blending.


i am just doing it for kinda a particle thing just to learn particles some more


big10p(Posted 2005) [#14]
OK, if you want this for particles then using meshes isn't the way to go.

However, if you really want to use meshes, the swirling color effect (without using a texture) can kinda be done with vertex colors:
	Graphics3D 800,600,32
	SetBuffer BackBuffer()

	SeedRnd MilliSecs()

	cam = CreateCamera()
	CameraClsColor cam,100,0,100
	PositionEntity cam,0,0,-5
	
	light = CreateLight()
	light2 = CreateLight()
	TurnEntity light,50,90,0
	TurnEntity light2,90,50,0
	
	bubble = CreateSphere(32)	
	inside = CreateSphere(32)	
	FlipMesh inside
	AddMesh inside,bubble
	FreeEntity inside

	EntityShininess bubble,1
	EntityBlend bubble,3
	EntityFX bubble,2+32
	
	ss = 0
	ee = 155
	surf = GetSurface(bubble,1)
	For i = 0 To CountVertices(surf)-1
		VertexColor surf,i,50,Rand(ss,ee),Rand(ss,ee),.6
	Next
	
	ang# = 0.0
	
	While Not KeyHit(1)

		ScaleEntity bubble,1+(Cos(ang)*0.05),1+(Sin(ang)*0.05),1+(Cos(ang)*0.05)
		ang = (ang + 10) Mod 360.0
		
		TurnEntity bubble,.5,.5,.5

		RenderWorld
		Flip True
	Wend

	End


This is obviously an 'expensive' way of doing things though, so probably not what you want.


Rubiks14(Posted 2005) [#15]
i don't no, that is pretty freakin cool. i watched it for like 10 mins


Nicstt(Posted 2005) [#16]
yep, looks sweet


big10p(Posted 2005) [#17]
Yeah, it is kinda mesmerizing. :)

Might make a good screen saver, just having a big bubble floating around the screen. Would probably be better using a geosphere instead, though - to get rid of the vertex colors converging at the poles.