Re: why so hard? How to put 3d obj into world

74 views
Skip to first unread message
Message has been deleted

UltraTopher

unread,
Jan 11, 2015, 4:47:03 PM1/11/15
to turbulenz-e...@googlegroups.com
Perhaps you should read "Programming for Dummiez 101" first. :)

Marián Šedaj

unread,
Jan 12, 2015, 3:04:56 AM1/12/15
to turbulenz-e...@googlegroups.com
Oh that was so clever! Thanks and sorry for telling my opinion!
When 14 y.o. kid who listens to One Republic tells me this I should listen.

Ian Ballantyne

unread,
Jan 12, 2015, 5:05:07 AM1/12/15
to turbulenz-e...@googlegroups.com
Sorry to hear you are having problems getting started. We have a huge range of developers with varying backgrounds and abilities on this forum and aim to help and encourage all of them. We are interested in helping everyone with their various issues, so if there is something in particular you would like to figure out how to do, we will do our best to answer it.

-_-

unread,
Jan 12, 2015, 5:56:32 AM1/12/15
to turbulenz-e...@googlegroups.com
Thank you Ian I really appreciate your work on the framework,

In your tutorial section, you perfectly explained how to place a cube into the world with vertexBuffer.

Now I want to place model (duck.dae) into the world. Just that, nothing more.

I initd all variables like gd, md etc. Then, I've created mapping_table.json where I refer duck.dae to staticmax/xxx.dae.json and then using SceneLoader I load the duck.dae and set up Default Rendering.

1st question is: What else do I need to do to render duck?
2. Where can I set up its position?
3. Why is SceneLoader out of jslib. Its helper function but why it isn't "in the box" already?

Thank you
 

Ian Ballantyne

unread,
Jan 16, 2015, 11:41:24 AM1/16/15
to turbulenz-e...@googlegroups.com
  1. A Camera to view the duck, see below
  2. With a transform matrix, again see below
  3. It is a basic method of loading the Scene object, but not the only way. Our samples use it and it can be used in your own projects. The quick answer is it probably should be, but has not been included historically.


If you are doing the process manually using the SceneLoader, Camera and Default Rendering:
  • Once you have done sceneLoader.load then you need to make sure you are updating the camera using updateProjectionMatrix() and updateViewProjectionMatrix.
  • To set the position of the duck you need to do:
var duckNode = scene.findNode("LOD3sp");
duckNode.setLocalTransform(duckMatrix);

where duckMatrix is the matrix for duckNode. Created like so:
var duckMatrix = mathDevice.m43BuildIdentity();
var 
v3Position = mathDevice.v3Build(x, y, z);
mathDevice.m43SetPos(
duckMatrix, v3Position);

An example of this can be found in the Camera sample and Load Model samples (Camera sets the position post load and Load Model sets it before load)




If you just want to get the duck loading, then using Protolib is a simpler library to do it:

duckMesh = protolib.loadMesh({
    mesh
: 'models/duck.dae',
    v3Size
: mathDevice.v3Build(1.0, 1.0, 1.0),
    v3Position
: mathDevice.v3Build(x, y, z)
});

To render the duck set the camera position and camera direction with protolib.setCameraPosition & protolib.setCameraDirection between protolib.beginFrame() and protolib.endFrame()

An example of this can be found in apps/protolibsampleapp/scripts/protolibsampleapp.js




Does this make sense? Let me know if you need more detail.


Reply all
Reply to author
Forward
0 new messages