Forum Replies Created
-
AuthorPosts
-
I had a different experience expected it to be dog slow, but not so much http://bedroomcoders.co.uk/mx2Test/Mojotest.html – I was actually quite impressed!
I guess it does depend on what you are using…
I’d kind of assumed release compile would optimise and remove any unused code anyhow…?
have you noticed that #include seems to do nothing – not even cause an error! (typo I keep doing!)
narp not here! its USER (Void Linux) let me reboot and see Antix (non systemd debian variant)… (brb)
Antix Linux also uses USER … NOT USERNAME
its login that sets the variable see also LOGNAME… just for extra confusion!
@scurty are you on windows ’cause USER works for me! whereas USERNAME does not…
maybe check both and see which one isn’t empty?
[/crayon]Monkey12345[crayon-5cbaa002e3345466275030 inline="true" ]#import "<libc>"Function Main()Local USERNAME:libc.char_t Ptr = libc.getenv("USER")Print(String.FromCString(USERNAME))EndTLDR; I keep rotation and position in a couple of vectors – its not a waste to use an extra one for scale….
its the diagonal values… (NB code isn’t using mx2’s affine matrix but my own version)
for example if I want to create a scale matrix (to multiply with a matrix I want to scale)
[/crayon]Monkey123456[crayon-5cbaa002e6f9b985227533 inline="true" ] Method scale(x:Float,y:Float,z:Float)identity()mat[0] = xmat[5] = ymat[10] = zEndhowever once you then rotate a matrix etc, these values are going to get lost in the aggregation
for example once you multiply it with a rotation matrix (which you could make like this)
[/crayon]Monkey123456789101112131415161718192021222324[crayon-5cbaa002e6fa1308113773 inline="true" ] Method rotationX(rad:Float)Local s:Float = Sin(rad)Local c:Float = Cos(rad)mat[ 0] = 1.0mat[ 1] = 0.0mat[ 2] = 0.0mat[ 3] = 0.0mat[ 4] = 0.0mat[ 5] = cmat[ 6] = smat[ 7] = 0.0mat[ 8] = 0.0mat[ 9] = -smat[10] = cmat[11] = 0.0mat[12] = 0.0mat[13] = 0.0mat[14] = 0.0mat[15] = 1.0Endnotice element 5 and 10….
In general what I have tended to do is use a position vector and quat rotation – stored in a 4 element vector… (if you need scale use another vector to store scale – why not its not a great waste!)
It used to be fashionable to say you should never store position and rotation ONLY in a matrix, if you only ever needed to add (or subtract!) incremental values from position and rotation, it has worked fine for me in the past – just bare in mind while you can easily extract position from a matrix BUT there are multiple axial rotations (and orders of rotation) that can give the same orientation.
@dawlane, nah you just compile using wine and the mingw compiler included with the windows version of mx2 – simples…
in fact if I can be bothered I could probably nail together a Makefile that could do it
[/crayon]Monkey1[crayon-5cbaa002eb9e7805865467 inline="true" ]make windows SRC=AAAgame.monkey2[/crayon]Monkey1[crayon-5cbaa002eb9ec585560294 inline="true" ]make linux SRC=AAAgame.monkey2and so on…
check you have the mserver tools installed in the monkey directory, check that the path specified exists and it contains the mserver executable.
In linux I tried it first and then figured out where it needed to be from the error message!
also make sure that when you extracted the server, that you retained the directory hierarchy
what is ted21? have you forked ted ?
here’s an OpenAL version (sdl mutter mutter bag of bolts mutter mutter)
which doesn’t need to be thread safe…
because of a struct array inside the channel info struct I’ve had issues getting realtime feedback for the channels – its probably not worth taking too much further…
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151#import "xmp"#import "<std>"#import "<mojo>"#import "<openal>"#import "assets/"Using xmp..Using std..Using mojo..Using openal..Global ang:Floatglobal ctx:xmp_context PtrGlobal paused:Bool = FalseGlobal frameInfo:xmp_frame_infoGlobal modData:DataBufferGlobal buf:=New ALuint[2]Const bSize:UInt = 1024*5Global curBuf:Int = 0Global bufDat1:=New UByte[bSize*4]Global bufDat2:=New UByte[bSize*4]Global src:ALuintFunction fillBuffer(buffer:ALuint)Local p:UByte PtrIf curBuf=0 ThencurBuf=1p = Varptr bufDat1[0]ElsecurBuf=0p = Varptr bufDat2[0]Endifxmp_play_buffer(ctx , p, bSize , 0)alBufferData( buffer, AL_FORMAT_STEREO16, p, bSize, 22500 )alSourceQueueBuffers( src, 1, Varptr buffer )End FunctionClass xmpWindow Extends WindowMethod New()ClearColor=New Color( 1, 0, 0 )End MethodMethod OnRender( canvas:Canvas ) OverrideApp.RequestRender()ang = ang + 0.01ClearColor= New Color((Abs(Sin(ang)/2.0)+0.5),0,0)canvas.Clear( ClearColor )canvas.DrawText("space to pause / restart", 20, 60 )canvas.DrawText("right to go forward a position", 20, 80 )canvas.DrawText("left to go backward a position", 20, 100 )local Processed:ALintalGetSourcei( src, AL_BUFFERS_PROCESSED, Varptr Processed )canvas.DrawText("processed "+Processed, 20, 200 )while Processed>0Local BufID:ALuintalSourceUnqueueBuffers( src, 1, Varptr BufID )canvas.DrawText("filling buffer "+BufID, 20, 220 )fillBuffer(BufID)alGetSourcei( src, AL_BUFFERS_PROCESSED, Varptr Processed )Wendxmp_get_frame_info(ctx, Varptr frameInfo)canvas.DrawText("pos:"+frameInfo.pos, 20, 160 )canvas.DrawText("pat:"+frameInfo.pattern, 80, 160 )canvas.DrawText("row:"+frameInfo.row, 140, 160 )End MethodMethod OnKeyEvent( event:KeyEvent ) OverrideSelect event.TypeCase EventType.KeyDownSelect event.KeyCase Key.Key1ang=0Case Key.Escape' TODO release OpenAL properly here....xmp_end_player(ctx)xmp_release_module(ctx)xmp_free_context(ctx)App.Terminate()Case Key.Spacepaused = Not pausedIf paused ThenalSourcePause( src )ElsealSourcePlay( src )End IfCase Key.Rightxmp_next_position(ctx)Case Key.Leftxmp_prev_position(ctx)EndEndEndEnd ClassFunction Main()New AppInstanceNew xmpWindowctx = xmp_create_context()If ctx = Null ThenPrint "couldn't get an xmp context"ReturnEnd IfmodData = DataBuffer.Load( "asset::yoafrica-dia.mod" )'Local modData:DataBuffer = DataBuffer.Load( "asset::JEFF93.IT")If xmp_load_module_from_memory(ctx, modData.Data, modData.Length) <> 0 ThenPrint "couldn't load module"ReturnEndxmp_start_player(ctx, 22500, 0)Local device:=alcOpenDevice( Null )Assert( device,"Failed to open OpenAL device" )Local context:=alcCreateContext( device,Null )Assert( context,"Failed to create OpenAL context" )Assert( alcMakeContextCurrent( context ) )alGenSources( 1,Varptr src )alGenBuffers( 2,Varptr buf[0] )fillBuffer(buf[0])fillBuffer(buf[1])alSourcePlay( src )App.Run()End Functionenjoy!
guessing you don’t approve of finalisers then? pity would be handy to clean up none GC resources…
so there is no way to safely use the sdl callback?
I assume then that openAL is the way to go?
in principle yes, there is actually not too much complication, but if you wanted to make a complete tracker it would probably be fairly time consuming, while many of the “mod” formats are documented (to various levels) it would probably be better to create a custom format.
The place to start would be to write a multi channel mixer/pitch bender… SDL makes it reasonably easy, as it provides a callback when it needs a new buffer, (see the callback in the demo)
anyhow bed soon and away for a little while
just to mention if you run in debug mode you’ll get a seg fault, tried to pin it down with gdb but its corrupting stack frames so difficult to see, “seems” ok in release mode, but I’ve even seen behaviour like that with and without gcc’s -g switch so I’d lean to there being some issue for sure…
might look at the “full” libxmp (as opposed to lite) source when I get back…
-
AuthorPosts