miniB3D - part4

Monkey Forums/User Modules/miniB3D - part4

AdamRedwoods(Posted 2012) [#1]

minib3d+monkey
Download:
https://github.com/adamredwoods/minib3d-monkey

*****************************************
Latest update (v0.33): GO TO THIS THREAD:
http://monkeycoder.co.nz/Community/posts.php?topic=4396
*****************************************






Rone(Posted 2012) [#2]
Hi Adam,
I have a few small additions to the xna renderer:

1. The current version does not support point sampling using TTexture.tex_smooth...
We need to initialize the necessary sampler States and have to consider .tex_smooth in XNAController.SetStates

_st_cU_cV2 = XNASamplerState.Create( TextureFilter_Point, TextureAddressMode_Clamp, TextureAddressMode_Clamp)
_st_wU_cV2 = XNASamplerState.Create( TextureFilter_Point, TextureAddressMode_Wrap , TextureAddressMode_Clamp)
_st_cU_wV2 = XNASamplerState.Create( TextureFilter_Point, TextureAddressMode_Clamp, TextureAddressMode_Wrap)
_st_wU_wV2 = XNASamplerState.Create( TextureFilter_Point, TextureAddressMode_Wrap, TextureAddressMode_Wrap)	


2. The BlendStates seems not 100% correct. I have used this states, but I'm also not sure:

' minib3d blend states
Local blendAlpha := XNABlendState.NonPremultiplied
		
Local blendMultiply := XNABlendState.Create
	blendMultiply.ColorSourceBlend 	        = Blend_Zero
	blendMultiply.ColorDestinationBlend 	= Blend_SourceColor
	blendMultiply.AlphaSourceBlend 		= Blend_Zero
	blendMultiply.AlphaDestinationBlend 	= Blend_SourceAlpha
		
Local blendAddAlpha :=  XNABlendState.Additive
		
Local blendAfterTexture:=  XNABlendState.Create
	blendAfterTexture.ColorSourceBlend 	= Blend_One
	blendAfterTexture.ColorDestinationBlend = Blend_One
	blendAfterTexture.AlphaSourceBlend 	= Blend_One
	blendAfterTexture.AlphaDestinationBlend = Blend_One
		
_blendStates 	= [ XNABlendState.Opaque , blendAlpha,
	blendAlpha, blendMultiply, blendAddAlpha, blendAfterTexture]



AdamRedwoods(Posted 2012) [#3]
Ah, good tips Rone, I'll have to add those in and so some texture testing.


Outstanding issues:
- programmable bone motion
- b3d files not loading properly
- more robust 2d text (add font scaling)
- xna texture testing
- LoadAnimMesh problem
- collisions, pick (this will take time)
- documentation (this will take time)


Xaron(Posted 2012) [#4]
Thanks Adam for your continuous work! :)

Using your latest fixes I get in the GLFW Windows target:

MonkeyPro/modules/minib3d/tmodelobj.monkey<496> : Error : Identifier 'default_texflags' not found.



Xaron(Posted 2012) [#5]
Oh and using your CreateGrid creates now strange mapping:



Here's the code:

http://www.leidel.net/dl/monkey/zombietest2.zip


Sammy(Posted 2012) [#6]
Has sliding collisions been fixed? Its the one issue that has stopped me using miniB3D for quite a while now unfortunately.


Xaron(Posted 2012) [#7]
Adam, this LoadAnimMesh bug is not fixed:

http://www.leidel.net/dl/monkey/zombietest3.zip

In that example I just load the zombie, only ONE zombie and it's not displayed:

zombie[0]=LoadAnimMesh("zombie_b3d_base64.txt")



AdamRedwoods(Posted 2012) [#8]
i haven't uploaded the changes yet. bones required a bit of a change. and i found some texture bugs that needed changes in many files. once i get bones working, then i'll upload (v0.32)

Has sliding collisions been fixed? Its the one issue that has stopped me using miniB3D for quite a while now unfortunately.

not yet. i understand it's needed, and will work on it soon.


Xaron(Posted 2012) [#9]
Oh sorry Adam, didn't know that. I just wanted to try out if your fixes already work on my phone. :)


Xaron(Posted 2012) [#10]
I don't want to stress you about that but do you have a rough estimate? :-)


AdamRedwoods(Posted 2012) [#11]

I don't want to stress you about that but do you have a rough estimate? :-)

I am working on this today, tomorrow.


StoneFaceEXE(Posted 2012) [#12]
There is more problem to PositionEntity.

It was like this:

Pivot.PositionEntity obj.EntityX(),obj.EntityY(),obj.EntityZ()


It works fine on GLFW (it places a pivot on the object x,y,z coordinates and camera follows the pivot as a child) but on Android target it crashes with error:
"Attemp to access null object" refering to 64 line in the project (to the line with PositionEntity and to the line 61 of mojo/app.monkey file

Removing this line results in stable app work but without placing pivot where needed.


Xaron(Posted 2012) [#13]
Hmm... I have no problems with positioning pivots. I do this all the time actually...


StoneFaceEXE(Posted 2012) [#14]
I don't know. It is specific to android, other targets work fine with positioning pivots.


Xaron(Posted 2012) [#15]
Could you post a simple complete example code please?


StoneFaceEXE(Posted 2012) [#16]
Don't mind me, somehow these type of errors are random. Yesterday there was an error - today all good. Maybe it's my android that behaves bad maybe its karma (

UPD: I know that the deal is with my device (Explay Informer 701) even though I factory reset it recently.
It is somewhat really random. App launches fully functional every 2-5s time, untill then it returns position pivot error and I have to relaunch it

This is really weird. I don't even know what could be the source of that.

Import monkey
Import os
Import mojo
Import diddy
Import minib3d


Global Level:TMesh
Global Textre:TTexture
Global Sun:TLight
Global Camera:TCamera
Global Player:TMesh
Global Pivot:TPivot

Global Angle:Int

	'  ### ### ### ### ### ### ### ### ### ###	' '  ### ### ### ### ### ### ### ### ### ###	'

		Function Main:Int()
			New SYS_Executable
			SetUpdateRate 60
			Return 0
		End Function

Class SYS_Executable Extends App
	Method OnCreate:Int()
		SetRender()	
		SetUpdateRate 60
		
		Level	=	CreateCube()'LoadMesh("3DM_World.txt")
			Level.ScaleEntity 16,0.1,9
			Level.ScaleMesh 2,2,2
		Textre	=	LoadTexture("texture.jpg")
			Level.EntityTexture Textre

		Player	=	CreateCone()
		Pivot	=	CreatePivot()				

		Sun		=	CreateLight(2,Pivot)
			Sun.PositionEntity 0, 4, 0
			Sun.LightRange 8

		Camera	=	CreateCamera(Pivot)
			Camera.CameraClsColor(0,0,80)
			Camera.PositionEntity 0, 8, -4
			Camera.PointEntity Level
	
	Return 0
	End Method

	Method OnUpdate:Int()
		MovePlayer()
		Pivot.PositionEntity Player.EntityX(),Player.EntityY(),Player.EntityZ()
	Return 0
	End Method
	
	Method OnRender:Int()
			RenderWorld()
	Return 0
	End Method
End Class



Xaron(Posted 2012) [#17]
Hey Adam,

just to show you that I really work with your lib:
http://monkeycoder.co.nz/Community/posts.php?topic=3923

It's fun! :) Thanks for your help!


AdamRedwoods(Posted 2012) [#18]
fix one problem, find another...


Xaron(Posted 2012) [#19]
Hehe, yeah I know that. Good luck!


MikeHart(Posted 2012) [#20]
Just got the latest master (via ZIP) from GITHUB and it crashes with the animation_test.monkey script under HTML5 with Monkey V66/Chrome 23.

Error: Cannot call method 'getParameter' of Null.

EDIT: All three example scripts crash that way.


MikeHart(Posted 2012) [#21]
Ok, I see, should have downloaded the .31 branch instead. Confusing.


Xaron(Posted 2012) [#22]
I guess you will see the same error message. ;)

I never got it working with HTML5 on my side. But that's just too experimental for my taste as every different browser might behave differently.


MikeHart(Posted 2012) [#23]
Ok, next error.

I:/MonkeyPro66/modules/minib3d/opengl/opengles20.monkey<318> : Error : Unable to find overload for ToArray(Float[]).



MikeHart(Posted 2012) [#24]
I never got it working with HTML5 on my side. But that's just too experimental for my taste as every different browser might behave differently.



Sadly, HTML5 is all I can test here at work.


Xaron(Posted 2012) [#25]
I see. Yep I can't await the next version from Adam as well. LOL


Xaron(Posted 2012) [#26]
Adam, any chance you add functions like:

GrabPixmap
ReadPixel
WritePixel

?


Xaron(Posted 2012) [#27]
Hey Adam, any news on the bug front? :)


Amon(Posted 2012) [#28]
I feel bad a bit for him because he's, apologies for talking about you in the 3rd person, Adam, piling a whole load of brain power in to minib3d. You can't doubt doubt his dedication. I could try donating £50-£100 in a few weeks as a thank you but I can't help thinking that a £50-100 donation compared to the work he has done is most probably an insult.

Anyway, I won't badger Adam. He's doing a brilliant job and in no way does he owe us this.

Blitzers/Monkites rule! :)


Xaron(Posted 2012) [#29]
I agree. I won't mind to donate as well. :) But again, I think Adam's work can't be fairly paid.


AdamRedwoods(Posted 2012) [#30]
Hi, thanks for the kind gestures, no donation is necessary. :D

As for the bug fixes, I am still rolling! I'm working on this now. Webgl on chrome 22 is giving me grief.


Rone(Posted 2012) [#31]
Hi,
I've just wrapped d3d11 and would now implement the miniB3D metro driver...is the metro target already available?


Xaron(Posted 2012) [#32]
Great Adam! I am looking forward to your fixes.

Rone that sounds awesome!! There is no Metro target yet, maybe with Monkey v67?


AdamRedwoods(Posted 2012) [#33]
Ugh, we lost a few posts...


AdamRedwoods(Posted 2012) [#34]
miniB3D + monkey v0.32
----------------------

- BUG FIXES!
- programmable bones (and global works)
- added TEntity.Draw(x,y) command for pixel-perfect image. Draw works much like Mojo's DrawImage command where it must be updated per frame to work
- fixed CreateGrid(x,y, repeat_tex,parent)
Creates a grid of x-width,y-depth of 1x1 interlinked quads. use repeat_tex to use this for textures (android fix)

- adjusted lighting slightly to be similar across all targets
- bug fixes: CameraLayer, LoadMesh problems, B3D loading problems, html5 Chrome bug, XNA bugs, iOS texureloading bug
- re-arranged XNA code

See Notes.txt for more information.


TO DO:
------
- fix collisions/tpick
- use quaternions for faster bones
- MDD import (will enable vertex animation from blender-- in theory)


StoneFaceEXE(Posted 2012) [#35]
Adam, you are the man, that is so awesome!!!!!!!!!!!!!!!!!!!!!!!


Sammy(Posted 2012) [#36]
Wow, nice, thank you Adam! :-)


MikeHart(Posted 2012) [#37]
Looks like it is time to give it a good test ride!


MikeHart(Posted 2012) [#38]
Damn, still getting the error

TypeError: Cannot call method 'GetParameter' of null


on Chrome (V23). Downloaded the 0.32 branch.


Xaron(Posted 2012) [#39]
Yes, HTML5 is still WIP I guess.


MikeHart(Posted 2012) [#40]
I was hoping for it as he said that he fixed html5.


AdamRedwoods(Posted 2012) [#41]
Hi Mike.
Do you get a monkey error or is it a console error? A line number would help.
I added in more checks for html5 but i am curious if you are getting stuck on those checks or are getting past them.


MikeHart(Posted 2012) [#42]
Like I said, use the samples you ship and you will see it with every sample script. But as you have asked for the line number:

106 in minib3d/opengl/opengles20.monkey


StoneFaceEXE(Posted 2012) [#43]
TypeError: Cannot call method 'GetParameter' of null

on chrome is the same as
Monkey Runtime Error : TypeError: gl is null

on firefox.

(they refer to same lines at least)


AdamRedwoods(Posted 2012) [#44]
Also make sure that the video card is not blacklisted by webgl.
http://www.khronos.org/webgl/wiki/BlacklistsAndWhitelists

Check to see if other webgl demos work found elsewhere on the web.
http://get.webgl.org/
Will give compatibility messages as well.


impixi(Posted 2012) [#45]
Same error here. Chrome version 23.0.1271.64. Whereas that spinning cube demo at get.webgl.org works perfectly.

Tried firepaint3d in GLFW and that works. Good job. Massive undertaking this!


AdamRedwoods(Posted 2012) [#46]
Strange. Ok. I'll look into this when I get back.


impixi(Posted 2012) [#47]
In minib3d file opengles20.monkey:

#OPENGL_GLES20_ENABLED="true"


should be:

#OPENGL_GLES20_ENABLED="1"


That will get it working for HTML5 platform, if your hardware permits.


impixi(Posted 2012) [#48]
WTF. Now I get an error when building for GLFW:

"Duplicate identifier 'glFlush' found in module 'gles20' and module 'gles11'".

EDIT: When running the firepaint3d example. The other two examples function as expected.

EDIT2: Change the firepaint3d.monkey import line to: Import minib3d


MikeHart(Posted 2012) [#49]
Thanks impixi, that made the samples works. Besides collision pick, there I get that the NoSmooth method is used on the text. But that gives me something to play.


StoneFaceEXE(Posted 2012) [#50]
Indeed impixi that made minib3d work on HTML5. On firefox though no lights are created (spot lights)


Beaker(Posted 2012) [#51]
I like the minib3d logo. :)


impixi(Posted 2012) [#52]
@MikeHart:

Comment out all the references to the txt variable in pick_collision_test.monkey and it will run without errors, albeit slowly.


impixi(Posted 2012) [#53]
Here's a simple HTML5-friendly 'template'. The key point is you need to make sure all your media resources are fully loaded before you try to use them. (In this simple example, the only 'resource' is "mojo_font.png").



EDIT: To clarify, in this example mojo_font.png is used by minib3d's text class, so it must be pre-loaded before use.


EdzUp(Posted 2012) [#54]
excellent i will use that when i get back to the office and create the foundations for star rogue this game will be a big undertaking as the old one ran on a 400mhz amd k6 it should work fine in HTML too :-)

once again thanks adam for all your hard work on this

does anyone have a demonstration of editting a texture it would be greatly appreciated :-)


AdamRedwoods(Posted 2012) [#55]
Re: HTML5
Damn, still getting the error

TypeError: Cannot call method 'GetParameter' of null


on Chrome (V23). Downloaded the 0.32 branch.


So I've been tracking this down a little and I think the problem is Monkey preprocessor updates:
Preprocessor config vars can now be modified, UNTIL they are used - ie: once a config var is evaluated for use with #If, #Print, #Error #blah= etc, it cannot be modified.


** Fixed. I've updated the master v0.32 to reflect this. **

I've also added an OPTIONAL "app" module. To use just "Import minib3d.app" and extend the methods. It consolidates the PreLoad() code and FPS counter.


EdzUp(Posted 2012) [#56]
Is there a certain type of texture that minib3d can load as I have png textures for a HTML5 target which has alpha and they are in the StarRogue.data directory (my main file is StarRogue.monkey). Minib3d is chucking up 'cant find sun1.png' errors, which cause texture errors and minib3d then quits after 50 or so.

Just wondered if there is a specific file type or format that it can load?


Xaron(Posted 2012) [#57]
For me both png with and without alpha layer and jpg work. But I've never used HTML5, only GLFW, iOS and Android.


AdamRedwoods(Posted 2012) [#58]
For HTML5 you *must* preload pixmaps (sun1.png) or the LoadTexture() wont find them.
The firepaint3d example shows how this is done.


EdzUp(Posted 2012) [#59]
ah ok thanks will have a look :)

does this mean no procedural generation for textures?


EdzUp(Posted 2012) [#60]
Does minib3d have a problem with 32 bit images (with alpha) as the images in Firepaint are just RGB but my suns which are RGBA cant be preloaded as preloading them still tells me they cant be loaded.

I have
If Not TPixmap.PreLoadPixmap(["sun1.png","sun2.png","sun3.png","sun4.png", "sun5.png", "sun6.png", "sun7.png"])	
	Error "NO RESOURCES LOADED"
	Return 0
Endif


I get 'NO RESOURCES LOADED' and they are imported into the HTML5 data directory as well.


AdamRedwoods(Posted 2012) [#61]
The way PreLoadPixmap works is that it returns 1 when the pixmaps are done loading. OnUpdate keeps calling the function with the same set array. it's meant to be an asynchronous loader, so that you can display a loading bar in between the "IF ENDIF" if you so desire.

Therefore, your "Error()" will stop the program.


Also note, I added a "minib3d.app" class to minib3d (on github). It encapsulates the PreLoading and FPS stuff, but no loadbar (yet).

To use it:

[monkeycode]

Import minib3d.app


Function Main ()
New Game
End


Class Game Extends Minib3dApp


Field cam:TCamera
Field light:TLight
Field cube:TMesh, floor:TMesh, txt2:TText

Method Create ()

SetUpdateRate 30

''PreLoad(files) here
PreLoad("yourPixmaps.png")
PreLoad(["arrayOfPixmaps.jpg"])

End

Method Init:Int()

AmbientLight 15,15,15

cam = CreateCamera ()
cam.CameraClsColor (200,200,255)
cam.PositionEntity(0,2,-10)
cam.CameraRange 1,500

light = CreateLight ()
PositionEntity light, 0, 15, -10
light.LightRange(100.0)
light.LightConeAngles(90,150)
'light.LightAttenuation(0.5,0,0.4)

cube = CreateCube()
EntityColor cube, 255, 0, 0
PositionEntity cube, -4, 0, 4
ScaleEntity cube,2.5,2.5,2.5

floor = CreateGrid(20,20)
floor.ScaleEntity(10.0,0.1,10.0)
floor.EntityColor(150,150,150)

txt2 = TText.CreateText2D()

Print "init done"

End




Method Update ()

Local cr:Float = KeyDown(KEY_LEFT)-KeyDown(KEY_RIGHT)
Local cu:Float = KeyDown(KEY_DOWN)-KeyDown(KEY_UP)
Local camin:Float = KeyDown(KEY_W)-KeyDown(KEY_S)
Local camup:Float = KeyDown(KEY_D)-KeyDown(KEY_A)
Local camin2:Float = KeyDown(KEY_T)-KeyDown(KEY_G)
Local camup2:Float = KeyDown(KEY_H)-KeyDown(KEY_F)

If TouchDown ()

' Convert touch y-position to a range of -"half-height" to +"half-height"...

Local offset:Float = (DeviceHeight () - TouchY ()) - (DeviceHeight () * 0.5)

' ... and we scale that range down...

MoveEntity cam, 0, 0, offset * 0.001

Endif

cam.TurnEntity cu*2,cr*2,0
cam.MoveEntity camup*0.5,0,camin*0.5

TurnEntity cube, 0.5, 1.0, 2.0

txt2.SetText(fps+" fps ~nhow are you",0,0)
txt2.Draw(0,0)


If KeyDown(KEY_ESCAPE)
Error "Exit"
End

UpdateWorld()

End

End

[/monkeycode]
Note the "Update" instead of "OnUpdate" usage, etc. Also no Render().


EdzUp(Posted 2012) [#62]
ah ok will have a look at that, I was testing to see if it had loaded as the other lines look like they did the same.

Now I get
MonkeyPro66/modules/minib3d/app.monkey<41> : Error : Identifier 'PreLoadPixmap' not found.


Should it be Preload like the rest of em?

Is there a way to see if the textures are actually loaded yet, as PreLoad returns 0 when called as they havent finished as its just been called but I dont know if you can keep calling it to see if they are loaded yet or if there is another function that does that and tells me if they are done loading?


AdamRedwoods(Posted 2012) [#63]
oops, line 41 in app.monkey should read:
		If Not TPixmap.PreLoadPixmap(preload_list.ToArray()) Then Return


You can keep calling PreLoadPixmap(). It caches the array.

With the "app" PreLoad() adds to a stack, so you can add it multiple times within the app's Create() method, but it won't tell you when a certain texture has been loaded.


Shagwana(Posted 2012) [#64]
Without doing all the searching, what is the current state of this module with the latest 67a build?

Does it need any tweaking to work?


Rone(Posted 2012) [#65]
does not work out of the box...
did not test it, but it looks, that only the 'opengl.databuffer' import needs to be replaceed by 'brl.databuffer' in monkeybuffer.monkey...


EdzUp(Posted 2012) [#66]
@Adam:That fixed it works fine now :D

Is there a way to create textures on the fly as Star Rogue requires procedural textures?


AdamRedwoods(Posted 2012) [#67]
Without doing all the searching, what is the current state of this module with the latest 67a build?

I tested it, it works, and only requires a few tweaks to the monkeybuffer file as Rone described. Let's stick with monkey V66 for now until V67 starts to settle.

Is there a way to create textures on the fly as Star Rogue requires procedural textures?

not currently. i could add in a pixel read/write through the TPixmap class. There's already a read method.


EdzUp(Posted 2012) [#68]
yeah as texture editing is a must for procedural generation :)

I take it there is a way to create textures on the fly too :)


AdamRedwoods(Posted 2012) [#69]
You can create textures a number of ways. SInce you need it "on the fly" then I don't recommend using TPixmap.Read/Write pixel. you will need to go straight to the databuffer for speed.

[monkeycode]
Local pix:TPixmap = TPixmap.CreatePixmap(64,64) ''must be powers-of-two

''edit pixmap
Local x:Int = 20, y:Int=20
Local color:Int = $ff0000ff '' ABGR
For Local x:Int=0 To 63
TPixmapGL(pix).pixels.PokeInt( (x+y*pix.width)*4, color) ''this is the fastest way currently
Next

''when done
Local tex:TTexture = TTexture.LoadTexture(pix, 1) ''flags 9=1+8=color+mipmapping

cube.EntityTexture(tex)
[/monkeycode]

* note this wont work for every target, i dont think it'll work for html5 yet

EDIT: html5 needs a work around since it can't load textures using the databuffer, so i'll have to think about that one...


EdzUp(Posted 2012) [#70]
Ah thanks for that will have to have a look, and yeah would be brilliant for HTML5 but from the general gist of everything I have done so far with it it only allows 'pre-loaded' textures which this wouldnt be good for :/


Rex Rhino(Posted 2012) [#71]
Wow, I have been away for a few months and I am just blown away at the progress of this thing! The newest version compiled and ran on my Xbox360 on the first try! Great work guys! I must echo the sentiment that someone else posted - If there was a place I could donate money to help make development easier, I would gladly pay!

Right now I am working on moving my 2D GUI code over to 3D. In my 2D Gui, I have button objects, and the button objects use touch or mouse on iphone/computer, and on the Xbox moving up or down cycles through and highlight a button with trigger/button selecting the highlighted button. It allows me to create menus/controls that work on all platforms.

The xbox version is not a problem because it doesn't need screen coordinates, but I am wondering how to implement it with 3D objects instead of 2D sprites on iphone/computer? I am assuming that I would create the GUI buttons as TSprite or TText objects, and then use CameraPick with the coordinates of the touch/mouse to know if the button is being highlighted?

Can anyone see a problem with this approach?


AdamRedwoods(Posted 2012) [#72]
well, if you're just using miniB3D's Draw() for GUI then the TouchX(),TouchY() will work just fine.

if you're trying to grab 3D objects in the 3D world, then you'll need the camera pick functions.


Rex Rhino(Posted 2012) [#73]
I am loading a sprite with loadsprite, and then I am drawing it with the Draw command.

It seems that when a sprite is loaded that isn't a 1:1 texture, it will be scaled to 1:1. Is this a bug, or is it supposed to work that way? It is a little bit weird to be loading a 1920x1080 bitmap, and having it appear as a square.

I am also exporting a 24bit png in photoshop - When the texture is loaded and displayed as a sprite, the green and the blue are switched (green looks blue, blue looks green). Is that a bug, or just a problem with how photoshop exports pngs?


AdamRedwoods(Posted 2012) [#74]
It seems that when a sprite is loaded that isn't a 1:1 texture, it will be scaled to 1:1. Is this a bug, or is it supposed to work that way? It is a little bit weird to be loading a 1920x1080 bitmap, and having it appear as a square.

well, all images must be powers-of-two so they are resized if not. i'll have to think about this one, i can auto-resize for sprites, but i would need to resize the actual mesh ( to one-day support compressed textures.... or do i not need to worry about this-- need to research).
you can manually resize for now by entity.ScaleSprite(power_of_two_width/original_width, power_of_two_height/original_height) that wont work

I am also exporting a 24bit png in photoshop - When the texture is loaded and displayed as a sprite, the green and the blue are switched (green looks blue, blue looks green).

bug. is this on XNA/windows?
EDIT:
after looking at the XNA load image code, it seems it is not expanding loaded images to ARGB.
EDIT2:
It seems Bitmap is not allowed in WP7, so not sure how I can do this properly. For now, you'll have to save your images as 32-bit.


Rone(Posted 2012) [#75]
It's System.Windows.Media.Imaging.BitmapImage instead of Bitmap in wp7...but it needs additional references and there is still no 'official' way to add these..

Another option is to use a cutom contentprocessor, but needs also additional references...if this monkey issue is solved, we can also add 16Bit(PixelFormat.Bgra4444) for mobile devices...

http://konaju.com/?p=33


AdamRedwoods(Posted 2012) [#76]
i've found a problem with XNA Draw(), need to investigate...

UPDATE:
ok, i think i've fixed those issues, but i want to finish some things before uploading v0.33.


Rone(Posted 2012) [#77]
Hi,

win8 target comes along nicely and I have already started the TRender implementation...
but I wonder how to deal with 'Object::mark()' and 'gc_mark_q()' correctly...since there is no documentation.

Currently each class implements 'Object::mark()', calls 'base::mark()' and 'gc_mark_q()' for each declared array... Is this pattern ok, or did I miss something??


AdamRedwoods(Posted 2012) [#78]
great!

I wonder how to deal with 'Object::mark()' and 'gc_mark_q()' correctly...since there is no documentation

First, I'll say I don't know if this is really needed for miniB3D. If it is, we may want to contact Mark to see if he can find a more elegant solution. I hesitate because any backend calls present future compatibility issues.


Second, here a link on how the GC works:
http://monkeycoder.co.nz/Community/posts.php?topic=4105


Rone(Posted 2012) [#79]
hmm, I do not know how to avoid this...
I have created an complete D3D11 wrapper...to do as little as possible in C++...

A typical d3d11 class looks as follows:


In monkey I use it like this, for example:
local vert_desc:= new D3D11_BUFFER_DESC
	vert_desc.Usage = D3D11_USAGE_DYNAMIC
	vert_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER
	vert_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE
	vert_desc.MiscFlags = 0
	vert_desc.ByteWidth = surf.verts_cnt * VERTEX_SIZE
	
local buffer: = _device.CreateBuffer(vert_desc, null)

while internally '.CreateBuffer' simply returns 'new BBD3D11Buffer(...)'


If you are allocating your own memory in your class, then you need to use gc_mark or gc_mark_q. I *think* the difference between the two is that gc_mark is managed memory collection, gc_mark_q is unmanaged, do it in your own class.


Do I have to use 'gc_mark_q' with 'ID3D11Buffer *' in some way?


StoneFaceEXE(Posted 2012) [#80]
Sorry to interupt hi tech discussion with my silly question but ... ^_^
How do I load textures into sprite?
I got jpg image and when I try to LoadTexture i get error "Image Not Found: image.jpg"
I tried to PreLoad("image.jpg") while Create() (not OnCreate()) but that didn't change anything. AnimationDemo textures work, so I thought it must be my image, but it is really simple, 256x256 resolution JPG and PNG formats (Tried both).

I get that error on html5 (thanks to impixi told how to make it work. Just reminding to put #OPENGL_GLES20_ENABLED="1") on GLFW textures load just fine.


StoneFaceEXE(Posted 2012) [#81]
\sorry doublepost\


AdamRedwoods(Posted 2012) [#82]
@Rone
Ok, i see... yes, structs, so you need to wrap it.
I would say try to limit the amount of extern classes to manage in case Mark changes his GC code.

No, you don't need to mark pointers, ID3D11Buffer* , that's automatic.



@StoneFaceEXE
Double-check everything. Are loading your texture in Init()? Is you file under the "data" folder? Also make sure your files are not progressive JPG.
I just tried out from scratch, everything seems ok on my end.


@All:
I'm happy to note that the MDD loader works now, so OBJ+MDD = vertex animation (morphs). MDD can be exported from Blender & Lightwave, and all others with PointOven (commercial).


Rone(Posted 2012) [#83]
ok..looked at mojo. no need to use 'mark()' or 'gc_mark' at all..


Xaron(Posted 2012) [#84]
Any news on 2d stuff? Is it possible to use 2d commands like drawline at least for some of the targets like GLFW, Android and iOS?


StoneFaceEXE(Posted 2012) [#85]
I don't think so.
New TEntity.Draw() function is a really great job but full 2d support shall not be expected that soon I think. With that minib3d functionallity I think it would be wise to clean up all 3d features first.

I still experience the problem with placing pivot OnUpdate() on Android platform :( Tried everything. I hope this error will disappear by itself in next version


AdamRedwoods(Posted 2012) [#86]

Is it possible to use 2d commands like drawline at least for some of the targets like GLFW, Android and iOS?

for now you can try that RestoreMojo2D in the OnRender(), but it's different for each target.
Now, with V67 coming soon, that will all change and either I'll be able to combine mojo and minib3d or I won't be able to at all. We have to wait and see.


I still experience the problem with placing pivot OnUpdate() on Android platform :( Tried everything. I hope this error will disappear by itself in next version

hi, can you describe your problem or give me the debug error line number?


Xaron(Posted 2012) [#87]
Thanks Adam, will check that. I'd need that for HUD stuff, especially lines. A simple DrawLine would be enough, but I guess this can be done via 3d as well...

I have a b3d mesh with bones which leads to a crash during LoadAnimMesh():

http://www.leidel.net/dl/temp/mesh.zip


Xaron(Posted 2012) [#88]
Another one: How is that TEntity.Draw(x,y) supposed to work with images? I guess I have to load it as sprite? But that doesn't work.


AdamRedwoods(Posted 2012) [#89]
I guess I have to load it as sprite? But that doesn't work.

yes as a sprite.
Field myimage:TSprite

Init()
  myimage = LoadSprite("sprite.jpg")
  myimage.HideEntity()
End

OnRender() ' or OnUpdate()
  myimage.Draw(x,y)
End

if it doesn't work, what is the error or symptom?
also, I guess I could allow drawing TPixmaps.

Also, i'm looking at your model problem.


StoneFaceEXE(Posted 2012) [#90]
hi, can you describe your problem or give me the debug error line number?


Sure:
*I have some code.
*If I compile it it works as intended on glfw target.
*If I compile it it crashes on android target when programm comes to certain line of code
*That line of code contains ONLY PositionEntity() function with some variables.
*That line is called OnUpdate()
*Android doesn't want to move my pivot no matter where (I tried both just numbers like 15,15,15 and commands like EntityX() of other entity)
*It seems it doesn't want to PositionEntity() at all - I tried to move mesh instead of pivot = result is same.
*Android Monkey Runtime Error refers to the line of code with PositionEntity() command.
*It also reffers to line app.monkey<61> as well.
*Everything else works just fine


dragon(Posted 2012) [#91]
binary load for b3d files


is this blender-file?
and how can i create base64-file?

can i load animated and textured mesh?


StoneFaceEXE(Posted 2012) [#92]
is this blender-file?
and how can i create base64-file?

can i load animated and textured mesh?


b3d is a blitz3d model file.
With proper addon Blender can export meshes to B3D format
After you have b3d file you must ENCODE it into Base64 TXT model (Yes thats right)
There are online encoders/decoders but I found that some of them don't encode models right. I can give you a link to one that I use


AdamRedwoods(Posted 2012) [#93]
@StoneFaceEXE

does this crash/work?

if not, then what is your monkey version and android version?


dragon(Posted 2012) [#94]
@StoneFaceEXE

have you a link to a exporter for blender and this Base64 encoder?


or what is the best free software to create b3d?


Amon(Posted 2012) [#95]
Greetings, dragon!

You can encode your B3D's to base64 using this online tool: http://www.opinionatedgeek.com/dotnet/tools/base64encode/

CharacterFX Can Export to b3d. Lithunwrap allows you to UVMap. If you want a serious tool for exporting to many other formats including B3D then I highly Recommend you purchase Ultimate Unwrap 3D Pro. You will not regret it.

If free is what you want then blender has a b3d exporter. Just google Blender b3d exporter and you should find your way.


Xaron(Posted 2012) [#96]
Hey Adam, do collisions with sliding work already?

Regarding the 2d draw, that works. Was a fault on my side. I just forgot HideEntity and saw nothing but a huge sprite. LOL

For Base64 encoding I use: http://www.motobit.com/util/base64-decoder-encoder.asp


AdamRedwoods(Posted 2012) [#97]
Hey Adam, do collisions with sliding work already?
Working on that for the past three days, almost there. If I can just fix one last problem, i should have a very exciting update...


Xaron(Posted 2012) [#98]
Sounds great, Adam! :)


dragon(Posted 2012) [#99]
why must we use base64?
can monkey not read files binary?


AdamRedwoods(Posted 2012) [#100]
Html5 does not have a binary file standard so base64 is best for total cross platform. But I guess I can open it up to other platforms.


CopperCircle(Posted 2012) [#101]
Binary would be great for the mobile platforms.


StoneFaceEXE(Posted 2012) [#102]
does this crash/work?


Yeah your code works fine. All I see is just black screen with some fps on the top left of the screen. (That is what it is supposed to do)

There was a lot of difference betwen my code and your code structure.
You use Create() while I use OnCreate() and other things. I had no INIT() method.

So now I changed everything to your code structure (All OnCall() methods are changed to Call() and added Init() and imported minib3d.app) and it works quite good, but my sprites are transparent if I load them directly (LoadSprite("sprite.png")) but if I assign a texture to newly created sprite then it is not transparent.

I have a feeling that I missed a lot of documentation that came with minib3d ))))


Xaron(Posted 2012) [#103]
Check the bb3d docu. For LoadSprite, there are some flags you can use:

http://blitzbasic.com/b3ddocs/command.php?name=LoadSprite


julesd(Posted 2012) [#104]
Is it possible to manipulate vertices with miniB3D?


AdamRedwoods(Posted 2012) [#105]
Is it possible to manipulate vertices with miniB3D?

yes. use this as a manual, although I've added a lot of new things.
get mesh's surface:
http://www.blitzbasic.com/b3ddocs/command.php?name=GetSurface&ref=3d_cat
modify surf's vertex:
http://www.blitzbasic.com/b3ddocs/command.php?name=VertexCoords&ref=3d_cat


Rone(Posted 2012) [#106]
The first step in the direction of win8 is done... gonna start shaders now! :)
Took almost 10 hours before I realized that I have to transpose the matrices...wtf




Xaron(Posted 2012) [#107]
LOL. Cool!


Xaron(Posted 2012) [#108]
Right, any idea how to make something like a dynamic HUD?

I had the idea to use a 1 pixel sprite and stretch that to create lines...


AdamRedwoods(Posted 2012) [#109]
Right, any idea how to make something like a dynamic HUD?

well, one way for now would be to use squares
local square:TMesh = CreateGrid(1,1)
square.HideEntity
square.ScaleEntity(sx,sy,1)
square.Draw(x,y)


If you need to move the Mesh "handle", use square.PositionMesh(x,y,0)


...I'm still working on collisions for v0.33. ugh.... scaled barycentric coordinates anyone? i'm so close it hurts.


Xaron(Posted 2012) [#110]
Ah great, will try that, thanks!

...I'm still working on collisions for v0.33. ugh.... scaled barycentric coordinates anyone? i'm so close it hurts.


Ugh... you really need that barycentric stuff for collisions?


Why0Why(Posted 2012) [#111]
I'm glad there are people much smarter than me to figure all of this stuff out :P


maverick69(Posted 2012) [#112]
Sorry if the following question is dumb, but I was curious why it isn't possible to mix 2D Mojo Graphics Command with MiniB3D?

I've tried it and got lots of flickering.

It would be a nice feature because it would be very easy to add 2D Huds on top of a 3D Scene or add some 3D-Effects to a Mojo 2D Game.


AdamRedwoods(Posted 2012) [#113]

why it isn't possible to mix 2D Mojo Graphics Command with MiniB3D?

because the backend keeps changing and I need to 'hack' mojo to get it to work with miniB3D. sometimes i can get it to work.

also keep in mind: it will NOT work with opengl2.0, so that is why i hesitate to guarantee it on all targets.

I will probably have to make line, circle, box, but i don't like re-creating what Mojo already does.


Rone(Posted 2012) [#114]
what about porting Draw3D2?

http://www.blitzbasic.com/Community/posts.php?topic=75362
http://www.blitzforum.de/forum/viewtopic.php?t=21659

I played around with it recently, and its just awesome...


Xaron(Posted 2012) [#115]
Looks great!

Edit: Pretty impressive. Will see if I can port this! Together with the ParticleCandy this might be very handy. There is a great 2d physics engine included as well!


Rone(Posted 2012) [#116]
Yes, but at least some commands require render to texture...

The only target where mojo does not work is opengl2.0...it might be significantly less work to fix this, instead of porting >8000 lines...

Have you any license agreement with x-pressive, because of ParticleCandy? May you release the source?

What's with SpriteCandy... compared with Draw2D?


Xaron(Posted 2012) [#117]
I've asked Mike (X-Pressive) regarding ParticleCandy. He gave me green light to open source the port as long as I refer to him as author. I've made another thread about that somewhere here...

I've looked into SpriteCandy as well but there are some texture based commands (ReadPixel, WritePixel) which are not supported yet otherwise I'd have ported it as well.


AdamRedwoods(Posted 2012) [#118]
(ReadPixel, WritePixel) which are not supported yet

i have this ready in v0.33, along with MDD, PC2 file loader (vertex animation)


Xaron(Posted 2012) [#119]
Wohoo, great! I'm looking forward to this!


julesd(Posted 2012) [#120]
@AdamRedwoods

I've notice you were working on wxmonkey as well.
I would love to see minib3d as a finished product.
If you could, please spend most of your time with minib3d.
Many thanks to this module as well.

Then maybe minib3d gui. So they are compatible with each other.


Rone(Posted 2012) [#121]
Adam,

Do you have a decent formatted version of your shader? ...I don't want to pick apart everyhing or reinvent the wheel(..lighting must look similar).

btw:
win8 makes progress... needs just a little renderstate tweaking and cleanup!


Edit:
It seems that the shader interface is pretty much WIP and there is currently no way for target independent parameter access...we should at least consider this.
Also tshader does not take into account, that some features are not available on all targets..for example, runtime shader compilation is not supported in win8/xna...


Xaron(Posted 2012) [#122]
Could it be that collisions (sphere to polygon) do not work when the mesh is pretty big and low poly so that the vertices have quite some space in between?


AdamRedwoods(Posted 2012) [#123]
Could it be that collisions (sphere to polygon) do not work when the mesh is pretty big and low poly so that the vertices have quite some space in between?

Not exactly, but this video I think explains the problems with minib3d collisions...
http://www.youtube.com/watch?v=5MmPV42SRdw


Rone(Posted 2012) [#124]
hi,

here's the d3d11 driver:
http://www.load.to/tuzjLjddrv/minib3d.zip

Please see notes in d3d11.monkey!

-------------

Since I'm running win8 using VMware, everything is very slow here..so, I'm looking forward to feedback

@Xaron
I have also tried your particleCandy port, and saw that 'ClearSurface' is called per frame. This should be a bottleneck, since 'vert_data' is recreated, which leads to vbo recreation, at least on xna/d3d11...


AdamRedwoods(Posted 2012) [#125]
awesome! nicely done. i dont have win8 here yet.

Re: TShader / ShaderValues

i'm open to ideas, i left the TShader class pretty open to extend easily and keep shaders target specific. i have no ideas about common shaders, since setting one up for Flash/AGAL will really be ugly.


Xaron(Posted 2012) [#126]
Not exactly, but this video I think explains the problems with minib3d collisions...
http://www.youtube.com/watch?v=5MmPV42SRdw



LOL. So is it something you might be able to fix?


Rone(Posted 2012) [#127]
Found a bug in xna_render..
- fog needs to be re enabled, after a mesh with Brush FX 8


AdamRedwoods(Posted 2013) [#128]
i've fixed collisions. give me about a day or two and i'll post a new thread with the updates.


Sammy(Posted 2013) [#129]
:D !!!


Xaron(Posted 2013) [#130]
Yay, that sounds great! Thanks Adam!


bruZard(Posted 2013) [#131]
B3D Exporter for Blender => http://www.colorflow.de/monkey/minib3d/B3DExport.zip

exports binary and base64.


Rone(Posted 2013) [#132]
Windows 8 update
https://github.com/sascha-schmidt217/minib3d-monkey/archive/minib3d.0.32_d3d11.zip

Includes some bug fixes and performance optimizations. Fixed also some xna issues with v67b.

Todo:
- test multi texturing
- add texture transform to shader
- implement framebuffer/rendertarget


MikeHart(Posted 2013) [#133]
Damn, you have to install this ilivid crap. Don't like that.


Rone(Posted 2013) [#134]
you have to click on the middle download button.. the small one.

someone knows a less irritating file hoster?


Amon(Posted 2013) [#135]
I've uploaded it to my webserver and webspace.

http://www.amon.co/storage/minib3d.zip

http://www.imaginationengine.co/storage/minib3d.zip


This will prevent the issues others have with the free hosting. :)


Rone(Posted 2013) [#136]
thx amon..
I have created a branch at github and updated the link.


julesd(Posted 2013) [#137]
where is the link Rone?


Rone(Posted 2013) [#138]
https://github.com/sascha-schmidt217/minib3d-monkey/archive/minib3d.0.32_d3d11.zip


Amon(Posted 2013) [#139]
Updated Links:

http://www.amon.co/storage/minib3d-monkey-minib3d.0.32_d3d11.zip

http://www.imaginationengine.co/storage/minib3d-monkey-minib3d.0.32_d3d11.zip


Rone(Posted 2013) [#140]
hmm, alpha blending in html5 looks strange .. I guess a problem with tpixmaphtml5...


bruZard(Posted 2013) [#141]
is it me or is EntityPosition for lights buggy?


AdamRedwoods(Posted 2013) [#142]
hmm, alpha blending in html5 looks strange .. I guess a problem with tpixmaphtml5.
yes the halo effect. i need to check if pre-multiplying alpha needs to be done (or fixed with shader).

EntityPosition for lights buggy

Specific target or just lights? Lights uses the same base as other entities.


p.s. found a couple bugs w/collisions, working today to fix this.


bruZard(Posted 2013) [#143]
HTML5 ... no matter where i position the light, it does not change the lighting of the scene


Rone(Posted 2013) [#144]
Have .obj files ever worked in xna?

"Line[0]" returns the ascii code as string in xna, had to replace with "Line[0..1]"...maybe an xna bug in v67?(tmodelobj.monkey/line 107)

Also string to float conversion fails here(win8-- "atof( ToCString<char>()" in String.ToFloat returns always 0.0) on .cpp targets(win8/glfw). I had to replace "," with "."(tmodelobj.monkey).

@bruZard
I just testet lighting with an movable spot light...works fine here in html5/chrome

@Xaron
It seems that particle candy has some problems with alphablending/z ordering

any Idea?

Edit:
Just noticed, while looking at the screens, that mip mapping acts pretty aggressively...maybe mip map bias needs to be increased a little?


EdzUp(Posted 2013) [#145]
Can we load standard b3ds yet or is it still base64 ones, havent tested it much as have had loads of real life things to sort. If it can load standard b3ds will this be added at some point?


AdamRedwoods(Posted 2013) [#146]
Can we load standard b3ds yet or is it still base64 ones, havent tested it much as have had loads of real life things to sort. If it can load standard b3ds will this be added at some point?

base64 for v66.
here's why: v66 had problems with databuffers on some targets (not sure about miniupdate 66), so i can't do it until v67 is stable. yes, i do have that function ready to go.


EdzUp(Posted 2013) [#147]
Ah ok :)


Rone(Posted 2013) [#148]
Hi folks,

I implemented mojo using miniB3D recently. Posted it in the german community and just wanted to link it here too:

http://www.monkeycoder.de/community/index.php?threads/minib3d-mojo-kommandos.2907/

In general, it seems that xna/d3d11 have SamplerStates issues(also seen in TText). Would appreciate any help!


OvineByDesign(Posted 2013) [#149]
Does slide collision work yet ?

/StuC


Xaron(Posted 2013) [#150]
No.


AdamRedwoods(Posted 2013) [#151]
I've been working on collisions. It pretty much works now, after I've rewritten it countless times. It was difficult, took much longer than I expected. There are very few good math explanations online, they all leave something out. I also created a hybrid distance squared poly order versus the common normalized time, which helped.

Hopefully something by this weekend, I'm just trying to get smoother responses as the sphere crosses from poly to poly edge.


julesd(Posted 2013) [#152]
Just want to confirm this, "implemented mojo using miniB3D"

Does this mean I can use these commands to do the drawing in the miniB3D
canvas?

Does this also mean it is not possible to use original mojo commands in the miniB3D canvas?


julesd(Posted 2013) [#153]
is there a writepixel,or readpixel commands implemented,if not will there be something similar implemented soon?

fillcolor command would be nice to.


AdamRedwoods(Posted 2013) [#154]

Does this also mean it is not possible to use original mojo commands in the miniB3D canvas?

some of the targets allow it, some don't (uses RestoreMojo2D() in OnRender()). we have to wait until a stable monkey V67 before i can figure out if it can be done.

i haven't tried Rone's implementation, but the base miniB3D uses a mysprite.Draw( x,y ) command to take care of most HUD needs. this uses the standard ScaleSprite, RotateSprite as well. YOu just have to do a EntityHide() after setup.

is there a writepixel,or readpixel commands implemented,if not will there be something similar implemented soon?

minib3d v0.33 (coming soon) allows dynamic pixel reading and writing to all targets.


julesd(Posted 2013) [#155]
awesome.


Xaron(Posted 2013) [#156]
Very nice, Adam! :)


Rone(Posted 2013) [#157]

Just want to confirm this, "implemented mojo using miniB3D"

Does this mean I can use these commands to do the drawing in the miniB3D
canvas?


Yes...basically


Tested on glfw, html5, xna and d3d11(all v67b). Also added fontmachine yesterday. Seems fast and stable!
Unfortunately, I had to touch TTexture(PRESERVE SIZE flag added)... did not want to annoy with automatic scaling

I probably missed one or two functions:

https://github.com/sascha-schmidt217/minib3d-monkey/tree/minib3d.0.32_d3d11/util
https://github.com/sascha-schmidt217/minib3d-monkey/blob/minib3d.0.32_d3d11/ttexture.monkey
firepaint sample:
https://github.com/sascha-schmidt217/minib3d-monkey/blob/minib3d.0.32_d3d11/examples/firepaint2d.monkey

Please let me know, if errors occur!


In general, it seems that xna/d3d11 have SamplerStates issues(also seen in TText). Would appreciate any help!



@Adam
you mean some time ago, that you found a problem with XNA Draw() and you fixed it...was this related to pixel perfect drawing??
I only ask because d3d11 has the same problem and I don't want to spend time if you have already found the error, which is probably the same in d3d11...


Amon(Posted 2013) [#158]
Any news on the release, Adam?


Xaron(Posted 2013) [#159]
Don't push him to hard! He's doing an amazing job and that collision stuff will work, I'm really sure. So far I can already work with the existing stuff.


StoneFaceEXE(Posted 2013) [#160]
Just to point out a thing that maybe was already pointed out.
Minib3d on android does not support foldering of data files.

I had two similar projects, with only one difference - 2nd project's files were placed in folders inside .data folder. GLFW handled them okay, but on android it refused to load anything that is not in the root directory of .data folder.

Dunno if that was already known, just in case )

UPD: Nevermind again stupid post of mine. It's just android target that ignores folders that start with _


Xaron(Posted 2013) [#161]
Hehe, well yes, I just wondered because it works here...


AdamRedwoods(Posted 2013) [#162]
Still a little bumpy around the edges... but i'll start to finish a few bugs and get this up anyways.

http://www.twopisoftware.com/monkeycoder/collision/collision_sphere.html
wasd = camera
z = reset ball
x = flatten surface toggle
tgfh = rotate surface
ry = roll surface


Xaron(Posted 2013) [#163]
Nice! Keep up your great work, I really appreciate it!


julesd(Posted 2013) [#164]
@Rone

re-posted in part 5