Mark Sibly

Forum Replies Created

Viewing 15 posts - 106 through 120 (of 1,431 total)
  • Author
    Posts
  • in reply to: Mojo: GetPixel() since update 1.11 #14178

    Mark Sibly
    Keymaster

    Yep, the behaviour of Keyboard.KeyPressed has changed since v1.1.06.

    Before v1.1.06 KeyPressed used use a ‘frame’ system, where KeyPressed returned true if a key was pressed in the current ‘frame’ (ie: the time between renders). However, this caused problems when people tried to use KeyPressed from within timers.

    It now returns true if a key has been pressed since the last call to KeyPressed (with the same key). This affects your code because you only call KeyPressed if mouse is in zone.

    The solution is to always check for KeyPressed, even if the mouse is not in any of the zones. I guess another possiblity would be to allow people to manually increment the ‘input frame’.

    Or, you could instead use a KeyEvent handler, like this:

    in reply to: Mojo: GetPixel() since update 1.11 #14174

    Mark Sibly
    Keymaster

    Now the question : How can i get the color of a pixel in the image ?

    The way you were doing it pre 1.1.11 is probably the most efficient so once 1.1.12 is out I’d suggest going back to that which will fix this issue.

    But note that it’s still not all that efficient, because modern GPUs don’t like you ‘reading’ their memory. On PC’s, GPU’s generally have their own private graphics memory and moving data to/from graphics memory is relatively expensive.

    Also, the OpenGLES API (used by mobile/web targets) doesn’t even support copying data from textures to system memory, only copying data from the ‘render target’. Desktop OpenGL does, but it wont be anymore efficient than the pre-1.1.11 method.

    There is no easy way around this, it’s just something you’ve got to deal with if you want HW accelerated graphics. If anyone has any ideas here too please feel free to share.

    For Keyboard events, i must experiment, (2900 lines of code in my prog), to see if my code is faulty.

    Not even a hint?!?

    in reply to: Mojo: GetPixel() since update 1.11 #14167

    Mark Sibly
    Keymaster

    Ok, I’m gonna revert this to pre 1.1.11 behaviour in the case of normal textures – my fixes were really only necessary for cubemap textures.

    in reply to: Mojo: GetPixel() since update 1.11 #14166

    Mark Sibly
    Keymaster

    Yes, the behaviour of textures has changed a little here – they were never supposed to modify the pixmap they were created with in the first place, and it was causing all sorts of issues with something else I was trying to do in 1.1.11, so I ‘fixed’ it so that the initial pixmap is copied to an internal one if necessary and is never used again (by the texture anyway).

    However, the old way is probably the most efficient way to do what you’re wanting so I think I’ll add some kind of new texture flag that preserves the old behaviour, not sure what I’ll call it yet. Should be in v1.1.12…

    Also any changes in Keyboard events ?

    There are always changes to everything! Could you be a little more specific?

    in reply to: 2D lighting issue. #14142

    Mark Sibly
    Keymaster

    The spaceships are ‘bouncing around’ because, with no texture filtering, they are ‘jumping’ between integer pixel coordinates. When things move slowly, this jumping will be very noticeable. Didn’t we go through this earlier? What are you expecting to happen here that isn’t? Why does the ‘ bouncing around’ bit appear twice at the start? Is there a difference between the 2 I’m not noticing?

    There is definitely a noticeable fringing on the right hand side of some detail sprites at 40s in the video, but a video is kind of next to useless for the purposes of diagnosing what could be going on – please post something short and simple I can run. Ditto there is more apparent fringing going on later in the video too but again there’s no way I can even really guess what’s going on purely from a video.

    Are you using a texture atlas at all? It looks a bit like texels are being fetched from the neighboring edges of an atlas. This *will* happen with filtering and you will need to pad atlas frames with a ‘null’ border.

    in reply to: mojo3d:Chunks creation problems (memory access violation) #14134

    Mark Sibly
    Keymaster

    Also, note that your code is creating *every* cube face here, even the hidden ones! The way you’ve done the sides[i] check effectively means that hidden sides will end up with ‘null’ indices (or possibly even incorrect indices) but the sides are actually still there and consuming memory and will even be ‘rendered’ by the gpu, although nothing willl be drawn because they are degenerate.

    Here’s a version that skips sides properly and now works on my machine without crashing. Again, the more efficient way to do this would be to just writing the entire thing into one big array and create the mesh all at once, but this is an improvement!

    in reply to: mojo3d:Chunks creation problems (memory access violation) #14133

    Mark Sibly
    Keymaster

    Yes, it’s crashing here if I set chunk sizes to 16, 128, 16 but it is also using about 2G memory which is the 32 bit limit and is likely to be causing problems (somehow). This shouldn’t be an issue on 64 bit windows really, although it will be on emscripten which is only 32 bit. You can check how much memory the app is using by starting task manager and watching the process memory usage growing.

    Part of this is because the mojo3d vertex format is quite ‘heavyweight’ – 80 bytes per vertex. Something like minecraft really needs a very lightweight vertex format but you can’t do that in mojo3d yet. Also, Mesh really needs a Compact() method of some kind as meshes will currently be consuming about 2x what they need to be due to the internal stacks.

    I’ll keep looking into this, but there is realistically likely to be some kind of 2G limit for monkey2 apps at the moment. It does also seem to be consuming more memory than I would have thought, which I’ll also look into.

    Note that building meshes with the mesh=mesh+mesh2 will be very ineffecient. Each time you add a mesh, the old mesh must be copied, which ‘grows’ the output mesh, which gets incremental slower and slower etc. You’ll probably get much better performance if you build everything into an array first and just build the mesh once.

    in reply to: Monkey 2 Spanish website #14120

    Mark Sibly
    Keymaster

    All integral datatypes in monkey2 are ‘signed’ by default with ‘unsigned’ variants of each. For example, ‘i:Int’ is a signed int, while ‘i:UInt’ is unsigned. So ‘b:UByte=255’ should do what you expect, as UByte is the unsigned variant of Byte.

    With blitzmax, you didn’t get a choice: byte and short were always unsigned, int and long were always signed (I think it was).

    in reply to: mojo3d : Shooting item from camera (angle) #14118

    Mark Sibly
    Keymaster

    The ‘forward vector’ of the camera may help here:

    Local fv:Vec3f=camera.Basis.k

    (Yes, that’s kind of ugly! perhaps Forward:Vec3f property could be added as an extension?)

    This returns a normalized vector representing the direction the camera is facing. For example, if the camera is pointed directly up, this will return (0,1,0).

    Note than in addition to entity.Basis.k, Basis.i will give you an entity’s ‘right’ vector and Basis.j will give you an entity’s ‘up’ vector.

    in reply to: Really newbie question about Monkey2 installation #14117

    Mark Sibly
    Keymaster

    If you are using the devtools package from the downloads page, you shouldn’t need to modify env_windows.txt at all! Glad you got it working though…

    in reply to: mojo3d:Not understanding Texcoord on cube of quads #14116

    Mark Sibly
    Keymaster

    If you want unique texcoords for each face of the cube (which I’m guessing is what you’re after) you need to duplicate the ‘shared’ vertices (ie: vertices with the same position) so each vertex gets its own texcoords. This will allow vertex 0 above to have different tex coords when used in the front quad (eg: 0,0) than when used in the left quad( eg: 1,0) because it’s really 2 vertices.

    This goes for any vertex attribute you want to to be different depending on the polygon it’s used in. For example, to ahieve flat-shading, vertices will have a different normal for each triangle they are used in (ie” the triangle’s normal) so a flat shaded mesh can’t have *any* shared vertices.

    Anyway, this means you should end up with 24 vertices (6 faces * 4 vertices per face) altogether. This is what Mesh.CreateBox does, you might want to have a look at that…

    And note that texcoord1 is not used by the built in shader.

    in reply to: mojo3d: Entity in view? #14103

    Mark Sibly
    Keymaster

    I’m having to invert the y result like below to correctly draw in 2D

    This issue has been fixed recently in develop branch.

    Wonder why Bullet is apparently so poor with the mesh stuff?

    I suspect this is actually a common problem with ‘real’ physics engines. As far as I can tell, they don’t generally work by working out a ‘collision time’ and finding an intersection point based on velocity ala blitz3d and many ‘game physics’ engines.

    Instead, they seem to use an instaneous ‘am I colliding’ sort of system that generally doesn’t take into account direction of movement or anything, so they have to sort of ‘guess’ which way to move things when they are intersecting, usually based on nearest point to penetrating point etc.

    To account for this and make collisions more accurate you need to perform more ‘substeps’ when updating the world which, now that I think about it, is something I haven’t even looked into yet!!!!!

    I’d swear I’ve seen Bullet doing terrain demos, but could be wrong!

    If you cmake the bullet repos, there are 2 demos that involve a mesh, both of which are terrain-ish and actually work pretty well. But the size of the mesh polys is quite a bit smaller than is pratical, smaller than the shapes colliding with them. I am planning to have a closer look at these demos later as it’s at least a working starting point…

    Your scaling code looks right, the important thing is to *not* use Entity.Scale as physics currently ignores this. Will take a close look at your demo a bit later…

    in reply to: mojo3d: Entity in view? #14102

    Mark Sibly
    Keymaster

    I’m having to invert the y result like below to correctly draw in 2D

    This issue has been fixed recently in develop branch.

    Wonder why Bullet is apparently so poor with the mesh stuff?

    I suspect this is actually a common problem with ‘real’ physics engines. As far as I can tell, they don’t generally work by working out a ‘collision time’ and finding an intersection point based on velocity ala blitz3d and many ‘game physics’ engines.

    Instead, they seem to use an instaneous ‘am I colliding’ sort of system that generally doesn’t take into account direction of movement or anything, so they have to sort of ‘guess’ which way to move things when they are intersecting, usually based on nearest point to penetrating point etc.

    To account for this and make collisions more accurate you need to perform more ‘substeps’ when updating the world which, now that I think about it, is something I haven’t even looked into yet!!!!!

    I’d swear I’ve seen Bullet doing terrain demos, but could be wrong!

    If you cmake the bullet repos, there are 2 demos that involve a mesh, both of which are terrain-ish and actually work pretty well. But the size of the mesh polys is quite a bit smaller than is pratical, smaller than the shapes colliding with them. I am planning to have a closer look at these demos later as it’s at least a working starting point…

    Your scaling code looks right, the important thing is to *not* use Entity.Scale as physics currently ignores this. Will take a close look at your demo a bit later…

    in reply to: Don't mind me, I'm just saying hi #14086

    Mark Sibly
    Keymaster

    Hi and welcome!

    in reply to: mojo3d: Entity in view? #14085

    Mark Sibly
    Keymaster

    OK, I’d deleted the code… now, on recreating it… it works perfectly, of course.

    If you can get it to happen again, give me a shout.

    More physics — would like to play with constraints in particular.

    What constraint should I start with?

    MeshCollider is well dodgy

    God yes, I’ve spent considerable time on this and haven’t come up with any really solutions yet. If you can post some simpe examples of the problems you’re having that would help. It’s likely MeshCollider used with ‘real physics’ is always gonna be tricky and require considerable coder ‘assistance’ to get working, in the case of bullet anyway.

    Fake ‘FPS physics’ still appears to be doable so it’s not a complete washout. But I was looking forward to doing some ‘real physics’ intertia-er thingy things with it so it sucks that it looks like that wont be easy.

    Switching to another API would be a possiblity except that there are no real alternatives. Phys-X is the only one with similar features (and even that’s missing some of the FPS features I’d like) but that’s not open source so no go there.

     world-space size of the mesh inside a scaled-down entity

    Scale does not currently affect physics! I may be able to make this work eventually, but it’s way down the list…

    To get ‘world bounds’ of a model, transform the mesh bounds (ie: the local bounds) by the model matrix. There should really be a AffineMat4 * Box operator in there for this but there isn’t yet (will add now) but you can use the TransformBox code above for now.

Viewing 15 posts - 106 through 120 (of 1,431 total)