MiniB3d for FreeBasic

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
Post Reply
angros47
Posts: 2386
Joined: Jun 21, 2005 19:04

Re: MiniB3d for FreeBasic

Post by angros47 »

I haven't yet tested, but atan2 return angles in radians (you wrote "+360" and "mod 360", so maybe you are assuming an angle in degrees).

Do you remember this post?
http://freebasic.net/forum/viewtopic.ph ... 70#p158170

Try multiplying the result by 57.

By the way, are you still working on your space simulation game?

Because I'm doing some experiments with LOD geospheres (aka spherical terrains).
Westbeam
Posts: 239
Joined: Dec 22, 2009 9:24
Contact:

Re: MiniB3d for FreeBasic

Post by Westbeam »

Damn it, why don't I remember I have already worked on that? :(
Thanks!
angros wrote:By the way, are you still working on your space simulation game?
Of course: X-the forgotten battles
angors wrote:Because I'm doing some experiments with LOD geospheres (aka spherical terrains).
Sounds like a great idea! Do they work already?
angros47
Posts: 2386
Joined: Jun 21, 2005 19:04

Re: MiniB3d for FreeBasic

Post by angros47 »

It still need some calibration, and some work for normals, but I hope it will be ready soon.
angros47
Posts: 2386
Joined: Jun 21, 2005 19:04

Re: MiniB3d for FreeBasic

Post by angros47 »

Version 0.8 is online. I will soon post some example.
angros47
Posts: 2386
Joined: Jun 21, 2005 19:04

Re: MiniB3d for FreeBasic

Post by angros47 »

Ok, a simple demo:


Image

Code: Select all

#include "openb3d.bi"


screen 18,  32, , &h10002 

	
Graphics3d 640,480,32,1,1


var camera=createcamera(0)
'cameraclscolor camera,0,255,0
camerarange camera,.00001,10

'scalemesh cube,.5,.5,.5

var x=loadgeosphere("44778d1336904592-need-help-earth-obliquie-projection-srtm_ramp2.world.5400x2700.jpg")'
'var x=creategeosphere(300)

var light=createlight()
moveentity light,10,10,10
pointentity light,x
moveentity camera,0,0,-30

scaleentity x,.01,.01,.01


var tex=loadtexture("MapOfEarth.jpg")
scaletexture tex,2700,2700
entitytexture x,tex


'wireframe 1

entitypickmode x,2


Dim CurrentX     As Integer
Dim CurrentY     As Integer
Dim MouseButtons As Integer


var sphere=Createsphere() 

scaleentity sphere,.1,.1,.1
entitycolor sphere,255,0,0

'x=camera
dim key as string

turnentity camera,80,0,0

do


	GetMouse CurrentX, CurrentY, , MouseButtons

	CameraPick (camera,CurrentX,480-CurrentY) 
	PositionEntity sphere,PickedX(),PickedY(),PickedZ()


	key=inkey
        if key=" " then moveentity camera,0,0,.08
        if key="z" then  moveentity camera,0,0,-.08:'freeentity x':end
        if key=chr(255)+"H" then turnentity camera,1,0,0,0
        if key=chr(255)+"P" then turnentity camera,-1,0,0,0
        if key=chr(255)+"M" then turnentity camera,0,-1,0,0
        if key=chr(255)+"K" then turnentity camera,0,1,0,0

	updateworld 1
	renderworld
sleep 1
	flip
loop until key=chr(27)
You need these files:
http://www.cartographersguild.com/attac ... 0x2700.jpg The heightmap

http://www.worldwidetelescope.org/docs/ ... fEarth.jpg The texture
Westbeam
Posts: 239
Joined: Dec 22, 2009 9:24
Contact:

Re: MiniB3d for FreeBasic

Post by Westbeam »

What's the "Loadgeosphere"-function? I can't find it in my openb3d-header. :/
angros47
Posts: 2386
Joined: Jun 21, 2005 19:04

Re: MiniB3d for FreeBasic

Post by angros47 »

Are you using the last version? If you have an header file from an older version, obviously there is no loadgeosphere because at time there was no such command!

If you download version 0.8 (for windows, or for linux) there is a newer file openb3d.bi with it.
Kot
Posts: 336
Joined: Dec 28, 2006 10:34

Re: MiniB3d for FreeBasic

Post by Kot »

Is there a billboard system? I couldn't find it :-/
angros47
Posts: 2386
Joined: Jun 21, 2005 19:04

Re: MiniB3d for FreeBasic

Post by angros47 »

What do you mean? A way to display text (scores, names of characters)? Or something else?
Kot
Posts: 336
Joined: Dec 28, 2006 10:34

Re: MiniB3d for FreeBasic

Post by Kot »

Mainly graphic, with some transparency. Names/scores would be nice.
Kronos
Posts: 9
Joined: Dec 10, 2012 19:53

Re: MiniB3d for FreeBasic

Post by Kronos »

sprites = billboards
angros47
Posts: 2386
Joined: Jun 21, 2005 19:04

Re: MiniB3d for FreeBasic

Post by angros47 »

You can use sprites, or you can use the header 2d.bi that allow you to use normal freebasic commands over 3d screen
Kot
Posts: 336
Joined: Dec 28, 2006 10:34

Re: MiniB3d for FreeBasic

Post by Kot »

Thanks. Did you implement also 2d part of the http://www.blitzbasic.com/b3ddocs/docs.php?
angros47
Posts: 2386
Joined: Jun 21, 2005 19:04

Re: MiniB3d for FreeBasic

Post by angros47 »

No, and I'm not going to do in the future, because I think it's unnecessary: in fact, the gfx library included in FreeBasic already supplies the same features, or most of them, so implementing Blitz 2D commands would just confuse developers, with no gain in programming features (at least, in my opinion).

Most of the features (lines, ovals, rectangles, image buffers, pages) are implemented both in BlitzBasic and FreeBasic, you only have to replace a command with its equivalent. FreeBasic has some powerful features that are not available in Blitz (like the commands PAINT, or DRAW); Blitz, on the other hand, has a couple of features that are not natively implemented in FreeBasic: rotation/zoom of sprites (but you can use the MultiPut routine), and pixel perfect collision detection (there are some routines for that, too, in the forum)

Anyway, if you likes OpenB3D, and you are looking for something similar for 2d graphics, I also made another library called OpenB2D; the forum thread is here:

http://www.freebasic.net/forum/viewtopi ... 14&t=22081

It features sprites (with zoom and rotations), tilemaps (they can be zoomed and rotated, too), isometric maps, pixel perfect collision, all hardware accelerated by the GPU through opengl (BlitzBasic and FreeBasic gfx don't use the GPU for accelerare 2d mode, they just use fast blitting and mmx instructions); OpenB2D, instead, can use hardware acceleration even for collision detection, if available.
petimat
Posts: 1
Joined: Jul 20, 2014 7:29

Re: MiniB3d for FreeBasic

Post by petimat »

Hi!
Can anyone point me in the right direction on normal mapping with openb3d?(e.g. a simple cube)

Edit:I've found that out already.
Post Reply