webgl library for CAD like applications - webgl

I would like to create a few simple CAD like applications (web based, ideally portable to mobile devices).
For example create a floor tile layout in 2D. There is a need to enter precise measurements (floor dimensions, tile dimensions), create a layout grid from the tiles, move the tile layout around the floor etc.
Once done with the layout it would be nice to render it in 3D with texture.
Learning 2D/3D programming represents a fairly steep learning curve for me (judging from the three.js tutorials i've seen) so I would like to start with the one best suited for the task.

Related

COLLADA 3D content creation, how?

I am looking for a tool to start with simple 3d objects for Scene Kit. I know there are a lot professional tools out there, but just buying blind a program to try a bit how things work would be wasted money.
How do I create 3D content for a Scene Kit scene, beyond using the builtin geometry and geometry creation tools within Scene Kit?
Short answer: Blender.
Long answer: Blender, because it's free and as good as any other 3D app (they are unfortunately all quite bad) but take this to the Apple Developer forums if you'd like more info, as this question is not appropriate for Stack Overflow. The way you're thinking about this is also not appropriate; no app is a "Colada editor". That would be like saying Photoshop is a JPEG editor.
The Unity forum is also a great place to hear a bunch of opinions; unlike any of Apple's tools other than Logic or perhaps Final Cut, it has a wide-ranging user base of technically-minded artists from whom to gather opinions.
Use Polygon Modelling.
COLLADA content is created in 3D modelling programs. There are three main ways of creating 3D content: polygon modelling, clay/brush style push/pull modelling of highly complex meshes, and what's most commonly known as NURBS modelling.
Polygon modelling involves creating shapes by articulating and adding primitive pieces of geometry to primitive pieces of geometry and progressively building up complex shapes in this manner. It has several massive advantages for game engine content creation that have seen it become (far and away) the most popular manner of making content for game engines.
Namely:
Strict and absolute control of the amount and type of geometry (performance)
Strict and absolute seam and inter-object connectivity control (animation)
Absolute texture control and material/shader control via geometry and bitmaps with 1:1 UVW mapping (ideal for expressing textures onto geometry with great performance)
Well designed and commonly used smoothing and tessellation algorithms nondestructive to, and considerate of, the above points
Given these massive benefits for game content creation, it's imperative you learn Polygon modelling first, for any and all game content creation. Most nearly all polygon modellers output a format compatible with COLLADA.
Understanding Polygon modelling will also give you understanding of some of how Geometry Shaders work and what they act on. The addition of Geometry Shaders is a relatively new feature of Scene Kit that provides vastly more interesting ways to manipulate geometry than the basic geometry creation tools provided within Scene Kit.

How to detect unseen triangles on screen

I'm having a very simple terrain map with tiles! All the tiles are same size, just different height (z value) !
I can render them OK, but there are thousands of tiles , but not all of them are on screen, only a portion (that ahead of view)! So i'm doing a batch rendering, collect only tiles that appear on screen then Render them all in 1 call!
I try to use D3DXVec3Project to project vertex on World space to Screen space, then detect which triangle is on Screen, however this is very slow, call this for whole map take to 7ms (about 250x250 calls ).
Right now i'm using iso view (D3DXMatrixOrthoLH), there is no camera or eye, when I want to move arround the map, I just translate the world!
I think this is a very common problem that all engine must face to optimize, but I cant search for it ! Is it visible detection , culling or clipping... ?
Thanks! Should I just render all the tiles on screen, and let DirectX auto clip for us ? (If I remember well, last time I try render them all, it's still very slow)
img : http://i1335.photobucket.com/albums/w666/greenpig83/terrain2_zps24b77283.png
Yes, in complex scenes, typically, we must cull invisible geometry to achieve interactive frame-rates. Of course it greatly depends on scene itself, capabilities of API, and target hardware.
Here are first steps of a good terrain renderer (in order of complexity):
Frustum culling - test for collision between camera's frustum (visible volume) and objects (such as meshes and terrain tiles). No collision means object is invisible. Based on collision detection algorithms. Of course, you will need camera (view and projection matrices) for that. Also you will need a good math lib.
Spatial partitioning (ex: "Quad tree" in case of terrain) - grouping objects to a specific data structures, which allows avoid collision tests which are known being impossible in advance. Incredibly speeds up frustum culling. For example, we don't need to test all tiles that are behind the camera.
Level of Detail (LOD) - different techniques which allows render objects, that are far away from camera, less detailed, reducing resources consumption. Allows render amazing, realistic, detailed scenes with huge terrains.
Now you know what to ask Google for ;) , but still I'll add some links.
For beginners:
braynzarsoft's tutorials - you probably be interested in latest ones, about terrain and collision detection
rastertek terrain tutorials
Advanced:
vterrain.org - source of infinite knowledge about terrain rendering (articles, papers, links to implementations)
Mr. Hoppe's papers on progressive meshes
Hope it helps =)

