miniB3D: monkey 3d engine - part5

Monkey Forums/User Modules/miniB3D: monkey 3d engine - part5

AdamRedwoods(Posted 2013) [#1]

minib3d+monkey
Latest update v0.33.5

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

Win8 target:
https://github.com/sascha-schmidt217/minib3d-monkey

Thread continued from:
http://monkeycoder.co.nz/Community/posts.php?topic=3897




notes:
- current branch: v0.33.5 requires Monkey V66 (Monkey V68 is easy to integrate)
- tested on glfw, android, macos, ios, xna, webgl

Works:
- normals
- textures, mipmaps
- vbos and non-vbo fallback
- sprites
- batch sprites
- context handling for mobile devices
- pick
- collisions
- binary load for b3d files (base64)
- animation, bone & vertex
- Load OBJ
- animated textures
- XNA, Win8 target (courtesy of Rone)
- HTML5 (webGL)
- Shaders
- normal mapping (opengl2.0)
- MDD/PC2 animation loaders


To Do:
- Flash, Ouya target
- bones to quat/matrix internals
- glow shaders, shadows, fast vertex shaders
- physics
- terrain





AdamRedwoods(Posted 2013) [#2]
****************************************
minib3d v0.33

- MDD and PC2 import for vertex animation (almost all 3d programs export this)
[monkeycode]
TModelMDD.LoadMDD:Void(mesh:TMesh, url:String, flipz:Int=0, variance:Float = EPSI)
TModelMDD.LoadPC2:Void(mesh:TMesh, url:String, flipz:Int=0, variance:Float = EPSI)
[/monkeycode]
-- applied to an existing mesh (like OBJ)
-- use variance to allow slight offset between loaded OBJ and MDD
-- frame 0 MUST be reference pose

- ReadPixel/WritePixel for TPixmap (TTextures). all targets, even html5.
Example:
[monkeycode]
pixtemp = TPixmap.CreatePixmap(64,64) ''must be powers-of-two

''edit pixmap
Local x:Int = 20, y:Int=20
For Local x:Int=0 To 63
pixtemp.SetPixel( x,y, 255,0,255)
Next

'Print ToHex(pixtemp.GetPixel( 1,y))


''when done
textemp = TTexture.LoadTexture(pixtemp , 1) ''flags 9=1+8=color+mipmapping

cube.EntityTexture(textemp)
[/monkeycode]

- Camera Pick and Collisions now work
Added CollisionSetup() for easier setup.
[monkeycode]
CollisionSetup(type_no, pick_mode) 'for auto sphere radius (uses cull radius)
CollisionSetup(type_no, pick_mode, radius) 'for sphere/polygon
CollisionSetup(type_no, pick_mode, x, y, z, w, d, h) 'for box
[/monkeycode]

- mymesh.Wireframe(bool) --to turn on/off individual wireframes
- auto-correct ratio of sprites / Draw()
- entity.PositionToVertex(mesh, surf, vertex_id) --to position an entity to a specific vertex on a mesh (animated too!)
- Added CreateLine() for thin lines (no thickness yet)
- CreateMiniB3DMonkey() -- creates a minib3d monkey head mesh

- other bug fixes (inc. b3d loading, xna fog, parenting problem)


AdamRedwoods(Posted 2013) [#3]
sorry for the delays everyone. i can't tell you how mind blowing collisions are.

i'm also working on a Flash target, since i find it more available (currently) than webgl.


StoneFaceEXE(Posted 2013) [#4]
So I deleted my last .build directory, refreshed minib3d and tried to compile my project that worked perfectly previously on android. Now I get error I had before:

Monkey Runtime Error:
index=134174, limit=134174

which refers to certain model I'll try to upload

Here:
https://docs.google.com/file/d/0B6cGK2VCmtfqZWJyZWdNSjRVaWM/edit


AdamRedwoods(Posted 2013) [#5]
OBJ or B3D?
i wonder if it is hitting a string size limit, or early eof.

you can send models for me to test to awpiette (which is at) yahoo dot com.
you can also use #MINIB3D_DEBUG_MODEL=1 to see the log of the parser (ddms on android).


AdamRedwoods(Posted 2013) [#6]
@StoneFaceEXE

in "monkeybuffer.monkey" change line 491 (ReadTag) to:
		If pos+3>size Then Return 0


i will update github now. sorry about that.


Amon(Posted 2013) [#7]
This is so cool, thanks man!


Shinkiro1(Posted 2013) [#8]
Thanks Adam! You are doing an awesome job, keep it up.


StoneFaceEXE(Posted 2013) [#9]
If pos+3>size Then Return 0

That did really hit the spot, but now I have another error with another mesh:

Monkey Runtime Error : Array index out of bounds.

That reffers to line:
Model = LoadAnimMesh("_3dm_human.txt")

The model is here:
https://docs.google.com/file/d/0B6cGK2VCmtfqaURLbWYxd1dYaDQ/edit

PS: Yes the first and this one are OBJ files


Rone(Posted 2013) [#10]
Great, nice update!
Merged with my latest d3d11...hopefully not forget anything.

How is merging envisaged in github? ...had to do it by hand, that sucks.

What happened to TEntity? ...breaks my project :(

Edit:
It is intended that UpdateMatTrans' now overwrites mat if load_identity=False And parent<>Null, in contrast to 0.32, where it is not done? ...probably not, because local rotation is overwritten by MoveEntity this way


AdamRedwoods(Posted 2013) [#11]

Edit:
It is intended that UpdateMatTrans' now overwrites mat if load_identity=False And parent<>Null, in contrast to 0.32, where it is not done? ...probably not, because local rotation is overwritten by MoveEntity this way


you are correct. Thanks for pointing that out, i am not sure why i did that. Unfortunately i am out of pocket so some of these bugs may wait.
EDIT: i made the change and updated GitHub.

i need to revisit those matrix routines, i know there is another problem with scaling. I need to keep in mind when the parent matrix is loaded and when children matrix are updated vs. local updates.

How is merging envisaged in github? ...had to do it by hand, that sucks

good question. I'll try to do some research.


Rone(Posted 2013) [#12]

i made the change and updated GitHub.


Thank you very much.


Unfortunately i am out of pocket so some of these bugs may wait.



I have a lot of time and would like to contribute more, respectively support your efforts...

Do not know if it is desired, if so, the development process needs to be more open. Maybe work in the same repository/different branch(?), using the issue-tracker + milestones...
I think we can quickly move forward, if we coordinate our efforts



i'm also working on a Flash target, since i find it more available (currently) than webgl.



Cool!
In connection with flash, GLSL2AGAL might useful

https://github.com/adobe/glsl2agal
http://www.cmodule.org/glsl2agal/

I did also some experiments with cg toolkit. Seems very useful for shader conversion cg<->hlsl<->glsl...

I think we should at least consider optional support for using one single shading language for all targets. Everyone is going this route, also Unity. The conversion tool they use is even open source

http://blogs.unity3d.com/2010/10/20/shader-compilation-for-multiple-platforms/

The 'Surface Shader' article is pretty interesting, too

http://blogs.unity3d.com/2010/07/17/unity-3-technology-surface-shaders/

I will start a evaluation, when xna shader support integration in 0.33 is finished.


Xaron(Posted 2013) [#13]
Awesome work, guys, incredible! Thank you so much!


EdzUp(Posted 2013) [#14]
Excellent stuff, will have a serious play with creating something with this what with monkey targets etc it will cut development times quite considerably :-)


bruZard(Posted 2013) [#15]
Excellent!


AdamRedwoods(Posted 2013) [#16]
I think we should at least consider optional support for using one single shading language for all targets.

also look to Ogre3D how they did it there, that is an engine i look at a lot.
(At some point I want to be able to read Ogre.scene files, so we can use Ogitor as a scene editor.)
http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Deferred+Shading&structure=Development

The first decision I think would be one of these directions:
1. Is shader language is external (custom .exe like Nvidia Cg)?
2. Is shader compiled by engine at runtime (Win8 problem)?
3. Is shader a hybrid monkey+runtime using heavy reflection? (extending a certain class will build the string for the glsl/hlsl/agal compiler)


Rone(Posted 2013) [#17]

also look to Ogre3D how they did it there, that is an engine i look at a lot.


Yes, I know their material/compositor framework.
I wanted at this point not to touch minib3d to very. only make it work with .cgfx(for example), on all targets.

So, keep it stupid simple:
local shader:IShader = TShader.LoadShader("myshader.cgfx")
local brush0:= CreateBrush()
brush0.AttachShader(shader)

local p:= shader.Parameters.Get("color")
p.SetValue(255,0,255)

So first implement IShader in OpenGl, as I have done in d3d11/xna. This basically requires only minor changes...
I think it's the next logical step, because every effect/material framework needs to be build on a common shader interface when targeting lot of platforms.


1. Is shader language is external (custom .exe like Nvidia Cg)?


Yes, it is probably easiest. I thought about a 'monkey c++ tool', that compiles all changed shaders automatically for each target.


2. Is shader compiled by engine at runtime (Win8 problem)?


Yes, runtime shader compilation can only done during development,when all platforms are considered.
So, if the engine is to be responsible for shader compilation, something like this is necessary:
#If MINIB3D_RELEASE="false" 
    ' compile changed shaders
    ' reflect shaders
    ' save to data/shader
#End 

before redistribution, the project needs to be compiled with #MINIB3D_RELEASE?"true". That's the way I did it in d3d11... if anyone knows a more elegant method, let me know it.

Drawback: No write permission in 'monkey / data' on all targets -> thus requires manual copy, before release


3. Is shader a hybrid monkey+runtime using heavy reflection? (extending a certain class will build the string for the glsl/hlsl/agal compiler)


How do you imagine that exactly?. Can you describe bit more detail? I've been thinking about something similar, but I have come to no solution ..


julesd(Posted 2013) [#18]
@Rone

Can you create your own minB3D-mojo topic in modules, and have the correct link to github.

in the note.txt file at top can we get something like
tested with: v67b
or something letting us know what version of monkey you are working with.

I also think minB3D should be called minM3D.

B=blitz language
M=monkey language

was posted in part 4, meant to post it here.


julesd(Posted 2013) [#19]
@Rone

i use your version of minB3D from github

when I run the animation demo.

config.monkey all true but resize and fullscreen

turn on wire frame mode.

when I do this the text is no longer readable in the top left corner.

I think it has something todo with wireframe mode.

I would like to be able to read the text in wireframe mode.


AdamRedwoods(Posted 2013) [#20]
i've uploaded some bug fixes for v0.33.2


MikeHart(Posted 2013) [#21]
@julesd

B3D is actually the 3D fileformat that Blitz supports and so tries MiniB3D. :-)))


Rone(Posted 2013) [#22]
@julesd
isn't the text in the animation sample created using TText?
Anyway, I disabled Wireframe in B2DBeginRender. So use "B2DSetFont( Null ) & B2DDrawText(...)"...or fontmachine

I just wonder whether wireframe has ever worked. Looks like it was disabled again directly in trender.rendercamera...?? doesn't work here...
from trender.RenderCamera:
If mesh.wireframe Or wireframe Then wireframe = True
TRender.render.Render(mesh,cam)
wireframe = False

Adam, can you explain that to me...I don't get it.
I need to do this, in order to get it work:
Local wireFrameIsEnabled:= wireframe
If mesh.wireframe Then wireframe = True		
TRender.render.Render(mesh,cam)		
wireframe = wireFrameIsEnabled


i've uploaded some bug fixes for v0.33.2


I still do not know how to merge clever...hope that I have removed the errors from the last merge correctly. Releasetag chaos seems inevitable...

Edit:
just wanted to link it here also..
I created a great mip mapping enhancement for minib3d, using sharpening filter when creating the mipmaps.
the blurry is not a display error, it's just how mipmapping looks without filtering^^



Sledge(Posted 2013) [#23]
Defo have a couple of hiccups with Monkey v66b and MiniB3D v0.33 & v0.33.2 here. Will list 'em in case they're significant (running under Win7, 64-bit):

firepaint3d.monkey
...MonkeyPro66b/modules/minib3d/tsprite.monkey<400> : Error : Unable to find overload for EntityParent(TEntity,Int).

pick_collision_test.monkey
...MonkeyPro66b/modules/minib3d/examples/pick_collision_test.monkey<80> : Error : Identifier 'EntityCollision' not found.

All the examples from MiniB3D v0.32 worked, conversely.

Very nice to see this coming together on so many platforms, though. Awesome stuff.


AdamRedwoods(Posted 2013) [#24]
another quick bug fix is up.
this one fixes a hard crash in tcamera, so be sure to UPDATE!

wireframe, fixed.

...MonkeyPro66b/modules/minib3d/tsprite.monkey<400> : Error : Unable to find overload for EntityParent(TEntity,Int).

fixed
...MonkeyPro66b/modules/minib3d/examples/pick_collision_test.monkey<80> : Error : Identifier 'EntityCollision' not found.

fixed. this was because i was using "EntityCollision()" but that command made no sense to me, and is now "CollisionSetup()".

Sorry for all the bugs everyone. Hopefully it will come together.


apamment(Posted 2013) [#25]
Edit: It seems to be a specific thing to virtualbox

I'm having a Memory Access Violation



The line is

[monkeycode]
glMaterialfv(GL_FRONT_AND_BACK,GL_SHININESS,mat_shininess)
[/monkeycode]


AdamRedwoods(Posted 2013) [#26]
I'm having a Memory Access Violation

that does seem like a strange error, and perhaps by virtualbox. i have not tried any of the engine through VMs.
Have you tried commenting out the offending glMaterial line? I wonder if there would be other errors.


apamment(Posted 2013) [#27]
Have you tried commenting out the offending glMaterial line? I wonder if there would be other errors.


It seems to work fine with that line commented, thankyou :D


apamment(Posted 2013) [#28]
I think I've found a bug with collisions, I'm not really sure how to explain it except if I turn left into a wall at the start of my game I warp to the z coordinate set to 0

Heres the coordinates printed out each frame

X54.0 Y0.0 Z32.0 <-- At the Start
X54.0 Y0.0 Z32.0
X54.0 Y0.0 Z32.0
X53.903873443603516 Y0.0 Z31.972436904907227 <- starting to turn into the wall
X53.615493774414062 Y0.0 Z-0.054128021001815796 <- warp to 0 Z coordinate
X53.519367218017578 Y0.0 Z-0.081691756844520569
X53.327114105224609 Y0.0 Z-0.13681922852993011

I'm using Collision Boxes for the walls (they are lots of cubes next to each other) and a Collision Sphere for the camera. The collision method for the collision command is COLLISION_METHOD_BOX changing the sphere to a collision box so everything is boxes seems to do the same thing.


chimaera(Posted 2013) [#29]
I was wondering if there are any tutorials on how to get a fully textured 3D-model loaded and displayed with miniB3D.

I have been reading the forum threads about miniB3D after I have downloaded the module and have tried to play around with it for a bit, but can't seem to get anywhere as I don't find any documentation.

I have been trying to load a OBJ-file with LoadMesh (collision test example as a base) but have not succeeded. Is the only way to make it work to convert OBJ->B3D->Base 64 Encode? When I do this I still get a "glerror: 1282".

Now my head is spinning...and I don't feel much smarter. :P

Can someone point me in a good direction? Thanks!


AdamRedwoods(Posted 2013) [#30]
I was wondering if there are any tutorials on how to get a fully textured 3D-model loaded and displayed with miniB3D.

so far there's two formats: b3d and obj
So you can export to OBJ from any 3d modeling application. I have tested Lightwave 9, 3DCoat, and Blender3D. It will export 2 files, obj and mtl, just change each to ".txt" at the end and place in the "monkeygame.data" folder. Then LoadMesh("mymodel.obj.txt"). No need for conversion.

there's a B3D exporter for blender if you need animation, i'll dig up the link i've seen to have lost it... but you can also export PC2 or MDD for vertex animation, which is faster than boned animation but requires more memory (200-300 frames per object is good). the only requirement for MDD/PC2 is that your frame 0 is the EXACT model/pose that is exported as an OBJ. then any animation can take place afterwards.

Other commands can be found on the Blitz3D website, since that is the base set that miniB3D+monkey is based on (not all commands were interchanged):
http://www.blitzbasic.com/b3ddocs/command_list_3d_cat.php

One thing i need to do is get the wiki going on github.


AdamRedwoods(Posted 2013) [#31]
I think I've found a bug with collisions

ok, i'll look into it.


chimaera(Posted 2013) [#32]
Hi Adam,

Thanks for your fast response! I'll try your instructions when I get home tonight, but it sounds very promising.

As I have been reading through the threads I have seen that you are working very hard on MiniB3D and like many others I really want to say "Thanks, and keep up the good work".

If you get the wiki online maybe we in the community can help to populate it.

Well, thanks for help! I will probably back for more. ;)


StoneFaceEXE(Posted 2013) [#33]
Here is the b3d exporter for blender that I use
https://docs.google.com/file/d/0B6cGK2VCmtfqS0hTU2JTenIybU0/edit?usp=sharing
path is "*blenderpath*/2.62/scripts" and don't forget to turn it on in addons in user preference

Worked allright with blender 2.62 but animations don't work well with me. Its either because of my b64 encoder or because of blender doesn't have "reset joint value" function that milkshape3d had which was a solution to all bugs that appeared with animated meshes.


bruZard(Posted 2013) [#34]
here's another b3d exporter for blender 2.6x: http://www.colorflow.de/monkey/minib3d/B3DExport.zip


Sledge(Posted 2013) [#35]
Which b64 encoder are people favouring? Google kinda spoils you for choice and it's difficult to say, when you hit a problem with a b3d, whether it's an issue with MiniB3D that should be raised or a wonky encoder.


AdamRedwoods(Posted 2013) [#36]
http://www.opinionatedgeek.com/dotnet/tools/base64encode/

most problems with b3d i've encountered is sudden End Of File.
I'm planning on creating a new JSON format, similar to three.js.


AdamRedwoods(Posted 2013) [#37]
v0.33.3 is a bug fix for tcamera. the frustum cache was removed (wasnt working).
v0.33.4 is a bug fix for collisions. should be a large speed increase and hopefully stable enough for use. i still find occasional collision errors, if anyone finds problems and has a test case, please let me know.


impixi(Posted 2013) [#38]
Thanks. This is a great project. I've been using miniB3d with Monkey V0.66b with minimal problems, targeting the HTML5 platform. See here, bottom of thread: http://www.monkeycoder.co.nz/Community/posts.php?topic=374

No luck with Monkey V67e though... "module opengl.databuffer not found."


AdamRedwoods(Posted 2013) [#39]
No luck with Monkey V67e though... "module opengl.databuffer not found."

to use V67e, just change this to read:
in monkeybuffer.monkey
#If TARGET="html5" Or TARGET="glfw" Or TARGET="mingw" Or TARGET="ios" Or TARGET="android"

	Import brl.databuffer
	'Import opengl.databuffer

	Function CreateDataBuffer:DataBuffer(i:Int)
		Return New DataBuffer(i)
	End
	Function GetBufferLength:Int(buf:DataBuffer)
		Return buf.Length()
	End



impixi(Posted 2013) [#40]
Then I get an "unable to determine overload to use..." error in tsurface.monkey.


Rone(Posted 2013) [#41]
You need to remove the default parameters(begin/bend) from CopyDataBuffer...I guess at least


AdamRedwoods(Posted 2013) [#42]
yup, in monkeybuffers.monkey a couple lines need to be changed, i changed them on the GitHub master just now. sorry about that I kept forgetting to update it.


AdamRedwoods(Posted 2013) [#43]
updated.

v0.33.5 -- improved collisions tenfold. turns out i was creating rays for every object and testing each one O(n*n) times. also added pre-emptive AABB testing. it's fast, even on android.


Amon(Posted 2013) [#44]
You have imho done the Monkey Community proud with your version of MiniB3D. Relentless updates and feature packed, you have produced the definitive 3D Module for Monkey!

You are the dude! :)


tOmzone(Posted 2013) [#45]
I wonder if somebody is gonna build a scenegraph-engine on top of this great module :D


Sammy(Posted 2013) [#46]
You have imho done the Monkey Community proud with your version of MiniB3D. Relentless updates and feature packed, you have produced the definitive 3D Module for Monkey!

You are the dude! :)


Could not have said it better myself, I totally agree!


EdzUp(Posted 2013) [#47]
Will the b3d loader be implemented soon, I know the current one is base64 at the moment just wondering on the eta of the new version?

I ask as I have LOADS of b3d models and currently the only way I have found to convert them is blender with the plugin.


StoneFaceEXE(Posted 2013) [#48]
If that may interest anyone: this b3d exported b64 model file causes my app to crash on android target with "Unexpected error occured that stoped the application. Try again" or something like that ) GLFW and some other target work good, even though they can't animate this model if I try to. Thing is - the error tha occurs is not even monkey runtime error )

https://docs.google.com/file/d/0B6cGK2VCmtfqeVZheG1YamFJRTg/edit?usp=sharing

UPD: Figured that armatures caused this, but then I cannot animate using blender tools (


EdzUp(Posted 2013) [#49]
Hmm thats not good :/


StoneFaceEXE(Posted 2013) [#50]
I still think it is because we use different b64 encoder AND python scripts for exporting to B3D from blender.


EdzUp(Posted 2013) [#51]
this is another reason for the standard b3d loader


AdamRedwoods(Posted 2013) [#52]
this b3d exported b64 model file causes my app to crash on android target with

updated the tmodelb3d.monkey to handle this error. please let me know if you still get errors.

Are you using the blender exporter? how are these b3d made?


this is another reason for the standard b3d loader

it's in there, just waiting for monkey v67.


EdzUp(Posted 2013) [#53]

it's in there, just waiting for monkey v67.


Ah thats good to know, hopefully it will be usable soon :D


StoneFaceEXE(Posted 2013) [#54]
updated the tmodelb3d.monkey to handle this error. please let me know if you still get errors.

Are you using the blender exporter? how are these b3d made?



I rebuild the app and here is the result:
LoadAnimMesh doesn't load mesh at all. I just don't see anything, but it solved the problem with app crashing for unknown non-monkey runtime reason ) I'd say this is a progres, because I left joints in the model and they seem not to interfere with game anymore.

I use different b3d exporters from blender (two different python scripts) I'll share them asap.

Model is a very simple mesh, the only hard part of it could be the wires that were made with bezier curves, but I converted them to mesh as soon as I finished working with them.

Here are two scripts I use, output model after I b64 converted it and the source *.b3d model
https://docs.google.com/file/d/0B6cGK2VCmtfqMVU1NVNnWS1LY0E/edit?usp=sharing
https://docs.google.com/file/d/0B6cGK2VCmtfqQm5Bem1zZVNrZ2M/edit?usp=sharing
https://docs.google.com/file/d/0B6cGK2VCmtfqLWRkdDQ5ZXBEam8/edit?usp=sharing
https://docs.google.com/file/d/0B6cGK2VCmtfqZF9zQXljZ1I3TVE/edit?usp=sharing


StoneFaceEXE(Posted 2013) [#55]
yeah it's still possible just to LoadMesh without animations and it will work ) (tried html5, android and glfw)


AdamRedwoods(Posted 2013) [#56]
ok, well i'd have to double-check the pythons script.

but what do people prefer?
1. blender export script that works for B3D (+ optional base64 export)
2. on-line javascript collada(dae)->b3d converter + optional base64 export (can be hosted at github)

let me know.


StoneFaceEXE(Posted 2013) [#57]
second variant makes it TRIPPLE conversion for blender user.
Like that:
1. blender -> b3d -> b64
2. blender -> dae -> b3d -> b64
I don't know whether it's good to have such many conversions, but if it is easy and more solid way to do it then do it, otherwise we could just define the one and THE only python script and place it for everyone to see and dl.


EdzUp(Posted 2013) [#58]
Tbh i would have just b3d import in minib3d as adam has already said hes waiting for v67 to go final then its a go, not only would this solve most of the issues but would make it work in line with blitzmax's minib3d. Making everything work across the whole blitz family from blitz3d to blitzmax and finally monkey will aid transition between the languages :)


EdzUp(Posted 2013) [#59]
Now that monkey v68 is out what is the ETA on importing b3d files into monkey minib3d?


AdamRedwoods(Posted 2013) [#60]
am trying to get the Flash target working, but maybe i need to update V68 first. will look into this.


EdzUp(Posted 2013) [#61]
Ah ok is there a variable i can change to load b3d's


IceVAN(Posted 2013) [#62]
Hi all.

I'm new monkey.
Long ago I use minib3d in BlitzMax and now I'm starting to use in monkey. You did a good job with minib3d for monkey!

I don't know if it is wise, but the lights don't work properly. The objects don't light as in BlitzMax.

If a mesh is rotated faces that are illuminated also rotate. It's as if the light turn once the mesh.

Greetings!


AdamRedwoods(Posted 2013) [#63]
I don't know if it is wise, but the lights don't work properly. The objects don't light as in BlitzMax.

is this in html5?


IceVAN(Posted 2013) [#64]
Hi, Adam

I tried with html5 and glfw (windows), and the last version of monkey.
In both is the same.


AdamRedwoods(Posted 2013) [#65]
after loading the mesh, try mesh.UpdateNormals(). does that help?


IceVAN(Posted 2013) [#66]
Yes, UpdateNormals() fixes the problem. But, I still have a problem ;)

UpdateNormals() smooths the mesh and I don't want a smoothed mesh.

And EntityFX(obj, 4) not solve this problem.



BlitzMax



Monkey



AdamRedwoods(Posted 2013) [#67]
Ok, thanks for explaining the problem. I'll look this over and get some answers tonight.


charlie(Posted 2013) [#68]
That looks like the difference between face and vertex normals with the update normals images.

Cheers
Charlie


AdamRedwoods(Posted 2013) [#69]
Re: Normals and flat shading

miniB3D does not allow multiple normals for a single vertex, so normals are generally averaged out, creating a smooth appearance. additionally the OpenGL fixed function pipeline allows for non-interpolated normals, so it will create flat surfaces, but for people who need to write their own shaders, it would require optimally a separate shader for non-interpolated surfaces. (more shaders=more overhead=more testing=more time!)

So what to do?

There's a way to separate triangles from each other, so no interpolation is done and no vertex weighting is averaged. Generally, this is called unwelding (see various 3D programs like Blender for this command in action).

Here is a small routine for this, and I will add this to the miniB3D TMesh API:
unweldtriangles.monkey

usage:
UnWeldTriangles(mesh) or
UnWeldTriangles(mesh, optional surface, optional bool dont create new normals)

don't UpdateNormals after using this routine, or it will smooth the normals again.


Sammy(Posted 2013) [#70]
This could be very handy for lots of situations.


Xaron(Posted 2013) [#71]
Great! I know I was a bit silent the last weeks (had some hard private stuff to sort out) but I still like what you're doing here, Adam! Incredible!

So what has to be done to have it working with v68? I guess you will update it anyway soon now as it's not experimental anymore?


AdamRedwoods(Posted 2013) [#72]
this post above explains how to get this working with v67/v68 until i can get an update in:
http://monkeycoder.co.nz/Community/post.php?topic=4396&post=49395

I guess you will update it anyway soon now as it's not experimental anymore?

yes, i would like to update a few minor things. hopefully soon.


Xaron(Posted 2013) [#73]
Thanks Adam!


Sammy(Posted 2013) [#74]
Is there a way to implement shadows?


IceVAN(Posted 2013) [#75]
Great!! Thanks Adam!


Rone(Posted 2013) [#76]
hi adam, I just read that you have installed win8 ... have you tried minib3d on win8 yet?


AdamRedwoods(Posted 2013) [#77]
Is there a way to implement shadows?

yes, custom shaders. i've done this, but i'm researching an glsl/hlsl solution first before i make any gbuffer shaders.

have you tried minib3d on win8 yet?

not yet, soon! (glfw works fine).


Sammy(Posted 2013) [#78]
yes, custom shaders. i've done this, but i'm researching an glsl/hlsl solution first before i make any gbuffer shaders.
Ok thanks for the reply Adam. I think I'll hang back till you've completed your research and then follow your lead.


Nobuyuki(Posted 2013) [#79]
for shaders:

I recommend doing this a similar way we handle audio. Let the end-coder deal with it! "Try" to compile shaders in whatever the target is, let the code fail if it's not supported on a target. XNA's/Win8's the only targets that uses HLSL shaders, and pretty much all the others use GLSL. Why not let the user convert their shaders to HLSL themselves? There are tools for this. Other solutions would add another potential point of failure in the chain if they involve some sort of "automagic" translation from a higher level language to the target's shader language


charlie(Posted 2013) [#80]
I think i'd rather handle my own shaders outside of commonly wanted stuff (like shadows). There's plenty of tools to test them/debug them out outside of minib3d, plus it'd likely make the codebase easier to manage for you.

Cheers
Charlie


EdzUp(Posted 2013) [#81]
Adam has something changed when I compile with v68c I get
[code
MonkeyPro68c/modules/minib3d/monkeybuffer.monkey<11> : Error : Module 'opengl.databuffergl' not found.
[/code]

There is no opengl.monkey, I got minib3d from github this morning?


impixi(Posted 2013) [#82]
@EdzUp:
See post #39: http://www.monkeycoder.co.nz/Community/post.php?topic=4396&post=49395


EdzUp(Posted 2013) [#83]
Ah missed that one thanks :)


Landon(Posted 2013) [#84]
I got minib3d to work on windows 8,

31 fps the zombie animations seem a tad choppy but moving the cube around and the zombies turning seems really smooth.


AdamRedwoods(Posted 2013) [#85]
the zombie animations seem a tad choppy

in the example, the zombies are converted to vertex animation. Vertex animation is where the data is stored and bones are not used. so when played at a slower rate they are choppy by nature since it is playing back frame by frame, rather than by calculating bones.

this allows for many, many zombies.


Landon(Posted 2013) [#86]
ah cool, i had a feeling that was it, reminded me of how the animations on players in dungeons and dragons online when far away.

at anyrate i am pleasantly impressed. I may just head down the road to win8 app development with this.

any recommendations on a UI that's decent and wouldn't be hard to port into minib3d?


EdzUp(Posted 2013) [#87]
Yeah is there mojo compatibility in minib3d so we can put text etc on screen


Landon(Posted 2013) [#88]
ah yea i see that, i don't have to wrestle to put 2d stuff up. suhweet


MikeHart(Posted 2013) [#89]
Does MiniB3D support bone animation in a B3D file?


AdamRedwoods(Posted 2013) [#90]
Yeah is there mojo compatibility in minib3d

not really. Rone has integrated some things in his separate mod you can try, but for the most part, Mojo will not work with miniB3D on all targets. I can get mojo working for cpp targets, but not opengl2.0 because mojo is only opengles1.1. I think someone has made a HTML5 WebGl mojo target, which would be opengles2.0 compatible.

I have included a myentity.Draw(x,y) command used with TText and TSprites, for all targets.

...and now after thinking for a bit, there may be a way to extend mojo's GraphicDevice class to use miniB3D directly (written in monkey, not native, all targets). this would be an interesting experiment.

Does MiniB3D support bone animation in a B3D file?

yes. the problem is there are few programs that create an animated B3D file. I am working on a collada->b3d converter.


Rone(Posted 2013) [#91]

I got minib3d to work on windows 8


Do you use my implementation...just wondering, cause I have not updated since v67b...


any recommendations on a UI that's decent and wouldn't be hard to port into minib3d?


I ported junglegui a while ago, using my mojo like commands... but it was very slow due to performance issues with my 2d commands / minib3d...
what interface do you use for 2d drawing?


Yeah is there mojo compatibility in minib3d so we can put text etc on screen


You can also you fontmachine
https://github.com/sascha-schmidt217/minib3d-monkey/tree/minib3d.0.33.2/util
-------------------

Adam, what's your plan with win8 and xna highdef? Are you going to integrate these with the next update, or does it make more sense if I merge with your latest updates..?

btw:
I have a rudimentary d3d9 blitzmax driver, has anyone usage for this?


Landon(Posted 2013) [#92]

yes. the problem is there are few programs that create an animated B3D file. I am working on a collada->b3d converter.



I usually just export my animated meshes out as ms3d, then from milkshape export to b3d. got tired of wrestling with exporters.


what interface do you use for 2d drawing?



i haven't made anything for monkey yet. I bought it and sat on it for a while.


AdamRedwoods(Posted 2013) [#93]
Adam, what's your plan with win8 and xna highdef?

i'll merge these into mine, but not sure when i'll get to this. i should probably up this priority since i've changed some key things to get Flash3D working. probably next week? so much going on...

I have a rudimentary d3d9 blitzmax target

interesting, is that a d3d9 mojo target or minib3d target?
also, does it need the special dx9c or will it work on standard dx9? i never understod dx9c since it was not compatible with dx10.


Rone(Posted 2013) [#94]

i'll merge these into mine...


Cool!


interesting, is that a d3d9 mojo target or minib3d target?


it's a d3d9 minib3d driver for the monkey blitzmax target.
based on blitzMax's pub.directx.d3d9...don't know if it is standard dx9 or not, but I guess it needs nothing special.


Landon(Posted 2013) [#95]

Do you use my implementation...just wondering, cause I have not updated since v67b...



i used this one

https://github.com/sascha-schmidt217/minib3d-monkey


Rone(Posted 2013) [#96]
yes, that's mine...minib3d core is 0.33.2 there, but the drivers are ok.


Landon(Posted 2013) [#97]

yes, that's mine...minib3d core is 0.33.2 there, but the drivers are ok.



Seemed to work fine. i was running monkey v69


IceVAN(Posted 2013) [#98]
Hi

I think the texture flags don't work.

LoadTexture("texture.png", 65) <- Sphere mapping + color

gives the same result that

LoadTexture("texture.png", 9) <- color + mipmaping

I tested with different targets and all is the same.

Regards!


AdamRedwoods(Posted 2013) [#99]
sphere mapping and cubemapping are not implemented, as there is none for OpenGLES1.1. i can implement cubemapping in OpenGLES2.0, but after i get a deferred shader going.

cubemapping in ES1.1 would require creating UV coordinates for a cubemap, and then setting the rotation of the texture to world matrix (ie doesnt move).


Landon(Posted 2013) [#100]
How far off do you think you are from adding the LoadAnimSeq and AddAnimSeq? I could really use those. i absolutely hate having to put all my animations into one file. :D


AdamRedwoods(Posted 2013) [#101]
How far off do you think you are from adding the LoadAnimSeq and AddAnimSeq?

There's code in there but I haven't used these yet, so I'm assuming they don't work.

With my Collada loader starting to come together, I will test these functions when I get minib3d loading collada animation. May take a couple weeks though, i've been busy.


Landon(Posted 2013) [#102]
I'd advocate a Cal3D loader. i may just write one myself.


AdamRedwoods(Posted 2013) [#103]
animation blending? i haven't thought of it, but this could be a future project. might be easy just by blending animation keys before vertex deform.

BlendAnimSeq( ExtractAnimSeq(m1,0,10),ExtractAnimSeq(m2,0,10), 0.5)


Landon(Posted 2013) [#104]
i had a question about animated models,i'm at work right now so i can't test.

so currently i can attach an object to a bone and it will follow the animations right?


time-killer-games(Posted 2013) [#105]
How do I load plain old wavefront obj models? I tried loading a b3d file I exported from blender and tried converting it to base64 from that opinionated geek website. Both gave me an "open device failed" error, it's strange because the zombie animation example and the other examples work just fine. An I doing something wrong?

My model has a ton of polygons, could that be why? I don't think there is anything wrong with my code, perhaps the model isn't loading because it isn't a properly formatted b3d? I'll upload it in a few if that helps.


Landon(Posted 2013) [#106]
i noticed after i convert a b3d to base64 i get an error until i convert the encoded file to use Unix EOL format in notepad++


time-killer-games(Posted 2013) [#107]
^thanks I'll try that. :)


AdamRedwoods(Posted 2013) [#108]
How do I load plain old wavefront obj models?

so, by default, monkey will not copy .obj files over to the build folder. you have to add the file filter thing... can't remember the exacts right now.

*OR* you can simply add .txt at the end of the obj filename, ie "mymodel.obj.txt" and monkey will copy it during the build and minib3d will LoadMesh("mymodel.obj.txt"). No base64 needed.


Landon(Posted 2013) [#109]
Question, any particular reason why the mesh of this model is on the skeleton backwards? see screenshot below.




Landon(Posted 2013) [#110]
Another weird issue is some models which do have animations i've verified in pace maker seem to load the mesh fine but do not animate at all.

the ones that do animate are old b3d files i think exported with the 3dsmax exporter. the one that doesn;t animate i exported from milkshape.

i can supply you with the models if you want for testing.


AdamRedwoods(Posted 2013) [#111]
i can supply you with the models if you want for testing.

yes, send to awpiette ... yahoo ..etc

why the mesh of this model is on the skeleton backwards?

don't know, but you can easily fix: mymesh.RotateMesh(0,180,0)
(note: RotateMesh will rotate the base mesh, not the entity)


IceVAN(Posted 2013) [#112]
Hi Adam

I detected a few small bugs.

In the method PaintMesh ()
- You copy bursh.tex_frame and this field does not exist in TBrush
- And you forgot to copy shine_strength

I added in TBrush: Field tex_frame: Int = 0
And I added in PaintMesh: surf.brush.shine_strength = bru.shine_strength

I have also detected that AddMesh not work well at all.

This don't work, the mesh is badly copied.
local cubes:TMesh = CreateMesh()

For Local n:Int = 0 Until 50	
	Local c:TMesh = CreateCube()
        RotateMesh(c,Rnd(0,360), Rnd(0,360), Rnd(0,360))
	PositionMesh(c,Cos(Rnd(0,360)) * r, Sin(Rnd(0,360)) * r,Rnd(-5,100))
			
	Local b:TBrush = CreateBrush(Rnd(0,360), Rnd(0,360), Rnd(0,360)
	
        PaintEntity(c,b)

	c.AddMesh(cubos)

	FreeEntity(c)
	b = null
Next



This work
local cubes:TMesh = CreateMesh()

For Local n:Int = 0 Until 50
			
	Local c:TMesh = CreateCube()
        RotateMesh(c,Rnd(0,360), Rnd(0,360), Rnd(0,360))
	PositionMesh(c,Cos(Rnd(0,360)) * r, Sin(Rnd(0,360)) * r,Rnd(-5,100))
			
	Local b:TBrush = CreateBrush(Rnd(0,360), Rnd(0,360), Rnd(0,360)
	
        PaintMesh(c,b)    ' <----------------- difference

	c.AddMesh(cubos)

	FreeEntity(c)
	b = null
Next



I changed your method addmesh() by this one:

(From BlitzMax version)
	Method AddMesh(mesh2:TMesh)
		
		If Not mesh2 Then Return
		
		For Local surf1:TSurface=Eachin surf_list
			
			' if surface is empty, don't add it
			If surf1.CountVertices()=0 And surf1.CountTriangles()=0 Then Continue
				
			Local new_surf:Bool=True
			
			For Local surf2:TSurface = Eachin mesh2.surf_list
			
				Local no_verts2=surf2.CountVertices()
				
				If (TBrush.CompareBrushes(surf1.brush,surf2.brush)=True)
				
					' add vertices
				
					For Local v=0 Until surf1.CountVertices()
		
						Local vx:Float=surf1.VertexX(v)
						Local vy:Float=surf1.VertexY(v)
						Local vz:Float=surf1.VertexZ(v)
						Local vr:Float=surf1.VertexRed(v)
						Local vg:Float=surf1.VertexGreen(v)
						Local vb:Float=surf1.VertexBlue(v)
						Local va:Float=surf1.VertexAlpha(v)
						Local vnx:Float=surf1.VertexNX(v)
						Local vny:Float=surf1.VertexNY(v)
						Local vnz:Float=surf1.VertexNZ(v)
						Local vu0:Float=surf1.VertexU(v,0)
						Local vv0:Float=surf1.VertexV(v,0)
						Local vw0:Float=surf1.VertexW(v,0)
						Local vu1:Float=surf1.VertexU(v,1)
						Local vv1:Float=surf1.VertexV(v,1)
						Local vw1:float=surf1.VertexW(v,1)
						
						Local v2=surf2.AddVertex(vx,vy,vz)
						surf2.VertexColor(v2,vr,vg,vb,va)
						surf2.VertexNormal(v2,vnx,vny,vnz)
						surf2.VertexTexCoords(v2,vu0,vv0,vw0,0)
						surf2.VertexTexCoords(v2,vu1,vv1,vw1,1)

					Next
		
					' add triangles
				
					For Local t=0 Until surf1.CountTriangles()
		
						Local v0=surf1.TriangleVertex(t,0)+no_verts2
						Local v1=surf1.TriangleVertex(t,1)+no_verts2
						Local v2=surf1.TriangleVertex(t,2)+no_verts2
						
						surf2.AddTriangle(v0,v1,v2)

					Next

					' mesh shape has changed - update reset flags
					surf2.reset_vbo=-1 ' (-1 = all)
	
					new_surf=False
					Exit


				end
				
				
			Next
			
			' add new surface
			
			If new_surf=true
			
				Local surf:TSurface=mesh2.CreateSurface()
				
				' add vertices
				
				For Local v=0 Until surf1.CountVertices()
	
					Local vx:Float=surf1.VertexX(v)
					Local vy:Float=surf1.VertexY(v)
					Local vz:Float=surf1.VertexZ(v)
					Local vr:Float=surf1.VertexRed(v)
					Local vg:Float=surf1.VertexGreen(v)
					Local vb:Float=surf1.VertexBlue(v)
					Local va:Float=surf1.VertexAlpha(v)
					Local vnx:Float=surf1.VertexNX(v)
					Local vny:Float=surf1.VertexNY(v)
					Local vnz:Float=surf1.VertexNZ(v)
					Local vu0:Float=surf1.VertexU(v,0)
					Local vv0:Float=surf1.VertexV(v,0)
					Local vw0:Float=surf1.VertexW(v,0)
					Local vu1:Float=surf1.VertexU(v,1)
					Local vv1:Float=surf1.VertexV(v,1)
					Local vw1:float=surf1.VertexW(v,1)
					
					Local v2=surf.AddVertex(vx,vy,vz)
					surf.VertexColor(v2,vr,vg,vb,va)
					surf.VertexNormal(v2,vnx,vny,vnz)
					surf.VertexTexCoords(v2,vu0,vv0,vw0,0)
					surf.VertexTexCoords(v2,vu1,vv1,vw1,1)

				Next
	
				' add triangles
			
				For Local t=0 Until surf1.CountTriangles()
	
					Local v0=surf1.TriangleVertex(t,0)
					Local v1=surf1.TriangleVertex(t,1)
					Local v2=surf1.TriangleVertex(t,2)
					
					surf.AddTriangle(v0,v1,v2)

				Next
				
				' copy brush
				
				If surf1.brush<>Null
				Print("supeficie copiada")
					surf.brush=surf1.brush.Copy()
					
				End
				
				' mesh shape has changed - update reset flags
				surf.reset_vbo=-1 ' (-1 = all)
			
			End
							
		Next
		
		' mesh shape has changed - update reset flags
		mesh2.reset_bounds=True
		mesh2.col_tree.reset_col_tree=True
	End 	




AdamRedwoods(Posted 2013) [#113]
Hi, thanks for finding these bugs!

The blitmax version of AddMesh() will crash/give wrong results on certain examples. the reason for the bad addmesh was flipping of z/normal z. a change i had made a while back.

i've also updated the paintmesh/paintentity check while doing the AddMesh().

these changes will appear on the next update.


Landon(Posted 2013) [#114]
Cool deal.

Any idea why my meshes are not loading the animations?


AdamRedwoods(Posted 2013) [#115]
Re: brush.tex_frame

I've always struggled with where to define that value. I have placed it under TTexture, because texture contains a pointer to TPixmap and overhead is minor for each copy.

But you pointed out a bug: Brushes should be able to have individual frames. So I've now added that in by applying a TTexture copy(). Thus, textures will all be animated the same if applied via PaintEntity(TTexture), but will all be different if applied through a brush PaintEntity(TBrush).


Landon(Posted 2013) [#116]
Rotate Mesh seemed to have fixed most of the problems with one of the meshes but it borked the arm bones completely. Not sure exactly why the bones are so out of whack.




AdamRedwoods(Posted 2013) [#117]
Any idea why my meshes are not loading the animations?

the bone weights seem to be set to 0.0
Not sure exactly why the bones are so out of whack.

checking this


Landon(Posted 2013) [#118]
the bone weights seem to be set to 0.0


that's weird, i opened the exported meshes into fragmotion and pacemaker and both of them play the skinned animation just fine. There must be some difference in the file structure that i'm exporting that is causing the module to not read the bone weights.


Landon(Posted 2013) [#119]
.


Landon(Posted 2013) [#120]
After experimenting aroundit seems with every attempt to export a b3d model from milkshape, blender and fragmotion i noticed that it only seems to read in weights of 1 or 0. for some reason if it's a non zero weight it comes in as 0. i checked the zombie and every weight is 1, that seems to be why it works.


Landon(Posted 2013) [#121]
Ok after going into milkshape and assigning all vertexes to have only one weight on one bone at 1.0 the animations worked just fine.

I find that really odd. there must be some issue somewhere that is preventing me from saving more than one bone weight.


AdamRedwoods(Posted 2013) [#122]
something is an INT where it should be a FLOAT.
EDIT: do all the animations work correctly, even the knight?
i found a 'dwarf' b3d from pacemaker3d, and i could not load that so i'm experimenting...


Landon(Posted 2013) [#123]
well the bone placement is still off on soem of the models but outside of that issue the animations DO work when i set all the weights to 1.

But i found this when looking at the milkshape b3d exporter source



int weight1 = msVertexEx_GetBoneWeights(vert2, 0);
			int weight2 = msVertexEx_GetBoneWeights(vert2, 1);
			int weight3 = msVertexEx_GetBoneWeights(vert2, 2);
			int weight4 = 100 - (weight1 + weight2 + weight3);

.... then later on

		for (size_t j = 0; j < bone_vertices[k].size(); j++)
		{
			writeInt(bone_vertices[k][j]);
			writeFloat((float) bone_weights[k][j] / 100.0f);
		}


Seems to be writing a float but for whatever reason when it's read in as a float it's a 0

Also when i load my model into minib3d(blitzmax) the bones are aligned just fine. But when i try to use it in monkey minib3d the bones are all in the wrong places.


Landon(Posted 2013) [#124]
Ok got my model's bones to line up perfectly as well as animate

i changed the code in TModelb3d to reflect minib3d on blitzmax and skeletal structure are in their proper placements.

				Case BONE
				
					Local ix:Int=0
					
					new_tag=file.ReadTag()
				
					bo_bone = New TBone
					bo_no_bones=bo_no_bones+1
					Print "New Tag: "+PrintTag(new_tag)
					
					While NewTag(new_tag)<>True And file.Eof()<>True
				
						bo_vert_id=file.ReadInt()
						bo_vert_w=file.ReadFloat()
						Print "Vert_id: "+bo_vert_id+" Bone weight: "+bo_vert_w
						If bo_vert_id>surf.no_verts Or bo_vert_id <0 Then Exit	'' a check for corrupt files			
						
						' assign weight values, with the strongest weight in vert_weight[1], and weakest in vert_weight[4]
									
						For Local anim_surf:TSurface=Eachin mesh.anim_surf
							
							'anim_surf = mesh.anim_surf[surf.surf_id]
							
							'If bo_vert_id>=anim_surf.vmin And bo_vert_id<=anim_surf.vmax
						
								If anim_surf<>Null
								
									'Local vid=bo_vert_id-anim_surf.vmin
									Local vid:Int = vert_lookup[bo_vert_id]-1 ''offset from 1
								
									If bo_vert_w>anim_surf.vert_weight1[vid]
														
										anim_surf.vert_bone4_no[vid]=anim_surf.vert_bone3_no[vid]
										anim_surf.vert_weight4[vid]=anim_surf.vert_weight3[vid]
										
										anim_surf.vert_bone3_no[vid]=anim_surf.vert_bone2_no[vid]
										anim_surf.vert_weight3[vid]=anim_surf.vert_weight2[vid]
										
										anim_surf.vert_bone2_no[vid]=anim_surf.vert_bone1_no[vid]
										anim_surf.vert_weight2[vid]=anim_surf.vert_weight1[vid]
										
										anim_surf.vert_bone1_no[vid]=bo_no_bones
										anim_surf.vert_weight1[vid]=bo_vert_w
																
									Else If bo_vert_w>anim_surf.vert_weight2[vid]
									
										anim_surf.vert_bone4_no[vid]=anim_surf.vert_bone3_no[vid]
										anim_surf.vert_weight4[vid]=anim_surf.vert_weight3[vid]
										
										anim_surf.vert_bone3_no[vid]=anim_surf.vert_bone2_no[vid]
										anim_surf.vert_weight3[vid]=anim_surf.vert_weight2[vid]
										
										anim_surf.vert_bone2_no[vid]=bo_no_bones
										anim_surf.vert_weight2[vid]=bo_vert_w
																							
									Else If bo_vert_w>anim_surf.vert_weight3[vid]
									
										anim_surf.vert_bone4_no[vid]=anim_surf.vert_bone3_no[vid]
										anim_surf.vert_weight4[vid]=anim_surf.vert_weight3[vid]
						
										anim_surf.vert_bone3_no[vid]=bo_no_bones
										anim_surf.vert_weight3[vid]=bo_vert_w
							
									Else If bo_vert_w>anim_surf.vert_weight4[vid]
									
										anim_surf.vert_bone4_no[vid]=bo_no_bones
										anim_surf.vert_weight4[vid]=bo_vert_w
												
									Endif
													
								Endif
								
							'Endif
							
						Next
						
						new_tag=file.ReadTag()
							
					Wend
					

					bo_bone.classname="Bone"
					bo_bone.name=n_name
					bo_bone.px=n_px  '' bone rest_mat takes care of original positions
					bo_bone.py=n_py
					bo_bone.pz=n_pz
					bo_bone.sx=n_sx
					bo_bone.sy=n_sy
					bo_bone.sz=n_sz
					bo_bone.rx=n_rx
					bo_bone.ry=n_ry
					bo_bone.rz=n_rz
					bo_bone.qw=n_qw
					bo_bone.qx=n_qx
					bo_bone.qy=n_qy
					bo_bone.qz=n_qz
					
					bo_bone.n_px=n_px
					bo_bone.n_py=n_py
					bo_bone.n_pz=n_pz
					bo_bone.n_sx=n_sx
					bo_bone.n_sy=n_sy
					bo_bone.n_sz=n_sz
					bo_bone.n_rx=n_rx
					bo_bone.n_ry=n_ry
					bo_bone.n_rz=n_rz
					bo_bone.n_qw=n_qw
					bo_bone.n_qx=n_qx
					bo_bone.n_qy=n_qy
					bo_bone.n_qz=n_qz
				
					bo_bone.keys=New TAnimationKeys
					bo_bone.keys.frames=a_frames
					bo_bone.keys.flags=bo_bone.keys.flags.Resize(a_frames+1)
					bo_bone.keys.px=bo_bone.keys.px.Resize(a_frames+1)
					bo_bone.keys.py=bo_bone.keys.py.Resize(a_frames+1)
					bo_bone.keys.pz=bo_bone.keys.pz.Resize(a_frames+1)
					bo_bone.keys.sx=bo_bone.keys.sx.Resize(a_frames+1)
					bo_bone.keys.sy=bo_bone.keys.sy.Resize(a_frames+1)
					bo_bone.keys.sz=bo_bone.keys.sz.Resize(a_frames+1)
					bo_bone.keys.qw=bo_bone.keys.qw.Resize(a_frames+1)
					bo_bone.keys.qx=bo_bone.keys.qx.Resize(a_frames+1)
					bo_bone.keys.qy=bo_bone.keys.qy.Resize(a_frames+1)
					bo_bone.keys.qz=bo_bone.keys.qz.Resize(a_frames+1)
							
					' root ent?
					If root_ent=Null Then root_ent=bo_bone
					
					' if ent nested then add parent
					If node_level>0 Then bo_bone.AddParent(parent_ent)
					
					Quaternion.QuatToMatrix(bo_bone.n_qx,bo_bone.n_qy,-bo_bone.n_qz,-bo_bone.n_qw, bo_bone.mat)
					
					bo_bone.mat.grid[3][0]=bo_bone.n_px
					bo_bone.mat.grid[3][1]=bo_bone.n_py
					bo_bone.mat.grid[3][2]=bo_bone.n_pz
					
					bo_bone.rest_mat.Overwrite(bo_bone.mat) '' keep rest mat
					bo_bone.loc_mat.Overwrite(bo_bone.mat) '' keep local mat
					bo_bone.mat2.Overwrite(bo_bone.mat)
					
					'' setting the glbola mat doesn't work? weird
					'If bo_bone.parent<>Null
						'bo_bone.mat.Overwrite(bo_bone.parent.mat)
						'bo_bone.mat.Multiply(bo_bone.loc_mat)
					'Endif
					
					If bo_bone.parent<>Null And TBone(bo_bone.parent)<>Null ' And... onwards needed to prevent inv_mat being incorrect if external parent supplied
						
						temp_mat.Overwrite(TBone(bo_bone.parent).mat2)
						temp_mat.Multiply(bo_bone.mat2)
						bo_bone.mat2.Overwrite(temp_mat)
						
						
					Endif

					bo_bone.inv_mat=bo_bone.mat2.Inverse() ''move rotation origin
				
					temp_mat.Overwrite(bo_bone.mat2)
					temp_mat.Multiply(bo_bone.inv_mat) ''set initial pose with tform_mat
					bo_bone.tform_mat.Overwrite(temp_mat) 

				
					If new_tag<>KEYS
						
						''**** removing bones to entity list-- how will this effect things? *******
						'bo_bone.entity_link = TEntity.entity_list.EntityListAdd(bo_bone)
						mesh.bones=mesh.bones.Resize(bo_no_bones)
						mesh.bones[bo_no_bones-1]=bo_bone
						last_ent=bo_bone
						mesh.no_bones = bo_no_bones
						
					Endif
					
					
						
		
				Case KEYS



AdamRedwoods(Posted 2013) [#125]
ah, the quat needed flipping
Quaternion.QuatToMatrix(bo_bone.n_qx,bo_bone.n_qy,-bo_bone.n_qz,-bo_bone.n_qw, bo_bone.mat)

nice find thanks!

still a few other problems with loading the dwarf.b3d file. will check this. UPDATE: i think i fixed that as well.


Landon(Posted 2013) [#126]
No prob,

also i found it's actually the exporters that are not exporting the weights properly. (Well milkshape so far) I'm not sure why but, even though i have a loaded mesh that is rigged properly in blender or milkshape it doesn't export the weights unless i go in and manually highlight the assigned vertices for each bone and then press assign weight.

I was actually able to get some models to load with shared weights of 0.5 across two bones. What bothers me is how the heck does Pacemaker as well as Fragmotion recognize the weighted vertices if they are reading in as 0.0 in minib3d?

Weird.. Oh well lol.




AdamRedwoods(Posted 2013) [#127]
What bothers me is how the heck does Pacemaker as well as Fragmotion recognize the weighted vertices if they are reading in as 0.0 in minib3d?

i've no idea either, but if i put in a line that "if weight=0.0 then weight=1.0", it starts to animate...


AdamRedwoods(Posted 2013) [#128]
I've updated GitHub for B3D loader bug fixes. This update is slated as 0.34 as it contains numerous changes and I wanted to get XNA, DX11 updates in this but haven't had time yet. So label it as "in progress" but if you need the B3D fixes, they are there. Oh, and no, Flash11 does not work yet (in progress).

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


IceVAN(Posted 2013) [#129]
Hi Adam

Another little bug.

In EntityVisible() [tpick.monkey]

LINE 75 : Local psurf:TSurface = picked_surface
LINE 104 : picked_surface=psurf

picked_surface is an Int not a TSurface

bye!


IceVAN(Posted 2013) [#130]
Hi again Adam.

Another small bug that I have fixed.

EntityOrder () does no effect.

The problem is in Render() Method of opengles11 and opengless20.

I've corrected by adding this code after glDisable(GL_ALPHA_TEST)

If ent.order<>0
   glDisable(GL_DEPTH_TEST)
   glDepthMask(False)
Else
   glEnable(GL_DEPTH_TEST)
   glDepthMask(True)
Endif


bye!

When will we have a new version? Thank you!


AdamRedwoods(Posted 2013) [#131]
EntityOrder () does no effect.

i always thought it was only used to help with z-fighting....
but from the blitz3d manual:
Setting an entity's order to non-0 also disables z-buffering for the entity, so should be only used for simple, convex entities like skyboxes, sprites etc.

EntityOrder affects the specified entity but none of its child entities, if any exist.


ok, so you're correct, we need to fix that. thanks!

When will we have a new version? Thank you!

i can update these couple bugs to github, but the new version i'm working on is interesting. unfotunately it will take a while as my time is pulled in all directions, so i am just trying to release updates slowly through a 0.34.x system.


AdamRedwoods(Posted 2013) [#132]
i've some interesting news.
I managed to get Mojo working, which may be on ALL TARGETS, by extending the Mojo's graphics class and leveraging miniB3D's own engine. it is seamless, meaning mojo commands just work as is. cool.


CopperCircle(Posted 2013) [#133]
Wow, great job. Having Mojo would be cool for creating a UI/Level Editor.
I haven't used mini B3D for a awhile, has the .b3d loader changed much? I always struggled to get my models loaded.


AdamRedwoods(Posted 2013) [#134]
.b3d loader changed much? I always struggled to get my models loaded.

yes. Landon found a few bugs, and I have put in a binary loader for direct .b3d files.
i'm also making a collada loader.


Sammy(Posted 2013) [#135]
Full cross-platform Mojo integration in one update, that's quite an achievement Adam, well done!


Difference(Posted 2013) [#136]
The mojo integration sounds fantastic. Checking github every day now to see when you commit it :-)


IceVAN(Posted 2013) [#137]
mojo integration? yes!!


EdzUp(Posted 2013) [#138]
When can we get the version with mojo integration


IceVAN(Posted 2013) [#139]
Hi Adam.

Another litle bug.

In opengles20.monkey, line (493 aprox)

If an entity have disable fog fx then all entitys in the world have disable fog fx.


Original code:
' fx flag 8 - disable fog
If fx&8
     'glDisable(GL_FOG)
     If shader.u.fogflag<> -1 Then glUniform1i( shader.u.fogflag, 0 )
Endif


Corrected code:
' fx flag 8 - disable fog
If fx&8
     'glDisable(GL_FOG)
     If shader.u.fogflag<> -1 Then glUniform1i( shader.u.fogflag, 0 )
Else
     If shader.u.fogflag<> -1 Then glUniform1i( shader.u.fogflag, 1 )
Endif


opengless11 don't have this bug.

Bye!


bruZard(Posted 2013) [#140]
is there an example which explains CameraLayer() ?


Xaron(Posted 2013) [#141]
bruZard, yes there is:

http://monkeycoder.co.nz/Community/post.php?topic=3211&post=40613

I did use it for 2d stuff.


EdzUp(Posted 2013) [#142]
When compiling my game for android I get:
BUILD SUCCESSFUL
Total time: 1 minute 0 seconds
Starting: Intent { cmp=com.monkey/.MonkeyGame }
--------- beginning of /dev/log/main
--------- beginning of /dev/log/system
I/[Monkey](14118): **OPENGL VERSION:1.1
I/[Monkey](14118): ..max textures:11
I/[Monkey](14118): Monkey Runtime Error : Invalid int: ""
I/[Monkey](14118): /Volumes/8GIG/Linux/MonkeyPro69/modules/minib3d/tmodelobj.monkey<402>
I/[Monkey](14118): /Volumes/8GIG/Linux/MonkeyPro69/modules/minib3d/tmodelobj.monkey<251>
I/[Monkey](14118): /Volumes/8GIG/Linux/MonkeyPro69/modules/minib3d/tmodelobj.monkey<68>
I/[Monkey](14118): /Volumes/8GIG/Linux/MonkeyPro69/modules/minib3d/tmesh.monkey<238>
I/[Monkey](14118): /Volumes/8GIG/Linux/MonkeyPro69/modules/minib3d/tmesh.monkey<209>
I/[Monkey](14118): /Volumes/8GIG/Linux/MonkeyPro69/modules/minib3d/functions.monkey<921>
I/[Monkey](14118): /Volumes/8GIG/A.I/AI.monkey<49>
I/[Monkey](14118): /Volumes/8GIG/A.I/AI.monkey<76>
I/[Monkey](14118): /Volumes/8GIG/Linux/MonkeyPro69/modules/mojo/app.monkey<60>
E/AndroidRuntime(14118): FATAL EXCEPTION: main
E/AndroidRuntime(14118): java.lang.NumberFormatException: Invalid int: ""
E/AndroidRuntime(14118): 	at java.lang.Integer.invalidInt(Integer.java:138)
E/AndroidRuntime(14118): 	at java.lang.Integer.parseInt(Integer.java:359)
E/AndroidRuntime(14118): 	at java.lang.Integer.parseInt(Integer.java:332)
E/AndroidRuntime(14118): 	at com.monkey.c_TModelObj.m_ParseFaces(MonkeyGame.java:12642)
E/AndroidRuntime(14118): 	at com.monkey.c_TModelObj.m_ParseObj(MonkeyGame.java:12881)
E/AndroidRuntime(14118): 	at com.monkey.c_TModelObj.m_LoadMesh(MonkeyGame.java:13003)
E/AndroidRuntime(14118): 	at com.monkey.c_TMesh.m_LoadAnimMesh(MonkeyGame.java:9154)
E/AndroidRuntime(14118): 	at com.monkey.c_TMesh.m_LoadMesh(MonkeyGame.java:9427)
E/AndroidRuntime(14118): 	at com.monkey.bb_functions2.g_LoadMesh(MonkeyGame.java:17626)
E/AndroidRuntime(14118): 	at com.monkey.c_AIApp.p_Init(MonkeyGame.java:2769)
E/AndroidRuntime(14118): 	at com.monkey.c_AIApp.p_OnUpdate(MonkeyGame.java:2802)
E/AndroidRuntime(14118): 	at com.monkey.c_GameDelegate.UpdateGame(MonkeyGame.java:2953)
E/AndroidRuntime(14118): 	at com.monkey.BBGame.UpdateGame(MonkeyGame.java:559)
E/AndroidRuntime(14118): 	at com.monkey.BBAndroidGame.UpdateGame(MonkeyGame.java:1205)
E/AndroidRuntime(14118): 	at com.monkey.BBAndroidGame$GameTimer.run(MonkeyGame.java:791)
E/AndroidRuntime(14118): 	at android.os.Handler.handleCallback(Handler.java:725)
E/AndroidRuntime(14118): 	at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(14118): 	at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(14118): 	at android.app.ActivityThread.main(ActivityThread.java:5041)
E/AndroidRuntime(14118): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(14118): 	at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(14118): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime(14118): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime(14118): 	at dalvik.system.NativeStart.main(Native Method)

Anyone have any ideas how to fix this, I have tried the game on other platforms and it works perfectly (OSX, Win32, Linux, HTML5) but wont compile for Android.


AdamRedwoods(Posted 2013) [#143]
Anyone have any ideas how to fix this, I have tried the game on other platforms and it works perfectly

android freaks out if there's anything, including spaces, when trying to convert a string to an int. it's annoying. i'll have to throw another strip function for spaces in TModelObj (assuming that's the problem). can you check to see if there's spaces in the "f 1 2 3" part?


bruZard(Posted 2013) [#144]
thanks Xaron. This will work with fullscreen sprites with the same ratio (e.g. 16:9). But how should i handle a smaller sprite?


EdzUp(Posted 2013) [#145]
@Adam: where am I looking for the spaces as from what I can see most of the separators in the obj files are spaces :)

There does seem to be a data.Find( " ") in the obj loader at several places.


AdamRedwoods(Posted 2013) [#146]
in tmodelobj.monkey
under the function "ParseFaces"
swap this part:
fdata[s].vi = Int(D2[0])
fdata[s].ti = Int(D2[1])
fdata[s].ni = Int(D2[2])

for this:
If D2[0]<>"" Then fdata[s].vi = Int(D2[0])
If D2[1]<>"" Then fdata[s].ti = Int(D2[1])
If D2[2]<>"" Then fdata[s].ni = Int(D2[2])


i'll update this for the next update, coming tonight hopefully.


EdzUp(Posted 2013) [#147]
Ah brilliant thanks :-) will test it later :-)


AdamRedwoods(Posted 2013) [#148]
****************************
THREAD CONTINUES HERE:

http://monkeycoder.co.nz/Community/posts.php?topic=5016