Open GoogleCodeExporter opened 8 years ago
Hi, Liu:
Really good idea! In fact I have been considering providing build-in support
for this functionality just as that in most CAD tools. But I'm just too busy in
other projects and there are still some difficulty in implementation to be
taken into account.
As for your application, a practical solution may be not to import multiple
models but to compute and construct a ground mesh automatically each time a new
model is loaded. The main idea is as this:
An stl model is loaded into one single mesh which makes things simple. When a
model is loaded completely, its bounding box will be calculated automatically
and stored in the mesh.aabb property. By knowing this, we manually construct a
box mesh whose vertical height is set to a small value and the horizontal
dimensions can be deduced from the sizes of the bounding box (such as 4 times
as large as that of the box). The vertices of the mesh should be placed just
beneath the bottom of the bounding box. Then we add our new mesh into the scene
via scene.addChild() method and update the display to show the result.
This approach is based on the assumption that the major model is positioned up
straight without any rotation in its model space. Otherwise it won't work.
Manually mesh construction is not documented well yet. I think this demo
http://jsc3d.googlecode.com/svn/trunk/jsc3d/demos/avatar.html can be a
reference for how to complete the task. And don't forget the API
documentations: http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/index.html.
Original comment by Humu2...@gmail.com
on 27 Jun 2014 at 10:55
Hi,
Thanks for your explanation.
I'm working on the same project, and after reading through your recommended
process and other tickets online, I am still having trouble to piece together
all the needed classes and functions to make this happen.
Would you sketch up a sample code please?
Very much appreciated!
Jay
Original comment by jayzhang...@gmail.com
on 23 Jul 2014 at 4:58
Oh it's not that complicated. I'll send you a simple example to demonstrate how
to make this via email. Please check it one or two days later.
Original comment by Humu2...@gmail.com
on 27 Jul 2014 at 2:14
Please check the attachment. It demonstrates constructing a ground plane
according to the bounding box of the scene each time a new model is loaded.
Original comment by Humu2...@gmail.com
on 29 Jul 2014 at 10:06
Attachments:
Thanks for your help!
Actually I figured out yesterday and we did approach it in a similar way.
However, is there anyway that I can have a different color for the ground or
have the ground surface as a net to better distinguish it from the model loaded?
Thanks
Original comment by jayzhang...@gmail.com
on 29 Jul 2014 at 4:29
Chaging color of the plane is very easy - just create a new
material(http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbols/JSC3D.Material
.html) with the diffuse color you like and set it to the plane via
mesh.setMaterial()
(http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbols/JSC3D.Mesh.html#setMat
erial).
Making the plane drawn as network requires more coding work. The basic idea is
to split the large plane to adjacent sub planes, still a single mesh of course.
And then override the plane mesh's default render mode with 'wireframe' through
mesh.setMaterial()
method(http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbols/JSC3D.Mesh.html#
setRenderMode), which tells the viewer to always render it as wireframe/network
regardless what the render mode is for the viewer. I think it can be done this
way.
Original comment by Humu2...@gmail.com
on 29 Jul 2014 at 5:36
Thanks a lot, it helps!
Original comment by jayzhang...@gmail.com
on 29 Jul 2014 at 7:01
Actually I tried to change the diffuse color to green, it didn't work. Then I
found out that for whatever color I changed, it will automatically be black.
Now I am using the default color, which is brown. Would you mind checking it
for me?
For the network plane, I totally understand your logic but if it's possible,
please send me a sample code. Otherwise please don't worry about it.
Also, my code currently could upload multiple stl files on the same ground
surface. However, to better distinguish different models, is there anyway I can
change the color of stl model uploaded?
Sorry I asked a lot of question, I appreciate your help!
Original comment by jayzhang...@gmail.com
on 30 Jul 2014 at 5:52
You should not just change the diffuse color of an existing material but create
a new material with the required diffuse color and set it to the mesh.
Please check the updated demo in the attachment. It may be helpful for your
current development.
Original comment by Humu2...@gmail.com
on 31 Jul 2014 at 10:47
Attachments:
I didn't use the correct format for color,
Thanks a lot!
Original comment by jayzhang...@gmail.com
on 31 Jul 2014 at 4:11
Hi there again,
I've finished adding ground plane to the model and other related stuff. Again
thanks for your help. It works very well locally. However, when I tried to push
the same code to the website, it messed up to an extent. The issue is that what
the code is doing is adding layers of layers viewer on top of each other if I
don't refresh the page, because on the web page, we are asking the user to
upload two STL files at once. In another word, without refreshing the page and
just changing the uploading files, the outcome is very uncertain. Especially
when I rotate it, the viewer will show the previous uploaded STL models, not
the current one.
Thanks,
Jay
Original comment by jayzhang...@gmail.com
on 9 Sep 2014 at 11:31
Original issue reported on code.google.com by
liuwukai...@gmail.com
on 22 Jun 2014 at 2:29