How do you access the skeleton of a gltf in Aframe - aframe

I have a gltf file with a skeleton rigged into it and I would like to move the bones of the skeleton manually. How hard is this to do in real time

Each bone in the skeleton is a THREE.Bone instance, and can be accessed by JavaScript in an A-Frame component:
const mesh = el.getObject3D('mesh');
const bone = mesh.getObjectByName('LeftUpperArm');
bone.rotation.y = Math.PI / 4;
The number of bones and their names will vary from model to model, so you may find it helpful to .traverse(...) the mesh and print the names of its bones for reference.
So, it's not hard to simply move a bone in the skeleton, BUT you may find it inconvenient to move the bones in precise and natural-looking ways — particularly with a human skeleton. The rotations will involve a fair bit of math, and that math depends heavily on the particular skeleton you're working with. In general it is probably easier to do this type of animation in Blender, or to use an IK library (like THREE.IK).

Related

How to implement KdTree using PCLPointCloud2 used in loadOBJfile in point cloud library?

Okay, so I have one OBJ file which I read into PCLpointcloud2. Now I want to feed it into a K-dTree. Which is not taking PCLPointCloud2 as input. I want to query any general point if it lies on the surface of my OBJ file.
I am finding it hard to understand their documentation. So how can it be done?
Plus, kindly point me to a good reference easily interpretable. And what is "PointT" BTW? Is it custom build type defined by us? please elaborate.
Look at the code in the provided tool pcl_mesh_sampling (in the PCL code directory under tools/mesh_sampling.cpp). It is relatively simple. It loads a model from PLY or OBJ then for each triangle it samples random points from the triangle. The final point cloud then undergoes a voxel-grid sample to make the points relatively uniform. Alternatively, you can just run the pcl_mesh_sampling program on your obj file to get an output PCD which you can then visualise with pcl_viewer before loading the PCD file into your own code.
Once you have the final point cloud, you can build and use a KD-Tree as per http://pointclouds.org/documentation/tutorials/kdtree_search.php
PointT is the template argument. The point cloud library can handle a variety of point types, from simple PointXYZ (having just x,y,z) to more complicated points like PointXYZRGBNormal (having x,y,z,normal_x,normal_y,normal_z, curvature, r, g, and b channels). Each algorithm is templated on the point type that you want to use. It would probably be easier if you used PointXYZ with your OBJ file, so use pcl::PointXYZ for all your template arguments. For more on templates see http://www.tutorialspoint.com/cplusplus/cpp_templates.htm and http://pointclouds.org/documentation/tutorials/adding_custom_ptype.php.
Update (reply to latest comment)
Added here because this reply is too long for a comment.
I think I see what you are getting at. So when you sample points from the point cloud & build a KD-tree of the object surface, and for each point you keep track which faces are nearby that point (probably all the faces adjacent to the face from which the point was sampled should be sufficient? Just one face is definitely insufficient). Then when the query point is given, you find the nearest point in the KD-tree and check whether the query point is on the "outside" or inside of the full list of nearby faces associated with that point in the KD-tree. If it's on the "inside" of all of them perhaps it is an interior point. But I cannot guarantee that this is true. That is my thinking on that question at the moment. But I do wonder if you want a mesh-based approach really. By the way, if you break your mesh up into convex parts then you can have nice guarantees when processing each convex part.

Is there an easy (and not too slow) way to compare two images in Qt/QML to detect motion

I would like to implement a motion detecting camera in Qt/QML for Nokia N9. I hoped that there would be some built in methods for computing image differences but I can't find any in the Qt documentation.
My first thoughts were to downscale two consecutive images, convert to one bit per pixel, compute XOR, and then count the black and white pixels.
Or is there an easy way of using a library from somewhere else to achieve the same end?
Edit:
I've just found some example code on the Qt developer network that looks promising:
Image Composition Example.
To compare images qt has QImage::operator==(const QImage&). But i don't think it will work for motion detection.
But this may help: Python Motion Detection Library + Demo.

