Jump to content

Selecting and Texturing One Side of a Box


Wingnut
 Share

Recommended Posts

....shape key animation, but this is not that

 

Jeff, I'm not quite sure I understand that. The animation is done with a shape key. - but just one.

 

Cloth Animation2

 

I look at F-curves as how the interpolation is done. In this new blend file, the same cloth animation,  but more animation editor windows open:

 

1.The Action Editor  - allows you to edit/create animations for whole objects and rigged objects. Currently empty as the animation does not involve moving objects.

2. The F-curve editor - allows you to define how the interpolation takes place. On right of that window you will see a box with the type of interpolation - currently set to Bezier. You can also tweak individual points ot groups of points, by scaling or moving them and by adjusting the handles.

3. The Shape Key Animation Editor - you can create animations with one or more Shape keys - objects don't move - but the vertices that make up the mesh do.

4 The Default Time line.

 

Finally over on the far right you will see a Shape Key box with "Draped" highlighted. Below that is a slider (currently at zero) drag it and watch the cloth change.

 

If you want to look at an example with multiple shape keys, I can dig out the head I used in my Unity Lipsync demo.

 

cheers, gryff :)

Link to comment
Share on other sites

gryff,

Just to be clear, shape keys would be an enhancement.  I am interested in it and trying to find out where in the python API the data for it is.  The animations & other things I requested are currently supported features of the existing production exporter(possibly undocumented).

 

The tablecloth examples are a good start for me, as I know there is data for me to find & I do not have to make anything, thanks.

 

What I had in mind for the base-case model was to add stuff to it so many export features could be exercised.  They might make a silly model, but the overall purpose of the model is deadly serious.  Maybe something like add a plane to act as ground and receive shadows.  Make sure the light is directional (sun) type, since it is the only kind of light that casts shadows in Babylon.  Do not worry about clicking the custom properties to cast/receive shadows or creating a shadow map for the light.  The new exporter has its own.  I'll turn them on once I get the model.

 

For other stuff just go wild like add fog, a multi-colored cube that rotates like a disco ball.  Make the camera pan back and forth.  This animation is directly either on the camera or mesh thru the structure animation_data (table cloth has nothing in animation_data).  The script for camera is:

You only have to understand this enough to know how to get it into the model.

        if camara.animation_data and camara.animation_data.action:            TowerOfBabel.log('animation begun of camera:  ' + self.name)            self.animations = []            for fcurve in camara.animation_data.action.fcurves:                if fcurve.data_path == "location" and locAnim == False:                    self.animations.append(VectorAnimation(camara, "location", "position", 1))                    locAnim = True                #Set Animations            self.autoAnimate = True            self.autoAnimateFrom = 0            self.autoAnimateTo = bpy.context.scene.frame_end - bpy.context.scene.frame_start + 1            self.autoAnimateLoop = True

The code for mesh is (object is the mesh):

        if object.animation_data and object.animation_data.action:            TowerOfBabel.log('animation begun of mesh:  ' + self.name, 2)            self.animations = []            for fcurve in object.animation_data.action.fcurves:                if fcurve.data_path == "rotation_euler" and rotAnim == False:                    self.animations.append(VectorAnimation(object, "rotation_euler", "rotation", -1))                    rotAnim = True                elif fcurve.data_path == "location" and locAnim == False:                    self.animations.append(VectorAnimation(object, "location", "position", 1))                    locAnim = True                elif fcurve.data_path == "scale" and scaAnim == False:                    self.animations.append(VectorAnimation(object, "scale", "scaling", 1))                    locAnim = True            #Set Animations            self.autoAnimate = True            self.autoAnimateFrom = 0            self.autoAnimateTo = bpy.context.scene.frame_end - bpy.context.scene.frame_start + 1            self.autoAnimateLoop = True

Here I would go for the the disco cube, rotation_euler.  Might look pretty funny for that man to go strolling thru the fog with that above his head.

 

Jeff

Link to comment
Share on other sites

