Forum Replies Created
-
AuthorPosts
-
But you can still hear something? I’m stuck with crappy monitor HDMI audio (through a KVM!) and with 64 samples I can hear a noticeable ‘click’ here, which I don’t find particularly surprising as the sound is only playing for 1/11025*64, ie: ~6ms!
Not quite sure what everyone’s expecting here…
…also works fine with 44100hz, even short sample data lengths such as 32.
I had assumed this was a macos openal bug, looks like I was wrong.
Can you post a sample you are having problems with?
This is playing something that sounds a lot like a sine wave, which would suggest it’s not actually a playback problem:
Monkey1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071Namespace myapp#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class MyWindow Extends WindowField _sounds:=New Sound[4]Field _soundid:=0Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )Super.New( title,width,height,flags )Local n:=8192Local s:=11025 '44100Local p:=1 '.25Local data:=New AudioData( n,AudioFormat.Mono8,s )For Local i:=0 Until ndata.Data[i]=Sin( i*p ) * 127+128Next_sounds[0]=New Sound( data )data=New AudioData( n,AudioFormat.Mono16,s )For Local i:=0 Until nCast<Short Ptr>(data.Data)[i]=Sin( i*p ) * 32767Next_sounds[1]=New Sound( data )data=New AudioData( n,AudioFormat.Stereo8,s )For Local i:=0 Until ndata.Data[i*2+0]=Sin( i*p ) * 127+128data.Data[i*2+1]=Sin( i*p ) * 127+128Next_sounds[2]=New Sound( data )data=New AudioData( n,AudioFormat.Stereo16,s )For Local i:=0 Until nCast<Short Ptr>(data.Data)[i*2+0]=Sin( i*p ) * 32767Cast<Short Ptr>(data.Data)[i*2+1]=Sin( i*p ) * 32767Next_sounds[3]=New Sound( data )EndMethod OnRender( canvas:Canvas ) OverrideIf Keyboard.KeyHit( Key.Space )_soundid=(_soundid+1)&3_sounds[_soundid].Play()EndifApp.RequestRender()canvas.DrawText( "Hello World!",Width/2,Height/2,.5,.5 )EndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndSeptember 12, 2017 at 10:12 am in reply to: Links point to old domain in files part of the site. #10432Thank you!
Yes, camera’ll eventually support orthographic, and hopefully stero one day!
This is the nice thing about the 4×4 projection matrix – it supports both perspective and orthographic projections so the project/unproject code wont have to change.
This has been fixed in more recent versions of monkey2. There’s a new binary build on its way – this week sometime for sure!
Ok, I think these camera methods are basically what you’re after? Adding to repos soon…
Monkey1234567891011121314151617181920212223242526#rem monkeydoc Converts a point from world coordinates to viewport coordinates.#endMethod ProjectToViewport:Vec2f( worldVertex:Vec3f )Local clip_coords:=ProjectionMatrix * InverseMatrix * New Vec4f( worldVertex,1.0 )Local ndc_coords:=clip_coords.XY/clip_coords.wLocal vp_coords:=Cast<Vec2f>( Viewport.Size ) * (ndc_coords * 0.5 + 0.5)Return vp_coordsEnd#rem monkeydoc Converts a point from viewport coordinates to world coordinates.#endMethod UnprojectFromViewport:Vec3f( viewportCoords:Vec2f )Local vp_coords:=viewportCoords / Cast<Vec2f>( Viewport.Size ) * 2.0 - 1.0Local clip_coords:=New Mat4f( Matrix ) * -ProjectionMatrix * New Vec4f( vp_coords,-1.0,1.0 )Local world_coords:=clip_coords.XYZ/clip_coords.wReturn world_coordsEndYou can added these as extensoin methods if you want, or butcher them for your own evil purposes.
Turns out I forgot ;${PATH} at the very end!
Aha!
Is your bin/env_windows.txt file correct, or have you set system PATH to mingw binaries?
Can you dump bin/env_windows.txt file here, along with full path to devtools.
The MSVC version still needs g++ to generate dependancies, so you’ll need this in devtools too.
Dividing a 3d point by it’s ‘z’ component will give you a 2d point at z=1.
You’re right, the latest version of the NDK (v15.2.4203891) breaks the sqlite module.
A fix for this has just been pushed to the develop branch, plus I updated to the latest version of sqlite.
Woah, had to dig deep to find that one, but once I did the fix was surprisingly simple and halved the length of the light vertex shader in the process.
Fix push to develop branch, but you should really only need to update this file:
https://github.com/blitz-research/monkey2/blob/develop/modules/mojo/graphics/shaders/light.glsl
And just to confuse things a bit more, here’s another approach!
This is a bit of a compromise in that it doesn’t store entities in components, but stores a single entity per gameobject (which is effectively its ‘transform’ too) that you can access directly. This means a gameobject can’t have both a camera and a light component – it must have one or the other. You can think of a gameobject’s entity as a sort of special case component.
It doesn’t bother managing a hierarchy – gameobjects are just stored in a linear stack. You can of course parent gameobject entities to each other though, much like Transform above.
Again, the implementation of components here isn’t really important, I’m more trying to think out how mojo3d can be interfaced with.
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141Class GameObjectMethod New( entity:Entity )_entity=entity_entity.SetDynamicProperty( "gameObject",Self )_gameObjects.Add( Self )EndProperty Entity:Entity()Return _entityEnd'for lazy people like me....Property Camera:Camera()Return Cast<Camera>( _entity )EndProperty Light:Light()Return Cast<Light>( _entity )EndProperty Model:Model()Return Cast<Model>( _entity )EndMethod Destroy()For Local component:=Eachin Componentscomponent.OnDestroy()Next_gameObjects.Remove( Self )_entity.Destroy()_components=Null_entity=NullEnd'helpers...Function CreatePivot:GameObject()Return New GameObject( New Entity )EndFunction CreateLight:GameObject()Return New GameObject( New Light )EndFunction CreateCamera:GameObject()Return New GameObject( New Camera )EndFunction CreateModel:GameObject()Return New GameObject( New Model )EndFunction UpdateAll()For Local gameObject:=Eachin _gameObjectsLocal modified:=_seq<>_entity.Seq_seq=_entity.SeqFor Local component:=Eachin gameObject.Componentscomponent.OnUpdate( modified )NextNextEndInternalProperty Components:StringMap<Object>()Return _componentsEndPrivateGlobal _gameObjects:=New Stack<GameObject>Field _components:=New StringMap<Object>Field _entity:EntityField _seq:IntEndClass ComponentMethod New( gameObject:GameObject,type:String )_gameObject=gameObject_type=type_gameObject.Components[_type]=SelfEndProperty GameObject:GameObject()Return _gameObjectEndProperty Type:String()Return _typeEndProtectedMethod OnUpdate( modified:Bool ) VirtualEndMethod OnDestroy() VirtualEndPrivateField _gameObject:GameObjectField _type:StringEndOne thing I dislike here – using component string name. In my code above I achived this by Typeof().Name, because you can take a mistake in string but not in type name.
I didn’t put much thought into how the actual component system should work, and that ‘s sort of the point – having ‘clean’ GameObject and Component classes means you can do whatever you want, however you want.
But doesn’t the GameObject approach mean you have to wrap all the functionality in the Entity subclasses?
Yes it does, and it’s up to you to decide if that’s an acceptable amount of work. But it *does* give you 100% control over access to entities, so you can fire off callbacks and invoke signals etc whenever you want etc. You can also mess with parameters, or even prevent properties being modified or methods being called at all. It’s a form of Proxy object I guess, and is really the only way I can think of to gain 100% control over an object.
A ‘halfway’ solution to this would be to add Entity:Camera, Entity:Light, Entity:Model properties to components to return underlying entities, so people could access component entities directly. This would save you writing all the ‘wrapper’ properties/methods, but again, you lose a degree of control over things this way, as you have NO IDEA how the entity could potential be modified. But its really up to you how big a deal that is. The above is just an example of IMO a 100% safe/clean approach.
-
AuthorPosts