How do you create 2D vines procedurally for a game?

For a game I am making I want to create 2D vines and vine like structures procedurally. Is there some paper or code snippet that someone can point me to?
Googling results in procedural trees which have straight spiky branches, but I need to create vines which are curvy. Think Jack and the beanstalk type of growth.
http://youtu.be/2wq541W6LyE?t=2m11s
Your particular approach is going to depend on how you game handles drawing and collisions.
An approach popular with flash-based games is to draw the vine to a bitmap: Since you don't list your programming environemnt, I'll just explain the steps, not the code.
Start with a circle,
1 draw it,
2 move it,
3 scale it down.
4 At a random interval, spawn a "branch" and or a leaf.
Set the scale and position of the branch to match the parent. Start a 1-5 loop on the branch.
5 repeat 1 until fully grown (scale is too small to proceed).
In the move phase it can be handy to use Sin curve to make your vine weave in and out.
Youcan tweak the settings for how much it curves to get different types of vines.
Here is a link to a discussion fo teh topic. Some good source to be found in the links.
http://groups.google.com/group/flashcodersny/browse_thread/thread/9906041e557e620c
Including source code inf flash:
http://xfiles.funnygarbage.com/~colinholgate/swf/varicoseg.zip
And a javascript version that looks more like lightning, but couild be adapted to vines without much change:
http://www.brainjam.ca/hyperbolic/01_spite_mrdoob.html

How to open a 3dmax or maya file in flash?

Hi i want to open a 3d max file and do some rotation of a 3dmax object in flash action script 3.
How can i do this?
There are some 3d Engines that makes this simpler
If you're doing just rotation, I suppose Sophie 3d might be the easiest http://www.sophie3d.com/
other that that the two go-to libraries are Away 3d and Papervision (in order of my preference)
http://www.away3d.com/
http://pv3d.org/
The way you would go about using these is to get Collada to convert your 3d Max object into an xml-readable scheme that away3d and pv3d support
http://www.collada.org/
after some quick googling of collada 3d tutorial found this, though there might be more out there http://www.wazim.com/Collada_Tutorial_1.htm
hope this helps...
As far as I know, there are two ways to get a 3D model (3DS, Maya, etc.) into a Flash application:
Render the 3D scene to video, and output the video in Flash (this will not be interactive).
Import your scene into Swift 3D, which can then export to Flash.
Beyond that, 3D would have to be generated from within Flash, or you'd have to know the file format and read in the points, normals, textures, etc. from the model file (exporting to *.x or *.fbx might help, and their text formats are comparatively easy to interpret; make sure you don't use the binary versions of x/fbx).
I know that Sandy3D can directly import 3DS files (as well as COLLADA and ASE) into a scene.
If you've never worked with Sandy3D before, they've got several handy tutorials posted to help you get started.

3D Software Renderer with VB6

