Forum Replies Created
-
AuthorPosts
-
Just did massive editing there for clarity.
I think in summary that WebSockets do the initial handshake over HTTP, then switch to an almost UDP-like ‘raw data’ protocol.
Looking at my Pastebin minimal WebSockets server code, I think the HTTP 1.1 client code probably should at least start to connect to a WebSockets server when run from a standard HTTP-supporting platform, at which point the server sends back “HTTP/1.1 101 Switching Protocols” and the server/client should then implement WebSockets protocols. (A true browser-based WebSockets client would not have to do the ‘manual’ HTTP connect-and-switch-protocol step — the browser presumably handles this part behind the scenes.)
Note that my HTTP 1.1 client actually has nothing to do with WebSockets, though if you add the check for 101 response I think it should get that far — on non-browser platforms.)
However, I think it unlikely that Emscripten translates HTTP sockets requests to WebSockets, so think it very doubtful the HTTP 1.1 client could be expected to work from the HTML/JS platforms.
Plenty links in the Pastebin source, including a proper 3rd-party test server!
Just remembered Brucey wrapped libwebsockets for BlitzMax, too… might be something that could be adapted (on Github under bah.mod I think). Also believe skidracer’s dom module for mx1 had websockets stuff in it.
I did the very beginnings of a WebSockets server in BlitzMax, though I think it only handled the initial negotation (can’t test right now). Might point someone in the right direction…
Won’t fill the thread with Max code!
Is there a better/more robust way to implement my <span class=”crayon-v”>CenterModel</span>, by the way?
Oh, would definitely prefer Pitch/Yaw/Roll methods… Rx/Ry/Rz don’t exactly jump out!
Ah, cool — I don’t think the IDE picks up .Rotation then! It does indeed work, though, thought I’d tried it!
Just added to the scene/model viewer below. Been using various downloaded models, but mainly the .fbx versions of these two from the new Google Poly:
https://poly.google.com/view/bmDjSxceaEE
https://poly.google.com/view/2binsxeOBve(You have to mess about with positioning in-demo to see them properly!)
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195#Import "<std>"#Import "<mojo3d>"#Import "<mojo3d-loaders>"#Import "<assimp>"Using std..Using mojo..Using mojo3d..' ----------------------------------------' Application name...' ----------------------------------------Const FORMATS_3D:String = "fbx, obj, b3d, gltf" ' More available!Global AppName:String = "Viewer 0.0000000000000001... pre-alpha"Function CenterModel:Void (model:Model, scale:Float)' Not bulletproof! 10000 hard-coded, not sure how you get around this...model.Mesh.FitVertices (New Boxf (-10000, 0, -10000, 10000, scale, 10000), True)model.Position = NullEndClass Game Extends WindowConst SHIFT_BOOST:Float = 5.0Field scene:SceneField camera:CameraField light:LightField camera_boost:Float = 1.0Field modelpath:StringField model:ModelField scale:Float = 1.0Field copies:Stack <Model>Method New (title:String, width:Int, height:Int, flags:WindowFlags)Super.New (title, width, height, flags)scene = Scene.GetCurrent ()scene.ClearColor = New Color (0.1, 0.2, 0.75)scene.AmbientLight = New Color (0.5, 0.5, 0.5)camera = New Camera' Camera settings...camera.Near = 0.1camera.FOV = 90LoadModel ()light = New Lightlight.CastsShadow = Truelight.Color = New Color (0.95, 0.975, 1.0)light.Range = 1000light.Move (-500, 500, -500)light.PointAt (model)End' This slightly dirty almost-self-contained utility method loads' directly into model:Model field -- ESC from load requester exits app!Method LoadModel:Void ()Local failed:Bool = FalseRepeatIf failed Then Notify ("NOOOOooooo...", "Failed to load " + StripDir (modelpath), True)modelpath = RequestFile ("Select a model, or Cancel/ESC to exit...", FORMATS_3D, False, CurrentDir ())If Not modelpath Then App.Terminate ()ChangeDir (ExtractDir (modelpath))If model Then model.Destroy ()model = Model.Load (modelpath)If Not model Then failed = TrueUntil modelCenterModel (model, 5)scale = 1.0model.Scale = New Vec3f (scale, scale, scale)camera.Position = Nullcamera.Rotation = NullEndMethod UpdateGame:Void ()model.Scale = New Vec3f (scale, scale, scale)EndMethod ProcessInput:Void ()If Keyboard.KeyHit (Key.Space) Then light.CastsShadow = Not light.CastsShadowIf Keyboard.KeyDown (Key.LeftShift)camera_boost = SHIFT_BOOSTElsecamera_boost = 1.0EndifIf Keyboard.KeyHit (Key.Escape)LoadModel ()EndifIf Keyboard.KeyDown (Key.A)camera.Move (0.0, 0.0, 0.1 * camera_boost)EndifIf Keyboard.KeyDown (Key.Z)camera.Move (0.0, 0.0, -0.1 * camera_boost)EndifIf Keyboard.KeyDown (Key.Left)camera.Rotate (0.0, 1.0, 0.0)EndifIf Keyboard.KeyDown (Key.Right)camera.Rotate (0.0, -1.0, 0.0)EndifIf Keyboard.KeyDown (Key.Up)camera.Rotate (1.0, 0.0, 0.0, True)EndifIf Keyboard.KeyDown (Key.Down)camera.Rotate (-1.0, 0.0, 0.0, true)EndifIf Keyboard.KeyDown (Key.Minus) Or Keyboard.KeyDown (Key.KeypadMinus)scale = scale - 0.1EndifIf Keyboard.KeyDown (Key.Equals) Or Keyboard.KeyDown (Key.KeypadPlus)scale = scale + 0.1EndifEndMethod OnRender (canvas:Canvas) OverrideProcessInput ()UpdateGame ()RequestRender ()scene.Render (canvas, camera)canvas.DrawText ("Camera controls: Cursors, plus A/Z (Shift for boost!)", 20.0, 20.0)canvas.DrawText ("ESC to load new model or exit (close dialog)...", 20.0, 40.0)canvas.DrawText ("Model scale (-/+ to change): " + scale, 20.0, 80.0)EndEndFunction Main ()Local width:Int = 1024Local height:Int = 768Local flags:WindowFlags = WindowFlags.Center' Local width:Int = 1920' Local height:Int = 1080' Local flags:WindowFlags = WindowFlags.FullscreenNew AppInstanceNew Game (AppName, width, height, flags)App.Run ()EndI find with these two models that scaling up to ~10.0 works nicely (see on-screen keys). You may have to ‘back up’ when scaling up!
You can hit ESC to load a new model… seems to work well. ESC/Cancel on the file requester to exit.
Patreon’d! Great piece of work, thanks for all your efforts.
That’s the web site I linked!
(Yeah, no doubt much more complex to implement than it appears anyway.)
I’m not sure it would need rewritten entirely — I read this web site a while back, and the recommendation seems to be “just convert to/from WCHAR” only at the point where the Win32 API requires it:
utf8everywhere.org (Should jump to “Our Conclusions”.)
Portability, cross-platform interoperability and simplicity are more important than interoperability with existing platform APIs. So, the best approach is to use UTF-8 narrow strings everywhere and convert them back and forth when using platform APIs that don’t support UTF-8 and accept wide strings (e.g. Windows API). Performance is seldom an issue of any relevance when dealing with string-accepting system APIs (e.g. UI code and file system APIs), and there is a great advantage to using the same encoding everywhere else in the application, so we see no sufficient reason to do otherwise.
Just for the record, works properly here on Win7.
Very, er, eyecatching!
Inevitable gripe: the light on the eye should stay still.
Nicely done though.
Yeah, please don’t post this kind of thing here — it’s been very civil so far.
Click Docs at the top of this site, then “Monkey2 Users Guide”, then “Language reference”. Docs are a definite “WIP” at this time, but the language reference is pretty much done I think.
I actually think the idea of putting on Steam for a small fee makes a lot of sense, especially if it were updated from dev regularly — updating dev branch really is a slog (probably takes 40 minutes+ to download and rebuild), so I’d quite happily pay myself!
No harm in describing it on Steam as open-source while still charging something for it, but I think a low price for the convenience would be key in the face of all the free competition.
I think people on Steam would be more likely to buy than on itch.io, though, where you can just take for free.
-
AuthorPosts