R0J0hound's Forum Posts

  • That pretty much just reduces the point count from 3991 to 328 which would give a speed increase. The model could always be made with a lower point count, and having the points uniformly spaced like that probably is preferred to the random sampling.

    That all could be done beforehand, and just use the rotation method we already have.

    Edit:

    I haven't done much work on the capx lately. I've been playing around with doing it in c and basic OpenGL to see the speed difference. 2% cpu vs 35% and it looks like I'm getting 60fps. Hmm, that was refreshing. Might try webgl and JavaScript next.

  • In your proposed algorithm step 1 requires sorting all the points into those bounding boxes, then in step 2 those would need to be sorted again by z. It would perhaps work well I you pre-calculated all of that but then you'd be stuck at one view angle.

    [quote:2cxp6ej9]The reason i got so high framerate before by only rotating in one axis, was because i rotated all the points as one entity. I did not need to calculate any new positions for them. I pinned them to a dummy sprite, and rotated the dummy sprite instead. Maybe somehow this could be done for each axis?

    That would only work for an xy rotation, if I understand it correctly.

  • I need to wait till C3 is actually released.

  • This link explains the math of a physics bounce:

    https://gamedevelopment.tutsplus.com/tu ... medev-6331

    I always found it hard to fake physics because it never looks right.

  • That sounds similar to a SVO (sparse voxel octree) which is commonly used for rendering/storing voxels. Here's a link with some code to find the intersection of a ray and the octree that I may study a bit more later.

    http://stackoverflow.com/questions/1022 ... algorithms

    Right now we're just transforming all the points and basically rendering all of them. Next would be to just use a uniform 3d grid of voxels or a SVO and cast a ray for every pixel we want to display. Ray casting on a uniform grid could be done with a line drawing algorithm like dda. I'm uncertain it will be faster than what we're doing now, due to the overhead of events adding up and sometimes providing no gain. It may be interesting to try that approach, as it also would eliminate the holes on the model.

  • rexrainbow

    It may take a while for me to post new links. I neglected to plan ahead and don't have anything set up.

    edit:

    new link posted

  • The models already are in pretty much normalized coordinants of -1 to 1. Using color to define position probably has way too low of percision to be useful, not to mention it would be slow to constantly need to get the individual components.

    That's odd that using only one axis of rotation is that much faster. The rotation math is only done on three objects, one for each axis X,y and z. We could combine the equations together at the expense of being readable.

    The zsorting of the points is probably the slow point now. For the tilemap rendering we could instead do a zbuffer instead of sorting and see if that's faster. For the Sprite rendering we could import the normals and transform them too, and then don't display or sort the normals facing away from the camera.

    The tilemap object does some typically useful things when you set a tile, such as updating its collision polygons. That probably adds up the way we're using it.

    Overall 4000 points is pretty high and we probably can get something that looks good with much fewer. Although we'd want it much faster if at all possible.

    I did an animation test with that eagle where all the points lerp between two frames with distorted points. It only lost a few fps.

  • It is faster, although less readable, even when doubling the number of points. It's actually a bit faster just using sprites instead of plotting to a tilemap, although coloring is a bit trickier. You can switch between the two with the use_tilemap variable.

    https://drive.google.com/open?id=0B-1_F ... TNuUS04NnM

    Loading a model file takes a few seconds right now. Tokenat is inefficient with large amounts of text. There are some topics on loading a dictionary that show faster ways which could be used here.

  • It's more of a point cloud renderer than a voxel one. I'm pretty sure something more efficient is done with voxel renderer's than drawing everything.

    Loops in the event sheet are probably the biggest culprit of why it's slow. I've compared equivelent loops in just JavaScript and they're over 20x faster. I guess in general the slowdown is events are interpreted and there is some overhead involved with it.

  • You may be able to do that with meshlab or cloudcompare, but there's probably a more direct way to do it.

    I found this:

    http://www.danielgm.net/cc/forum/viewto ... f=9&t=2322

    So with cloudcompare you can load a mesh and get a point cloud of the surface. I think a file format like ply would help here since it can be in text.

    Here's the test. I took the model in blender and created a uv for it and baked a texture to it, then after a little fanagling I managed to get the exported obj file to include the image with it. Then I followed the guide in the link above to sample points on the 3d model. I used 2000 points since that seemed reasonable, then I exported with the ply file format since that stores vertex colors.

    https://dl.dropboxusercontent.com/u/542 ... zer_3.capx

    It works and is slightly faster but the object has to be drawn smaller to hide the gaps. I also disabled the perspective transform since that caused even more gaps.

  • Look here:

    http://www.meshlabjs.net/

    Load your 3d model in obj format and search for "Poisson Disk Sampling". You could then export it back out to a obj file. The only catch is color/texture isn't used. I think an orthogonal render of the model could be used to sample the colors.

    Another idea could be to convert the mesh to voxels. There's a command line utility poly2vox that looks like it supports a few formats. The voxel formats would need to be decoded though.

  • tunepunk

    I had some fun trying my hand at implementing some of that stuff. My events are mostly clean and as readable as possible, although it's at the point where a lot of it needs to be refactored and cleaned up. It is mostly organized so maybe you'll find it useful.

    https://dl.dropboxusercontent.com/u/542 ... rizer.capx

    What it does is fairly straight forward.

    1

    The object file is loaded so we have a list of 3d points and a list of faces which list indices of the points.

    2

    The points are moved around, or in the capx rotated around in 3d.

    Rotation

    The rotation math to rotate on the xy plane is this:

    newx = x*cos(ang)-y*sin(ang)

    newy = y*cos(ang)+x*sin(ang)

    It's basically the same for xz or yz rotations. Just change the x,y variables.

    Changing the amount of rotation every frame can be used for animation.

    Translation

    Next after rotating the points around we need to move the points away from 0,0,0 which is the viewer position. So for example we want the object center to be five units in front of the viewer you could do this:

    newz = z+5

    This is important to do before the perspective transform because things get distorted near 0 and we shouldn't be able to see points with z<0 or behind the camera.

    Perspective

    Perspective is really simple, it's just multiplying x,y by a scale number and dividing by z:

    perspectiveX= x*scale/z

    perspectiveY= y*scale/z

    final transformation to screen position

    This is basically changing the center from 0,0 to the center of the screen.

    screenx = x+320

    screeny = y+240

    3

    Now that the points are transformed we next want to draw points and lines and perhaps polygons. There are a few ways that come to mind.

    Using sprites

    Sprites could be created at the transformed xy position and lines could be done by stretching sprites from one point to another. Polygons could be done with some madness with triangle sprites but that's not straightforward.

    Using the canvas plugin

    You can plot points, draw lines and draw polygons fairly easy. The antialiased lines may not be what you want. Also the paster plugin can be used for textured polygons but that's a different topic.

    Using a tilemap

    The tilemap can be thought of as an array and it removes the step needed to convert the array to something visual. One color is simple but if you look at the capx it shows a way to do a spectrum of colors, well 4096 to be exact. It takes red,green and blue components in the range of 0 to 15 and converts it to a tile number.

    Line drawing

    This is done by lerping from the one point to the other and drawing the inbetween points. Look the "plot line" function in the capx, it's fairly simple.

    polygon drawing

    This took me a bit to wrap my head around. I tried two methods to draw triangles.

    The first one is fairly simple to understand. First you find the bounding box that contains the all three points of the triangle, then you loop over every pixel in that bounding box and see if that pixel is inside the polygon. Unfortunately the math looks a bit hairy.

    The second method is a scanline method which is faster. It involves sorting the three points by y and then lerping along the edges to get the x positions at every y. It has less hairy math but isn't the simplest to understand either.

    Performance on the monkey model is about 4-6 fps and I don't think a whole lot of extra performance for this can be squeezed out of the events. This sort of thing is always pretty slow which is why the rasterization is usually all done by the gpu. It can be made faster if most of it was done in javascript, and the events were only used to issue commands. 60fps should be possible with the events ported directly over, but js isn't pleasant to work with imo.

  • This isn't a bug, it's a feature request.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Im sure someone uses databases with c2, although I never have myself. You could look at the plugin list to see if there's something to help with that or maybe search the tutorials to see if someone explains how to do it.