Creating a 3d coordinate system plus 3d vectors in ActionScript?

I am just starting to dive into the world of 3D objects and perspectives, esp. in Flash.
My goal is to have a 3d coordinate system with grids plus the option to define x, y, z values of a vector to be plotted.
Simple example:
It would also be great to use the mouse to rotate the coordinate system, e. g. like in this video or here.
Does anybody know if there is such a tool or library that provides such a 3d coordinate-system? I would prefer Flash AS2/AS3 but this is not a must-be. The only requirement: The tool must be running within the browser, no use of software such as Blender or SketchUp.
Maybe somebody has already written a program like that?
Thank you.
PS: I know that there are web services like wolframalpha that can plot in 3d, but I need an interactive tool.
PaperVision3D is an opensource actionscript3 library that can handle all sorts of 3D rendering. http://code.google.com/p/papervision3d/ . I've used it for programs that give you a full 3D environment with typical 6 degrees of freedom.

How can I create a corner pin effect in XNA 4.0?

I am trying to write a strategy game using XNA 4.0, with a dynamically generating map, and it's really difficult to create all the ground textures, having to distort them individually in photoshop.
So what I want to do is create a flat image, and then apply the distortion programatically to simulate perspective, by moving the corners of the image.
Here is an example done in photoshop:
How can I do that in XNA?
My answer isn't XNA-specific as I've never actually used the library; however the concept should still apply.
In general, the best way to get a good perspective effect is to actually give 3d coordinates and transformations and let DirectX/OpenGL handle the rest. This has great benefits over attempting to do it yourself - specifically, ease of use, performance (much of the work is passed on to your graphics card), and perspective-correct texturing. And nothing's stopping you from doing 3d and 2d in the same scene, if that's a concern. There are numerous tutorials online for getting set up in the third dimension with XNA. I'd suggest heading over to MSDN.

Do camera libraries exist for XNA?

Do libraries of different cameras exist for XNA? I've searched around and found lots of different camera classes with different interfaces (or no defined interface at all) but no common interface with standard camera definitions.
I feel that there must be something that I'm missing, it seems like such a crucial aspect of any game that there must be a good reason for the lack of camera libraries.
Your question is a little bit ambiguous. So I'll do my best to explain how to do cameras in XNA.
Basically a camera is just a Matrix (as you seem to already know), or collection of matrices. Conventionally you have a View matrix (position the camera in the world) and a Project matrix (project the 3D points of the world onto the 2D viewport).
Because cameras are as simple as this - there is really no need for some kind of comprehensive camera library. It is generally easier for a game to "hard code" a simple camera class that fulfils the functionality required by that game, than to try and solve the exponentially complicated problem of making some kind of generic camera class that will work for all games.
To create useful matrices for a camera, the XNA Matrix class provides various methods. Like CreatePerspective for a Projection matrix, or CreateLookAt for a View matrix.
(So, to make a simple camera class, have it take your camera setup information - position, field of view, etc - and output the necessary matrices.)
To use those matrices when drawing, you need to set them on your Effect (where they will be used to transform vertices to their screen positions in your vertex shader). XNA 4.0 introduces effect interfaces, which provides a consistent interface for doing this.

Resources