Jump to content

Loaded Object Always Flat Shaded


Pryme8
 Share

Recommended Posts

I will try the normal recalculate.  EDIT** Ive tried several ways to do this none with any effect, can you give me and example of what you mean maybe Im going about it differently.


Does anyone have a good reference for the structure of an fbx file?  I want to add fbx and c4d support to the object importer.


 

1.jpg

2.jpg

Link to comment
Share on other sites

wk.tools.modelPrep.loadModel = function(target, cse){
	
	
	if(!target || !cse ){return false;}
	this._target = target;	
	this._cse = cse;
	
	var loader = this._cse._scene.loader;
	var file = this._target.files[0];
	console.log(file);
	
	var newload = loader.addMeshTask("newModel", "", "./files/test_model/", file.name);
	
var parent = this;

	newload.onSuccess = function (task) {
			$.each(task.loadedMeshes, function(i,e){
				e.renderingGroupId = 2;
				
			});
			
			buildObjectList(task.loadedMeshes, parent._cse);
		};
	
		loader.load();

it also seems once I apply a new material to the object and change its diffuse color nothing seems to be happening? even though if I look at my scene object and mesh object everything is right. ***EDIT correction the colors do work, I was just making one too close to the default

Textures seem to work though, weird... anyways once I can fully figure out why they look like that I can wrap up this tool, but till then im finishing up the features like physics rigging, and animations then and object sterilizer that gets ran through my proprietary compression algorithm, and saved as a .kong file which has a loader that will put what ever you built into your scene with one string call, textures, riggins, animations, controls ect... with a built in CORS loader tailored for github, so you can host your kong files there...

Link to comment
Share on other sites

So, recalculating normals:

var positions = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);
var normals = mesh.getVerticesData(BABYLON.VertexBuffer.NormalKind);
BABYLON.VertexData.ComputeNormals(positions, mesh.getIndices(), normals);

Dunno if it will work, have no idea how the mesh is constructed. Which can also be the problem.

About the material not being applied, it would be great to see a live example to understand what's going on there.

Link to comment
Share on other sites

$.each(task.loadedMeshes, function(i,e){
				e.renderingGroupId = 2;
				var positions = e.getVerticesData(BABYLON.VertexBuffer.PositionKind);
				var normals = e.getVerticesData(BABYLON.VertexBuffer.NormalKind);
				BABYLON.VertexData.ComputeNormals(positions, e.getIndices(), normals);
			});

did not do anything :-(... well I would like to show you a live demo but unfortunately I am not trying to put these scripts online yet for licensing reasons.

Link to comment
Share on other sites

nope there is a light in my scene, it just seems like the normal are not being calculated correctly or something... maybe I need to have a normal tag on my obj in c4d for when I export it?

**Edit, ok  I have done everything I can think of... Ive recalculated the normal's, Ive reversed them (in bjs and in c4d), Ive added lights tried different methods... Im now coming to the conclusion that there is something happening in the obj import process..

https://doc.babylonjs.com/tutorials/Lights

but it still looks like they calculate like back faces no matter what i do.

Link to comment
Share on other sites

                var positions = e.getVerticesData(BABYLON.VertexBuffer.PositionKind);
                   var indices = e.getIndices();
                var normals = e.getVerticesData(BABYLON.VertexBuffer.NormalKind);
                BABYLON.VertexData.ComputeNormals(positions, indices, normals);
                   e.updateVerticesData(BABYLON.VertexBuffer.NormalKind, normals, true, true);
                BABYLON.VertexData.ComputeNormals(positions, e.getIndices(), normals);

fixed it

 

thank you.

 

example.jpg

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...