jsc3d icon indicating copy to clipboard operation
jsc3d copied to clipboard

How to get all coordinate

Open GoogleCodeExporter opened this issue 10 years ago • 11 comments

What steps will reproduce the problem?
1. I have a obj file exported from blender,How to get all the 
vertexBuffer,indexBuffer,texCoordBuffer,texCoordIndexBuffer.
2. I have attached the obj file.
3.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 23 Jul 2014 at 12:21

Attachments:

GoogleCodeExporter avatar Jul 29 '15 04:07 GoogleCodeExporter

First of all, you should get the obj file loaded in the viewer. When done, the 
content of the obj file are wrapped in a Scene object, which can be obtained 
via the viewer.getScene() 
method(http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbols/JSC3D.Viewer.htm
l#getScene).

An obj model might be parsed to multiple meshes, you can get this mesh array 
using scene.getChildren() 
method(http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbols/JSC3D.Scene.html
#getChildren).

Now that you have all the mesh objects, the primitive data are merely plain 
properties of these meshes which can be accessed at your will:

  mesh.vertexBuffer
  mesh.indexBuffer
  mesh.texCoordBuffer
  mesh.texCoordIndexBuffer
  ...

Original comment by [email protected] on 23 Jul 2014 at 3:31

GoogleCodeExporter avatar Jul 29 '15 04:07 GoogleCodeExporter

Thanks for reply,but viewer.getScene() returning null,please check the coding 
below,is anything wrong?

        var canvas = document.getElementById('cv');
    var viewer = new JSC3D.Viewer(canvas);

    viewer.setParameter('SceneUrl', 'bank/female02.obj');

    viewer.setParameter('InitRotationX', 0);
    viewer.setParameter('InitRotationY', 0);
    viewer.setParameter('InitRotationZ', 0);
    viewer.setParameter('MipMapping', 'on');
    viewer.setParameter('Renderer', 'webgl');
    viewer.init();
    viewer.update();
var scene = viewer.getScene();
alert(scene);

Original comment by [email protected] on 24 Jul 2014 at 4:49

GoogleCodeExporter avatar Jul 29 '15 04:07 GoogleCodeExporter

The loading is asynchronous. So you should override the 
viewer.onloadingcomplete(http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbol
s/JSC3D.Viewer.html#onloadingcomplete) with a callback function and wrap your 
code in it like this:

  var viewer = ...
  ...
  viewer.init();
  viewer.update();

  viewer.onloadingcomplete = function() {
    // This will be executed immediately as the loading is done.
    var scene = viewer.getScene();
    console.info(scene);
    ...
  };

Original comment by [email protected] on 24 Jul 2014 at 6:20

GoogleCodeExporter avatar Jul 29 '15 04:07 GoogleCodeExporter

Ok thanks for your reply,can u please tell me how to load multiple obj file?

Original comment by [email protected] on 24 Jul 2014 at 6:39

GoogleCodeExporter avatar Jul 29 '15 04:07 GoogleCodeExporter

This discussion http://code.google.com/p/jsc3d/issues/detail?id=52 provides a 
good example for how to load multiple models into a single scene.

Please be aware that mutiple models from different sources can be used in a 
scene only if they share the same model space. Otherwise there will be a mess.

Original comment by [email protected] on 24 Jul 2014 at 11:53

GoogleCodeExporter avatar Jul 29 '15 04:07 GoogleCodeExporter

Thanks JSC3D is GREAT in the 3D world and project member of JSC3D is the best.

Original comment by [email protected] on 24 Jul 2014 at 11:56

GoogleCodeExporter avatar Jul 29 '15 04:07 GoogleCodeExporter

How to Change texture of a mesh on a button click?

Original comment by [email protected] on 25 Jul 2014 at 10:07

GoogleCodeExporter avatar Jul 29 '15 04:07 GoogleCodeExporter

First, get the clicked mesh via mouse event handlers. Then invoke 
mesh.setTexture() 
method(http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbols/JSC3D.Mesh.html#
setTexture) passing in a new texture object to replace the old one. Finally, 
call viewer.update() to notify the viewer the scene has changed and update 
display. The programming interface of JSC3D.Texture is documented here 
http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbols/JSC3D.Texture.html.

Original comment by [email protected] on 26 Jul 2014 at 2:03

GoogleCodeExporter avatar Jul 29 '15 04:07 GoogleCodeExporter

How to change vertexbuffer of a mesh on a button click?


Original comment by [email protected] on 30 Jul 2014 at 10:46

GoogleCodeExporter avatar Jul 29 '15 04:07 GoogleCodeExporter

Don't change vertexBuffer of an existing mesh. Create a new mesh with the given 
vertices and use it to replace the old one.

Original comment by [email protected] on 31 Jul 2014 at 10:52

GoogleCodeExporter avatar Jul 29 '15 04:07 GoogleCodeExporter

ok ,thanks,how to replace a mesh with the old one?

Original comment by [email protected] on 31 Jul 2014 at 11:21

GoogleCodeExporter avatar Jul 29 '15 04:07 GoogleCodeExporter