Just to be clear, shape keys would be an enhancement.

 

Understand that - but was not sure exactly what the dividing line was. I will try to build a test file for you though I think "fog" is going to be a problem. Blender has a number of ways of doing fog , smoke, fire etc. but they are usually for situations where you produce still renders or animations - not a 3d setup. Example "Mist" is produced in a render by adding an alpha factor to objects as they get further away from the camera in a render.

 

Will try to make a test file for you after my guest leave next week.

 

cheers, gryff :)

Link to comment
Share on other sites

Hi guys.  JC... at http://www.blender.org/support/ ... in the 'demo files & FAQ' section, there is a link to the 'regression suite' which is supposedly a large package of Blender test files.  Might be worth a look.  If you want to avoid all the BS, its link is http://download.blender.org/demo/test/test260.tgz

 

Thanks again for your cool work on exporting.  I love hearing you talk about it, and feeling your enthusiasm.  I hope hope hope you make Tower of Babel free for us (maybe with a donations link).  What a great contribution it will be.  You'll not only be a hero for Babylon users... but for ALL people who export from Blender. 

 

And you seem to teach REAL WELL, too, so comment that puppy to the gills, and it won't need any documentation. :)  I would be more than glad to voluntarily help with ongoing support where ever I can.

 

As best I can tell, you have essentially created a 2-way exporter.  One choice... make a .babylon file, and the other choice, make a Babylon ready-to-use scene.  I love that idea.

Link to comment
Share on other sites

Jeff, one issue that might crop up when sharing .blend files is whichg version of Blender was used to create them. Example, files created in Blender 2.63+ when opened in Blender 2.61 and earlier will show up without faces - just a wireframe. Another example, if I create a .blend file in Blender 2.71, when I open it in Blender 2.69 I get a warning message telling me that "data maybe lost" as it was created in a later version of Blender. So, it might be a good idea if I use the same version as you to create test files (which I will start in a couple of days).

 

cheers, gryff :)

Link to comment
Share on other sites

gryff:

Good to know, about the versions.  On Ubuntu (my dev system), I am using 2.69, because I was in a hurry after nuking my Window 7 a couple of weeks back, and this is the version piped in from this Ubuntu software packager thingy.  On OSX, I use 2.7a.  Go with 2.69, as this model is intended to be put in GIT for regression testing of future modifications.  Most software will open an older version of a file that is uses, and possibly update them.

 

Wingnut:

Thanks for the source for some more .blend files to try.  I plan on justing putting Towel of Babel in GIT, just like the original exporter.  Not in any hurry though.  There is a fully working exporter in production.  I am starting to play with Shape Keys, which is a higher priority.  There is also a problem with dealing with the way Babylon implemented Instances.  My plan is to fully support my commercial needs first.  After that, it is in my interest that not it HAVE TO BE supported by me.

 

As far as documentation,  It is sort of the same program, massively reorganized into smaller python OO classes.  The original was created right at the beginning of this project, and it shows it.  It was just one monolithic class, with everything done in a single pass.  Almost every new project has one these.  You need to pump data in from an external source, then you have to quickly focus on using it.  You just get this program to work, not put it in an easy state to maintain.

 

Towel of Babel has python classes for World, Mesh, SubMesh, Node, Camera, Light, Texture, Material, Mult-material, bone, skeleton, & animation/Vector animation subclass.  Each of these classes has a constructor, which does the first pass of pulling out all the things that are needed and doing any processing needed to make them Babylon ready.  Each class also has both a to_scene_file() & to_java_script() methods to write the babylon friendly data to its respective output.

 

This level of modularity makes it vastly more maintainable than before.

 

Jeff

Link to comment
Share on other sites

  • 1 month later...

hello !

 

I have exported a scene from blender it's working fine in web .

But i want to change its texture and color dynamically .

 

e.g.

 

Suppose i have a bag object i have exported it from blender its name is test.babylon  it has a texture name base.jpg.

But i have have 3 another textures . i have create a dropdownlist in my html page.

 

