vishalchunne / blender-webgl-exporter

Automatically exported from code.google.com/p/blender-webgl-exporter
0 stars 0 forks source link

Cannot reproduce SceneJS example data #3

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The sample data in blender-cube.js looks like this:

var BlenderExport = {};
BlenderExport.Cube = function() {
return SceneJs.geometry({
type: 'Cube',
vertices : [[1.000,1.000,1.000],[1.000, ...
indices : [[0,1,2],[3,4,5], ...
texCoords : [[0.333,0.498],[0.001, ...
});
};

When I export from Blender, having selected the SceneJS option, my like
looks like this:

var BlenderExport = {};
BlenderExport.Cube = function() {
return SceneJs.geometry({
type: 'Cube',
vertices : [[1.00,1.00,-1.00],[1.00, ...
indices : [[0,1,2],[3,4,5], ...
normals : [[0.58, 0.58, -0.58],[0.58, ,
});
};

Apart from the different number of vertices, the normals is made from three
items while texCoords has only two items.

Original issue reported on code.google.com by t.arm...@gmail.com on 9 May 2010 at 9:42

GoogleCodeExporter commented 9 years ago
Normals having 3 items and texture coordinates having two is correct.  Normals 
are
vectors in 3D space, and texture coordinates are positions in 2D space.

Original comment by giles.th...@gmail.com on 13 May 2010 at 5:14

GoogleCodeExporter commented 9 years ago

Original comment by giles.th...@gmail.com on 14 May 2010 at 3:14

GoogleCodeExporter commented 9 years ago
I was just trying to point out that the sample example (that actually works) 
uses
texCoords - but blender-webgl-exporter sends out normals.

I must assume that blender-webgl-exporter is doing something wrong here, no?

Original comment by t.arm...@gmail.com on 16 May 2010 at 6:49

GoogleCodeExporter commented 9 years ago
You're right and you're wrong :-)  I *think* the exporter is doing the right 
thing,
but you and Dennis are using different models.  

It sounds like the default cube that appears in Blender has no texture 
coordinates,
which makes sense -- they're the kind of thing you'd expect to have to set up 
manually.  

The sample file seems to have been generated from a Blender file which has had
texture coordinates set up, but has had the normals removed.  (The latter is a 
bit
suprising to me, but perhaps Dennis had a good reason for it.)

So, when you export the default Blender file, which has normals but no texture
coordinates, that's what you get in your SceneJS file -- and the same for the 
other
kinds of export.  When Dennis exported his own file, which had texture coords 
but no
normals, that's what he got in the output.

The real bug is that the Blender file which was used to generate the samples is 
not
included with them, which is obviously very confusing.

In addition, it sounds like the format needs updating from SceneJS 0.1 to the 
latest
version.

Original comment by giles.th...@gmail.com on 16 May 2010 at 1:05

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hi, I just stumbled in on this.

Looks to me like simply a case of renaming and flattening some of those arrays 
parameters on the SceneJS.geometry.  

Here's a live example of manual geometry definition in the latest SceneJS (a 
cube, as it happens) to use as reference: http://bit.ly/cBD0D2

Couple of things to note here:

1. You need to include a "primitives" property - IE. primitives: "triangles" 

2. The "type" property uniquely identifies the buffers for the geometry in 
video ram, within the scope of WebGL canvas. So the type should not always be 
"Cube" - you can either omit it, causing SceneJS to randomly generate it, or 
ensure that it is unique to that geometry by making it a hash on the the 
geometry's topology. For example, say you have a cube of dimensions 
x=2,y=34,z=10, if you give it a type of say, "cube-2-34-10" then SceneJS will 
reuse the same set of buffers for multiple instances of that particular 
geometry in the scene, even if you have multiple geometry nodes specifying it. 

cheers,
Lindsay

Original comment by lindsays...@gmail.com on 25 Jun 2010 at 4:45

GoogleCodeExporter commented 9 years ago
Also, here's the API doc on Geometry: 
http://www.scenejs.org/docs/symbols/SceneJS.Geometry.html

Original comment by lindsays...@gmail.com on 26 Jun 2010 at 1:03