forked from adamredwoods/minib3d-monkey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NOTES.txt
216 lines (140 loc) · 11.1 KB
/
NOTES.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
****************************************
minib3d v0.33.2
bug fixes: xna, xna fog, xna vertex animation improved. opengl1.1 texture fix.
****************************************
minib3d v0.33
- MDD and PC2 import for vertex animation
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)
-- applied to an existing mesh
-- 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:
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)
- Camera Pick and Collisions now work
Added CollisionSetup() for easier setup.
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
- 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)
****************************************
minib3d v0.32
-added "minib3d.app" template. to use, import minib3d.app and override methods (Create, Init, Update).
- added function TEntity GetChildren(recursive = true)
- update movement functions to allow bone deformation. should work with Entity commands as well.(PositionEntity, RotateEntity, ScaleEntity, etc.) To animate with bones you must use myEntity.ActivateBones() or myEntity.Animate(4). You cannot combine B3D animation and programmable bone animation.
Example:
zombie.ActivateBones()
Local ent:TEntity = zombie.FindChild("Joint9")
ent.TurnEntity(0,1.0,0) ' 'rotates zombie torso on y axis
ent.PositionEntity(0,3.0,0) ' 'moves zombie torso to offset y=3.0
- with monkey V66, you can only load new shaders in OnCreate() or OnRender() [android]
- with monkey V66, SetRender() must be in OnCreate()
- in monkey v66, shaders must be setup in OnCreate().
(ie. use store pointers: fastbrightshader = New FastBrightShader)
- added TEntity.Draw(x,y) command:
Draw works much like Mojo's DrawImage command where it must be updated per frame to work, and renders the order of all objects layered when RenderWorld() is called. It can be placed in OnRender() but before RenderWorld().
The use of Draw is pixel perfect, but will automatically scale based on TPixmap's width and height. To override auto-scaling use Draw(x,y,true).
Also beware, that you need to use HideEntity() to keep the object from appearing in multiple cameras or when not drawn. Draw() will auto-unhide.
In XNA & some HTML5, the TText scaling is off, not sure why. Either smooth textures or increase TText entity scale.
Example:
local txt:TText = CreateText2D("Some text here")
txt.HideEntity()
txt.Draw(0,0)
- 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
****************************************
minib3d v0.31
- updated for monkey v66
- re-arranged preloading/buffer loading (future-proofing)
- uses #MINIB3D_DEBUG_MODEL = "true" to debug models instead of hardcoding
****************************************
minib3d v0.30
OVERALL
-- new targets: xna reach, html5, opengl2.0
-- shaders
-- vertex buffers are interleaved now
TMODELLOADERS
-- found an "error" where all loaded models were being rendered twice, some three times... hmmm... should notice a speedup.
TCAMERA
-- fog mode 3 modes. 1 linear, 2 exp, 3, exp squared. range has an effect on the location and length of the fog for all 3. it is a vertex fog, not per pixel.
TEntity
-- PaintEntity() for shaders, keeps old brush info (textures, color, etc). (leads to the question, why even have shaders as a tbrush?)
TMESH
-- CopyMesh()
Now more robust, copies animation as well. Use AddMesh() for merging just vertices.
-- AddSurface(surf)
Adds existing surface to mesh.
-- CreateGrid(x,y, repeat_tex,parent)
Creates a grid of x-width,y-depth of 1x1 interlinked quads. could be used for heightmaps. use repeat_tex to use this for textures (android fix)
-- SetNormalMapping()
Sets up normap mapping. Technically creates a tangent normal and stores in the color uniform. Implemented in shaders (not opengl1.1 or xna).
TTEXTURE
-- texture fx_flag & 1024 = normal mapping flag, must be in texture0
QUATERNION
-- i have a suspicion one of these equations is wrong. need unit testing
-- XNA
XNA is reach profile, should work on mobile. No point lights, spotlight, light attenuation. No multi textures.
works with VBOs only.
vertex animation copies the buffer, this can be slow, but it may not always be the slowness factor.
I've noticed odd slowing factors at around 100 zombies (1 fps) compared to 80 (30 fps) . very strange.
-- OpenGL1.1
Works with VBOs only since we are using interleaved arrays.
-- OpenGL2.0
Works with VBOs only since we are using interleaved arrays.
I've placed some default shaders for people to use:
BlurShader
FastBrightShader (full light, 1 or 2 textures)
FullShader (1 light, 4 textures, very slow on android)
I didn't implement masked textures since I have alpha blending, let me know if needed.
-- HTML5
recommended to use PreLoad() for textures, or will get errors on asynchronous loads from web.
-- Shaders
the pmatrix is fed a Proj*view matrix. I don't feed a separate proj matrix, but i have a separate view and model matrix.
I work with my shaders in world coords. (which is why the camera is a pv matrix)
-- IShaderEntity
. class to apply per entity shaders
.
****************************************
minib3d v0.20
- requires at least monkey 56, recommend monkey 59
- Uses #MINIB3D_DRIVER="driver name" for debug info and compiler side conditionals
-- problem with FireFox webgl, does not like empty vertex colors array. will flicker. turning off does nothing.
****************************************
march 1 2012
minib3d+monkey for glfw(pc mac), android, ios
https://github.com/adamredwoods/minib3d-monkey
config.h for glfw:
- turn on config.h depth_buffer_bits = 32
Adaption Notes v0.10
--------------------
When I first encountered minib3d I found it to be an elegant, non-complex 3d solution and I've tried to keep that... but the quest for optimization can lead to complexity.
Several things to think about regarding minib3d+monkey. Performance and memory. Effort was made to optimize matrix functions and the render loop. For matrix functions, be aware matrix functions act on themselves instead of creating new objects. Vector functions are not this way. Also, entities that are not parented will run faster than those that are (obviously). I'm currently using a global scale for each entity to quickly remove scaling from any matrix equations. I believe this was a problem with blitzmax minib3d but should be fixed here.
I've removed TGlobal file. All functions there were moved to their respective locations, mainly into TRender. TRender is broken out so it will be easier to introduce a new render pipeline using SetRender(). Possibilites include opengl20, flash, directx, and even raytraced or raycasting. Ttexture has not been broken out and i wonder if i should do this or allow respective targets to offer their own ttexture_directx class themselves. I'm open to suggestions.
I've taken liberty to add new functions to offer simplicity for expansion. CameraLayers is such functionality. One could associate entities to only be rendered with certain cameras like ortho cameras. This helps with huds, overlays, text boxes and shader effects. Entityfx is now given value 64 which disables depth testing for that entity. Ttexture now offers tex.Smooth() or tex.NoSmooth(). TBatchSprite has been added to manage particles and sprites. Very similar to sprites, particles can be added by using CreateSprite(), but a behind the scenes mesh is managed on the fly. I guess this could be used for grass or clouds too.
Vertex animation has been added. One can now convert b3d bone animation to vertex animation, which uses more memory, but for many identical entities offers a performance solution. I had 20 zombies animating at 30 fps on android. I plan to add an MDD file format loader since most 3d programs offer this export. MD2 files use a similar format, but i find very few MD2 exporters available. I added an OBJ loader, so OBJ+MDD would be a nice way to add animation without B3D exporters available. (Collada is crap, slow, and overly complex, i've already tried and it's unfinished. fbx is closed source.)
Collisions and picking are slow. I converted everything over but considered rewriting my own. Such a chore. Optimization will be considered, but i have already consolidated quite a bit of the functions and classes, although more can be done. I would like to rename some entity collision functions to use "collision" in the function call, like EntityBox() to CollisionBox() for the function to define the entities collision presence. Is anyone opposed to this? It'd make more sense imho. I already added EntityCollision() which could be overloaded to handle a lot of this setup.
Base64 is one of the ideal file formats for monkey. In tmonkeyutility you will find a nice decoder that offers file stream like functions. Base64 takes binary files and converts them to text. You could even encapsulate files into one text file. Online base64 converters are available online, or its possible make one in blitmax or any language.
Reloading context is necessary on mobile devices. If interrupted or paused, apps need a way to restore their state. I use the excess-memory method where loaded textures are kept in memory. Be aware of this, although it would be easy to de-allocate them if one so desires. TPixmap was created to help with this.
This version of minib3d was made to be extended. TRender is ripe for this. Ill probably make an opengl20 version quickly enough, with FBO and GLSL. Directx is entirely possible. Flash 11 stage3d is poor since AGAL is not glsl or hlsl but their own interpretation (why oh why adobe?).
I've added other small things here and there like TText, since I couldn't get back to Mojo after miniB3D rendering. This TText offers 2d or 3d rendering. You can add your own bitmap font if you please.
I've added AlignToVector with slerp, and shared that code with Blitzmax minib3d users.
As always I will be looking for bugs and revising minib3d+monkey as I continue with FBOs and Opengl20. I'm happy to add revisions or additions from the community.
Enjoy.