V0.45 Beta

BlitzMax Forums/MiniB3D Module/V0.45 Beta

simonh(Posted 2007) [#1]
Looking for a few people to test this - if you fancy it please send me an email to simonh@...


*(Posted 2007) [#2]
Trying to compile the Bird demo on a clean Max install with all the latest updates and syncmods generates:
Building BirdDemo
Compiling:bbtype.bmx
flat assembler  version 1.66
3 passes, 4637 bytes.
Compiling:bbvkey.bmx
flat assembler  version 1.66
3 passes, 5233 bytes.
Compiling:cfuncs.cpp
Build Error: failed to compile C:/Program Files/BlitzMax/samples/minib3d-v045-beta/inc/cfuncs.cpp
Process complete


Firepaint3d generates
Building firepaint3d
Compiling:cfuncs.cpp
Build Error: failed to compile C:/Program Files/BlitzMax/samples/minib3d-v045-beta/inc/cfuncs.cpp
Process complete


Will check all the other things I dont know if im missing anything from the install I have the latest MingW runtime installed as well.


simonh(Posted 2007) [#3]
Just to check do you have the following:

* BlitzMax 1.28
* MinGW 5.1.3 installed in the C root dir
* C:\MinGW\bin set to your system PATH environment variable
* Quick Build off

If so it should work - at least it does here!


mongia2(Posted 2007) [#4]
i compiled with a mingw 5.1.3

Linking:camerapick.exe
C:/Programmi/BlitzMax/lib/libgcc.a(unwind-sjlj.o):(.text+0x28): undefined reference to `__mingwthr_key_dtor'
C:/Programmi/BlitzMax/lib/libgcc.a(gthr-win32.o):(.text+0xc3): undefined reference to `__mingwthr_key_dtor'


simonh(Posted 2007) [#5]
Did you have Quick Build off?


mongia2(Posted 2007) [#6]
yes i have a Quick Build off


simonh(Posted 2007) [#7]
You might want to try it without any C++ references. To do so, make the following changes to minib3d.bmx:

Comment out these lines:

' c++
Import "inc/cfuncs.cpp"			' contains C_UpdateNormals and C_IntersectTriangle
Import "inc/ccol.cpp"			' contains C_checkTriangle

Comment out these lines:

Extern
	Function C_UpdateNormals(no_tris:Int,no_verts:Int,tris:Short Ptr,vert_coords:Float Ptr,vert_norms:Float Ptr) ' used by TMesh.bmx
	Function C_IntersectSegmentTriangle:Int(	px:Float, py:Float, pz:Float,..
												qx:Float, qy:Float, qz:Float,..
												ax:Float, ay:Float, az:Float,..
												bx:Float, by:Float, bz:Float,..
												cx:Float, cy:Float, cz:Float,..
                             					u:Float Var, v:Float Var, w:Float Var, t:Float Var) ' used by TPick.bmx
	Function C_checkTriangle:Int(col_pack:Float Ptr,a:Float Ptr,b:Float Ptr,c:Float Ptr) ' use by TCollision.bmx
End Extern

Add these lines somewhere:

Function C_UpdateNormals(no_tris:Int,no_verts:Int,tris:Short Ptr,vert_coords:Float Ptr,vert_norms:Float Ptr)
End Function
Function C_IntersectSegmentTriangle:Int(px:Float, py:Float,pz:Float,qx:Float,qy:Float,qz:Float,ax:Float, ay:Float,az:Float,bx:Float,by:Float,bz:Float,cx:Float, cy:Float,cz:Float,u:Float Var,v:Float Var,w:Float Var,t:Float Var)
End Function
Function C_checkTriangle:Int(col_pack:Float Ptr,a:Float Ptr,b:Float Ptr,c:Float Ptr)
End Function

Finally set:

Const USE_C=True
To False.


klepto2(Posted 2007) [#8]
Hi simon, works like a charm. no problems till now. All samples and demos runs really fast. And the animations just one word ... WOW .

Thx. I start to add my extensions :)


Brucey(Posted 2007) [#9]
In the spheremap example, the text is inverted...

Otherwise, it rocks :-)


klepto2(Posted 2007) [#10]
A small fix for the flipped text when using Spheremaps, well it only aplies to loaded textures but better than nothing:

At first in TMesh.bmx comment out line 1899 this line should look something like this:

If tex_flags&64<>0
						glScalef(1.0,-1.0,-1.0) <--- this needs to be commented out
					EndIf


And least you have to change TTexture.bmx:

Replace the Function LoadanimTexture at line 117 with :
Function LoadAnimTexture:TTexture(file$,flags,frame_width,frame_height,first_frame,frame_count,tex:TTexture=Null)

		If flags&128 Then Return LoadCubeMapTexture(file$,flags,tex)
	
		If tex=Null Then tex:TTexture=New TTexture

		If FileFind(file$)=False Then Return Null
		
		tex.file$=file$
		tex.file_abs$=FileAbs$(file$)
		
		' set tex.flags before TexInList
		tex.flags=flags
		tex.FilterFlags()
		
		' check to see if texture with same properties exists already, if so return existing texture
		Local old_tex:TTexture
		old_tex=tex.TexInList()
		If old_tex<>Null And old_tex<>tex
			Return old_tex
		Else
			If old_tex<>tex
				ListAddLast(tex_list,tex)
			EndIf
		EndIf

		' load pixmap
		tex.pixmap=LoadPixmap(file$)

		' convert pixmap to appropriate format
		If tex.pixmap.format<>PF_RGBA8888
			tex.pixmap=tex.pixmap.Convert(PF_RGBA8888)
		EndIf
		
		' ---
		
		' if tex not anim tex, get frame width and height
		If frame_width=0 And frame_height=0
			frame_width=tex.pixmap.width
			frame_height=tex.pixmap.height
		EndIf

		' ---
		
		tex.no_frames=frame_count
		tex.gltex=tex.gltex[..tex.no_frames]

		' ---
		
		' pixmap -> tex

		Local xframes=tex.pixmap.width/frame_width
		Local yframes=tex.pixmap.height/frame_height
			
		Local startx=first_frame Mod xframes
		Local starty=(first_frame/yframes) Mod yframes
			
		Local x=startx
		Local y=starty
	
		Local pixmap:TPixmap
	
		For Local i=0 To tex.no_frames-1
	
			' get static pixmap window. when resize pixmap is called new pixmap will be returned.
			pixmap=tex.pixmap.Window(x*frame_width,y*frame_height,frame_width,frame_height)
			x=x+1
			If x>=xframes
				x=0
				y=y+1
			EndIf
			
			If tex.flags&64 Then 
				pixmap = YFlipPixmap(pixmap)
			EndIf
		
		
			' ---
		
			pixmap=AdjustPixmap(pixmap)
			tex.width=pixmap.width
			tex.height=pixmap.height
			Local width=pixmap.width
			Local height=pixmap.height

			Local name
			glGenTextures 1,Varptr name
			glBindtexture GL_TEXTURE_2D,name

			Local mipmap
			If tex.flags&8 Then mipmap=True
			Local mip_level=0
			Repeat
				glPixelStorei GL_UNPACK_ROW_LENGTH,pixmap.pitch/BytesPerPixel[pixmap.format]
				glTexImage2D GL_TEXTURE_2D,mip_level,GL_RGBA8,width,height,0,GL_RGBA,GL_UNSIGNED_BYTE,pixmap.pixels
				If Not mipmap Then Exit
				If width=1 And height=1 Exit
				If width>1 width:/2
				If height>1 height:/2

				pixmap=ResizePixmap(pixmap,width,height)
				mip_level:+1
			Forever
			tex.no_mipmaps=mip_level

			tex.gltex[i]=name
	
		Next
				
		Return tex
		
	End Function


I hope simon will find another fix for this as it is just a dirty fix by me.


z4g0(Posted 2007) [#11]
hi!, I've just upgrade the minb3D version in my project, and I'm getting a 'generic' Memory Access Violation on start @
	//TSurfaces.bmx
  Method FreeVBO()
	
		glDeleteBuffers(6,vbo_id)
	
  End Method

(in the old minib3D version all works)


other question:
in current project I'm using the really usefull and versatile "tGlobal.BeginMax2D() / tGlobal.EndMax2D()" system, but in the new version (copy&paste both function form old tGlobal to new tGlobal) don't seem to work properly


klepto2(Posted 2007) [#12]
Which old version did you use?
Extended or normal?

Normally you have to copy some global variables also.


siread(Posted 2007) [#13]
Ok, using Vista. Everything build like a charm after upgrading MinGW. Animations are much, much faster, topping 999fps in release mode. Happy days! Looking forward to getting my 22 players running around. I'll let you know how that goes.

I have an issue with my mesh though. When animated he gets all distorted. It works fine with the B3DSdk (cool idea implementing that btw!)


MiniB3D - Not animated


MiniB3D - Animated


B3DSDK - Animated

I'll try MacOS now...


simonh(Posted 2007) [#14]
If your OpenGL version is 1.3 or less, the VBO functions will cause problems - they need to be replaced with ARB ones. Will be fixed in the final version, but in the meantime you may want to try updating your graphics driver to see if that fixes it.

As for the animated mesh - ouch! Can you send me the file Si?


z4g0(Posted 2007) [#15]
dunno why... but deleting the piece of VBOsupport check&init
		' get hardware info and set vbo_enabled accordingly
		THardwareInfo.GetInfo()
		THardwareInfo.DisplayInfo()
		If USE_VBO=True
			vbo_enabled=THardwareInfo.VBOSupport
		EndIf

of tGlobal, now all works fine... & really really faster (than old, 0.42 standard version)!!

so.. seems to be very fast also without vbo support and at the moment i'll not use this feature.

I've noticed a z-sort problem (that old versions doesn't have) :

HERE:
a screen from 042 minib3D version

HERE:

a screen from 045 beta : the .b3D seems also better (as in Blitz3D!!), but have zsort problems


HERE:

enabling the VBO support (but disabling glDeleteBuffers(6, vbo_id) that cause MAV )


My VC: Ati mobility radeon X1400






[EDIT]

If your OpenGL version is 1.3 or less, the VBO functions will cause problems - they need to be replaced with ARB ones. Will be fixed in the final version, but in the meantime you may want to try updating your graphics driver to see if that fixes it.


mmm could be... i'll check Ogl version and test it tomorrow

thanks 4 all ;)


mongia2(Posted 2007) [#16]
Building anim
Compiling:anim.bmx
flat assembler version 1.66
3 passes, 6608 bytes.
Linking:anim.debug.exe
C:/Programmi/BlitzMax/lib/libgcc.a(unwind-sjlj.o):(.text+0x28): undefined reference to `__mingwthr_key_dtor'
C:/Programmi/BlitzMax/lib/libgcc.a(gthr-win32.o):(.text+0xc3): undefined reference to `__mingwthr_key_dtor'
Build Error: Failed to link C:/Documents and Settings/carlo/Documenti/Coccopulta/minib3d-v045-beta/minib3d-v045-beta/examples/anim.debug.exe
Process complete


i change a Add these lines somewhere:


Function C_UpdateNormals(no_tris:Int,no_verts:Int,tris:Short Ptr,vert_coords:Float Ptr,vert_norms:Float Ptr)
End Function
Function C_IntersectSegmentTriangle:Int(px:Float, py:Float,pz:Float,qx:Float,qy:Float,qz:Float,ax:Float, ay:Float,az:Float,bx:Float,by:Float,bz:Float,cx:Float, cy:Float,cz:Float,u:Float Var,v:Float Var,w:Float Var,t:Float Var)
End Function
Function C_checkTriangle:Int(col_pack:Float Ptr,a:Float Ptr,b:Float Ptr,c:Float Ptr)
End Function

Finally set:


Const USE_C=TrueTo False.


and a use a mod from simonread but i have same error


simonh(Posted 2007) [#17]
Did you do the first bit as well? You need to delete these lines:

' c++
Import "inc/cfuncs.cpp"			' contains C_UpdateNormals and C_IntersectTriangle
Import "inc/ccol.cpp"			' contains C_checkTriangle
Comment out these lines:


Extern
	Function C_UpdateNormals(no_tris:Int,no_verts:Int,tris:Short Ptr,vert_coords:Float Ptr,vert_norms:Float Ptr) ' used by TMesh.bmx
	Function C_IntersectSegmentTriangle:Int(	px:Float, py:Float, pz:Float,..
												qx:Float, qy:Float, qz:Float,..
												ax:Float, ay:Float, az:Float,..
												bx:Float, by:Float, bz:Float,..
												cx:Float, cy:Float, cz:Float,..
                             					u:Float Var, v:Float Var, w:Float Var, t:Float Var) ' used by TPick.bmx
	Function C_checkTriangle:Int(col_pack:Float Ptr,a:Float Ptr,b:Float Ptr,c:Float Ptr) ' use by TCollision.bmx
End Extern

What mod from Simon Read? You've lost me.


siread(Posted 2007) [#18]
I spoke to Mongia on MSN and sent him my built minib3d.mod which works fine for me.


siread(Posted 2007) [#19]
Another issue I've noticed is that if you ScaleEntity (0.5) your mesh, then Animate mesh, it shrinks even further to about 0.1 of the original scale.


siread(Posted 2007) [#20]
Also having problems with Collision.

I converted the B3D collision example:
http://www.blitzbasic.com/b3ddocs/command.php?name=Collisions&ref=3d_a-z

But the ball only collides with the floor. Have I misunderstood something?


' Collisions Example
' ------------------
Import sidesign.minib3d

Graphics3D 640,480
'SetBuffer BackBuffer()

' Set collision Type values
type_ground=1
type_character=2
type_scenery=3

camera=CreateCamera()
RotateEntity camera,45,0,0
PositionEntity camera,0,15,-10

light=CreateLight()
RotateEntity light,45,0,0

' Create cube 'ground'
cube=CreateCube()
ScaleEntity cube,10,10,10
EntityColor cube,0,127,0
EntityType cube,type_ground
PositionEntity cube,0,-5,0

' Create sphere 'character'
sphere=CreateSphere( 32 )
EntityColor sphere,127,0,0
EntityRadius sphere,1
EntityType sphere,type_character
PositionEntity sphere,0,7,0

' Enable Collisions between type_character And type_ground
Collisions type_character,type_ground,2,2

' Create cylinder 'scenery'
cylinder=CreateCylinder( 32 )
ScaleEntity cylinder,2,2,2
EntityColor cylinder,0,0,255
EntityRadius cylinder,2
EntityBox cylinder,-2,-2,-2,4,4,4
EntityType cylinder,type_scenery
PositionEntity cylinder,-4,7,-4

' Create cone 'scenery'
cone=CreateCone( 32 )
ScaleEntity cone,2,2,2
EntityColor cone,0,0,255
EntityRadius cone,2
EntityBox cone,-2,-2,-2,4,4,4
EntityType cone,type_scenery
PositionEntity cone,4,7,-4

' Create prism 'scenery'
prism=CreateCylinder( 3 )
ScaleEntity prism,2,2,2
EntityColor prism,0,0,255
EntityRadius prism,2
EntityBox prism,-2,-2,-2,4,4,4
EntityType prism,type_scenery
PositionEntity prism,-4,7,4
RotateEntity prism,0,180,0

' Create pyramid 'scenery'
pyramid=CreateCone( 4 )
ScaleEntity pyramid,2,2,2
EntityColor pyramid,0,0,255
EntityRadius pyramid,2
EntityBox pyramid,-2,-2,-2,4,4,4
EntityType pyramid,type_scenery
RotateEntity pyramid,0,45,0
PositionEntity pyramid,4,7,4

' Set collision meth And response values
Meth=2
response=2

meth_info$="ellipsoid-to-polygon"
response_info$="slide1"

While Not KeyDown( KEY_ESCAPE )

x#=0
y#=0
z#=0

If KeyDown( KEY_LEFT )=True Then x#=-0.1
If KeyDown( KEY_RIGHT )=True Then x#=0.1
If KeyDown( KEY_DOWN )=True Then z#=-0.1
If KeyDown( KEY_UP )=True Then z#=0.1

MoveEntity sphere,x#,y#,z#
MoveEntity sphere,0,-0.02,0 ' gravity

' Change collision meth
If KeyHit( KEY_M )=True
meth=meth+1
If meth=4 Then meth=1
If meth=1 Then meth_info$="ellipsoid-to-sphere"
If meth=2 Then meth_info$="ellipsoid-to-polygon"
If meth=3 Then meth_info$="ellipsoid-to-box"
EndIf

' Change collision response
If KeyHit( KEY_R )=True
response=response+1
If response=4 Then response=1
If response=1 Then response_info$="stop"
If response=2 Then response_info$="slide1"
If response=3 Then response_info$="slide2"
EndIf

' Enable Collisions between type_character And type_scenery
Collisions type_character,type_scenery,meth,response

' Perform collision checking
UpdateWorld

RenderWorld

Text 0,0,"Use cursor keys to move sphere"
Text 0,20,"Press M to change collision meth (currently: "+meth_info$+")"
Text 0,40,"Press R to change collision Response (currently: "+response_info$+")"
Text 0,60,"Collisions type_character,type_scenery,"+meth+","+response

Flip 

Wend

End 



siread(Posted 2007) [#21]
I noticed that if you comment out:
Collisions type_character,type_ground,2,2

It will then respond to collisions with the scenery, before the ball falls through the floor.


*(Posted 2007) [#22]
Ah MingW wasnt installed correctly, seems it failed to completely install. All works ok now and really fast =)

Now all I need to create is turnentity and then I can release a build of Elite Multiplayer :)


mongia2(Posted 2007) [#23]
evvaii

it work

it disinstalled and reinstalled a bmax

and it work
thanks to all


simonh(Posted 2007) [#24]
A quick fix for your anim problem Si is to comment out line 590 in TModel.bmx:
TrimVerts(surf)



siread(Posted 2007) [#25]
Thanks. Works fine now. :)

I'm guessing that if we want to use the B3DSDK that we need to change TMesh, TCamera to Ints, right?


simonh(Posted 2007) [#26]
Yes, although using ints may cause noticeable slowdown - at least it does on my PPC Mac. I'm currently wrestling with this conundrum for my own game - I may end up having to write some sort of code processor that deletes all the TTypes for the SDK version.


smilertoo(Posted 2007) [#27]
How does the processing speed of animated skinned meshes compare to those in native b3d?


simonh(Posted 2007) [#28]
About the same, maybe a little faster.


simonh(Posted 2007) [#29]
Something I've just noticed is that Blitz3D slows down quite a lot when you're displaying lots of meshes loaded with LoadAnimMesh, compared to when loaded with LoadMesh - regardless of whether the model contains anim info or is being animated.

MiniB3D on the other hand is about the same for LoadMesh/LoadAnimMesh - and compared to Blitz3D, it's slower when LoadMesh is used, but faster when LoadAnimMesh is used.


Pete Carter(Posted 2007) [#30]
does opengl perform animations using the cpu or gpu because i think blitz3d/dx7 use the cpu to calculate animation?


simonh(Posted 2007) [#31]
MiniB3D uses the CPU.


Pete Carter(Posted 2007) [#32]
Im hoping that i can bring back my Syndicate project with minib3d, because i was getting alot of slow down with my animated meshes in blitz3d so
faster when LoadAnimMesh is used

this is good news.