So i want to if i have selected red/black/purple  from dropdownlist bag texture should be change .

Please do help me out .

 

Thanks in advance .

Link to comment
Share on other sites

  • 9 months later...

Bringing back to life an old thread here! It seems like the answer to this is to use submeshes and a multi-material? Temechon's code is pasted in below. But I'm struggling to understand the SubMesh() parameters: it feels like they are magical numbers just plucked out of thin air. How do I know the numbers to use for each of the 6 faces of the box? Also, on one of tries, I got the texture on just one face, but it was upside down. I wondered if giving the numbers in a different order can fix that, or if I have to rotate the whole box?

 

BTW, I have a two-sided plane, working, but I don't like that when I rotate around it that it has no depth, which is why I want to create a box instead:

var myImage = new BABYLON.StandardMaterial(null, scene);myImage.diffuseTexture =  new BABYLON.Texture("textures/img1.png", scene);myImage.backFaceCulling = false;myPlane = new BABYLON.Mesh.CreatePlane(null, 2.0, scene, true);myPlane.material = myImage;

(The textures I put on each side might be dynamic textures, which is why doing this in Blender is not a solution.)
 

 


Temechon's code from earlier in this thread:

var wall3DMaterial = new BABYLON.MultiMaterial("wall3DMaterial", scene);wall3DMaterial.subMaterials.push(wall3DInnerMaterial);wall3DMaterial.subMaterials.push(wall3DOuterMaterial);wall3DMaterial.subMaterials.push(wall3DSideMaterial);wall.subMeshes = [];var verticesCount = wall.getTotalVertices();// Material at index 1 : wall3DOuterMaterialnew BABYLON.SubMesh(1, 0, verticesCount, 0, 3, wall);new BABYLON.SubMesh(1, 0, verticesCount, 3, 3, wall);// material at index 0 : wall3DInnerMaterialnew BABYLON.SubMesh(0, 0, verticesCount, 6, 3, wall);new BABYLON.SubMesh(0, 0, verticesCount, 9, 3, wall);//Material at index 2 : wall3DSideMaterialnew BABYLON.SubMesh(2, 0, verticesCount, 12, 24, wall);
Link to comment
Share on other sites

Trial and error found the 6 faces, but I cannot solve the problem that "Front" is upside down, and "Back" isn't. BTW, there seems no difference between doing "0,6" vs. two commands, "0,3" and then "3,3",  as Temechon did. (?)

myBox.subMeshes.push(new BABYLON.SubMesh(0, 0, verticesCount, 0, 6, myBox));  //FrontmyBox.subMeshes.push(new BABYLON.SubMesh(0, 0, verticesCount, 6, 6, myBox));  //BackmyBox.subMeshes.push(new BABYLON.SubMesh(1, 0, verticesCount, 12, 6, myBox)); //RightmyBox.subMeshes.push(new BABYLON.SubMesh(1, 0, verticesCount, 18, 6, myBox)); //LeftmyBox.subMeshes.push(new BABYLON.SubMesh(1, 0, verticesCount, 24, 6, myBox)); //TopmyBox.subMeshes.push(new BABYLON.SubMesh(1, 0, verticesCount, 30, 6, myBox)); //Bottom

 

Link to comment
Share on other sites

These are the constructor args for submesh:

constructor(public materialIndex: number,             public verticesStart: number,             public verticesCount: number,             public indexStart,             public indexCount: number,             mesh: AbstractMesh,             renderingMesh?: Mesh,             createBoundingBox: boolean = true)

you are setting the verticesStart to always be 0, with also the same count.  That seems wrong.

Link to comment
Share on other sites

They are not redundant.  From my work refactoring the Blender python export script, I know it builds different values for them.  I can see where each section had the same vertex count.  The examples are building even sized sections.  The verticesStart really should not be the same.

 

Think that you can get away with it, since the only internal use of these is in refreshBoundingInfo().  These are public members though, so external parts of the framework can reference them.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...