I am IT student and I have to make a project in VB6, I was thinking to make a 3D Software Renderer but I don't really know where to start, I found a few tutorials but I want something that goes in depth with the maths and algorithms, I will like something that shows how to make 3D transformations, Camera, lights, shading ...
It does not matter the programing language used, I just need some resources that shows me exactly how to make this.
So I just want to know where to find some resources, or you can show me some source code and tell me where to start from.
Or if any of you have a better idea for a VB6 project.
Thanks.
I disagree with the previous posts, a 3D renderer is actually pretty simple. A high-quality 3D renderer is hard however.
Get a bunch of 3D data, triangles are simplest.
Learn about homogenous coordinates and the great 4x4 matrix for transforms.
Define a camera by a position and a rotation (expressed in the 4x4 matrix).
Transform your 3D geometry by this camera.
Perform the perspective divide and scale to your window. This converts your 3D data to 2D.
Render the data as 2D.
Now you're going to lose out on a depth buffer, so stick to wireframes in the beginning. :-)
Don't listen to these nay-sayers, go out and have some fun!
Many years ago I made a shaded triangle renderer that used library calls to draw the triangles. It's a rather naive approach but you would be able to achieve the same result using VB6. I got all the maths & techniques from "Computer Graphics principles and practice" by Foley et al. Some parts are out of date now but I think you'd find it very helpful for this project and it can be bought 2nd hand at reasonable prices from Amazon for example.
One simple approach could be:
Read model file as triangles
Transform each triangle using matrices to account for camera position
Project triangle points onto 2D
Draw 2D triangle (probably using GDI)
This covers wireframe viewing. To extend this to hidden surface removal you need to work out which triangles are in front. Two possible ways:
Z-order sorting the triangles and drawing the ones furthest from the camera first. This is simple but inefficient if there are a lot of triangles and can give overlapping triangle effects when the order is not quite correct. You also have to decide how to sort the triangles - e..g by centroid, by extents...
Using a software depth buffer. This will give better results but is more work to implement. You will have to write your own triangle drawing code so cannot rely on GDI. See bresenham's line algorithm and related algorithms for doing filled triangles for how to do this.
After this you'd also need some kind of shading based on lighting. The calculations are covered in Computer Graphics principles and practice. For simple shading you can stick with drawing triangles using gdi , but if you want to do gouraud or phong shading the colour values vary across a triangle. One way around this is to sub-divide the triangle into smaller triangles, but this is inefficient and won't give very nice looking results. Better would be to draw the triangles yourself as required above for the software depth buffer.
A good extension would be to support primitives other than triangles. Basic approach would be to split primitives into triangles as you read them.
Good luck - could be an interesting project.
VB6 is not the best suited language to do maths and 3D graphics, and given that you have no previous knowledge about the subject either, I would recommend you to choose something different (and easier).
As it's Visual Basic, you could try something more form-oriented, that is the original intent of the language.
There is the 3D engine list which lists three engine in pure basic (an oxymoron) + Source code and of them one is in Visual Basic (Dex3D)
DeX3D is an open source 3D engine
coded entirely in Visual Basic from
Jerry Chen ( -onlyuser#hotmail.com ).
Gouraud shading
Transparency
Fogging
Omni and spot lights
Hierarchical meshes
Support for 3D Studio files
Particle systems
Bezier curve segments
2.5 D text
Visual Basic source
More information, screenshots and the
source can be found on the Dex3D
Homepage. (<= Dead Link)
EGL25 by Erkan Sanli is a fast open source VB 6 renderer that can render, rotate, animate, etc. complex solid shapes made of thousands of polygons. Just Windows API calls – no DirectX, no OpenGL.
VBMigration.com chose EGL25 as a high-quality open-source VB6 project to demonstrate their VB6 to VB.Net upgrade tool.
A 3D software renderer as a whole project is fairly complex if you've never done it before. I would suggest something smaller - like just doing the 3D portion and using lines to do the rendering OR just write a shaded triangle renderer (which is the underpinnings of 3D renderers anyway).
Something a little simpler rather than trying to write a full-blown 3D software renderer on the first go - especially in VB.
A software renderer is a very difficult project and the language VB6 is not indicated at all ( for a task like this c++ is the way.. ), anyway I can suggest you some great books I used:
Shaders: http://wiki.gamedev.net/index.php/D3DBook:Introduction_%28Volume%29
Math: 3D Math Primer for Graphics and Game Development
There are other 2 books. Even if they are for VB.NET you can find some useful code:
.NET Game Programming with DirectX 9.0
Beginning .NET Game Programming in VB .NET
I think you can take two ways either go the Direct X way and use DirectX 8 that has VB 5-6 support. I found a page http://www.gamedev.net/reference/articles/article1308.asp
You can always write a engine group up but by doing so you will need some basic linear algebra like Frank Krueger suggests.

Resources