Viewpoint Developer Central    Viewpoint Forums    Viewpoint Forums  Hop To Forum Categories  JavaScript    Not Saving Diffuse Color

Moderators: e_phoenix13
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Member
Posted
I am loading an object and on load it is calling the following function.. the problem is it loads, it loads the texture, and i see the correct color for a split second before it goes back to the objects base color.

function doneLoading() {
vmp.SetProperty('MTSMaterial.colorArea, 'difc', newDIFC);
vmp.SetProperty('MTSTimeElem.textureReplace', 'Path', "test.jpg", 'mts_str');
vmp.SetProperty('MTSTimeElem.textureReplace', 'trgr', '1', 'mts_int');

}

I thought this was because it wasn't loaded all the way.. but the strange thing is it keeps the new texture, just resets the color.
 
Posts: 48 | Registered: April 17, 2006Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of Admin
Posted Hide Post
Hi Shawn,

Without seeing the project directly, I'm not sure if this will help, but try re-rendering the scene:

function doneLoading() {
vmp.SetProperty('MTSMaterial.colorArea, 'difc', newDIFC);
vmp.SetProperty('MTSTimeElem.textureReplace', 'Path', "test.jpg", 'mts_str');
vmp.SetProperty('MTSTimeElem.textureReplace', 'trgr', '1', 'mts_int');
vmp.SetProperty('MTSScene','nerd',1,'mts_int');
}

Let me know if that by chance helps. If not, we'll figure something else out.
 
Posts: 1188 | Registered: January 08, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Posted Hide Post
Its almost like when the texture finishes loading it resets the color... is there a way to throw an event when the texture finishes loading?
 
Posts: 48 | Registered: April 17, 2006Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of Admin
Posted Hide Post
Shawn,

I'm a little confused. In your code, it looks like you are setting a new diffuse color as well as assigning a diffuse texture. You cannot have both, only diffuse color or diffuse texture. Could you clarify? Smile
 
Posts: 1188 | Registered: January 08, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Posted Hide Post
The diffuse color is being applied to the back of the object while the texture is being applied to the front of the object.

I know it can be done because if I look the set diffuse color function up to a button and wait until after it is done loading the texture and everything to click it the diffuse color works fine.
 
Posts: 48 | Registered: April 17, 2006Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of Admin
Posted Hide Post
Since it works that way, have you tried waiting until after it is done loading the texture and everything before you call your function in javascript?
 
Posts: 1188 | Registered: January 08, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Posted Hide Post
no.. I am not sure how to have the texture throw a done event when it is done loading a new texture.
 
Posts: 48 | Registered: April 17, 2006Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of Admin
Posted Hide Post
When you load the new object using MTSLoadMTX and put an MTXDoneEvent at the end of the loaded object's mtx, it should not post the MTXDoneEvent until the object, textures, and all are finished loading.

If this is not working (or is not the exact way you are loading the object), try using a delay when the object is finished loading (look up "Delay" in the MTX code reference http://developer.viewpoint.com/dc/xml.shtml).

Something like this:

<MTSInteractor>
<MTSHandle Event="myDoneEvent" Action="MTSJavaScript" Func="doneLoading()" Delay="0.4" />
</MTSInteractor>

This will delay calling the javascript function that changes the textures for 0.4 seconds.
 
Posts: 1188 | Registered: January 08, 2003Reply With QuoteEdit or Delete MessageReport This Post
Member
Posted Hide Post
I did something like that with the javascript delay function... I am just worried that depending on connection speed this could cause problems.
 
Posts: 48 | Registered: April 17, 2006Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of Admin
Posted Hide Post
Shawn,

MTSLoadMTX with MTXDoneEvent should work properly. The MTXDoneEvent should not fire until the new MTX is fully loaded (textures and all). If this is not working, my only suggestions are to use Delay, which you are right could vary depending on CPU speed, or somehow sending me an example that I could debug.

Regards
 
Posts: 1188 | Registered: January 08, 2003Reply With QuoteEdit or Delete MessageReport This Post
  Powered by Eve Community  
 

Viewpoint Developer Central    Viewpoint Forums    Viewpoint Forums  Hop To Forum Categories  JavaScript    Not Saving Diffuse Color