Author Topic: Mapping image to texture, but image shows upside down  (Read 197 times)

Javier Cerdas   «   on: August 06, 2012, 11:06:05 PM »
I was wondering if you guys could help me out.  I have a model, and I'm trying to apply an image (someone's face shot) to the model, by replacing a texture.  I have all that in place, but for some reason, my image is upside down on the model... How can I rotate the texture so it displays correctly?  or is there something I need to do before swapping the texture?  Thanks for any help.  

Ivan Vodopiviz   «   Reply #1 on: August 07, 2012, 10:09:54 AM »
Hi,

Could you please give us a little more detail? How are you changing the texture? Are you capturing the new image from a camera or is it just a file?

Cheers,

Javier Cerdas   «   Reply #2 on: August 07, 2012, 01:28:42 PM »
Sure.  Right now I'm loading it from a file... eventually it will be from the camera.  

Also, I just realized it's not upside down, it's just on the side of the model... let me explain.  The model is a dog (like a cartoon dog, think scooby doo), my image is loading on the head, but it's not upside down like I thought, it's just in the wrong direction.  The picture is of my son, and his nose is showing up on the right ear of the dog.  So when I rotate the dog, I can see that the picture was place on the side.  Why is this?  Obviously I'm a very beginner type of 3D user hahaha  so thank you for the patience and help.

Here's the code, which is a mix&match from the tutorial files:

public function Test() 
{         
    // stage configuration.
    stage.scaleMode = StageScaleMode.NO_SCALE;
    stage.align = StageAlign.TOP_LEFT;
    
    // creates a new 3d scene.
    scene = new Viewer3D( this );
    scene.camera = new Camera3D( "myOwnCamera" );
    scene.camera.setPosition( -20, 20, 5);
    scene.camera.lookAt( 0, 0, 0 );
         
    // add global scene progress and complete events.
    scene.addEventListener( Scene3D.PROGRESS_EVENT, progressEvent );
    scene.addEventListener( Scene3D.COMPLETE_EVENT, completeEvent );
    
    // loads the objects.
    sample_model = scene.addChildFromFile( "../resources/dog.f3d" );
   picture_texture = scene.addTextureFromFile( "../resources/testImage.jpg" );
         
     // this prevents to flare3d to start render before the objects are completly loaded.
    scene.pause();
}

private function completeEvent(e:Event):void 
{
    // once the scene has been loaded, resume the render.
    scene.resume();
      
    // start to update the scene.
    scene.addEventListener( Scene3D.UPDATE_EVENT, updateEvent );
         
}
      
private function updateEvent(e:Event):void 
{
    if ( Input3D.keyDown( Input3D.UP ) ) 
    {
      var mesh:Mesh3D = (
sample_model.getChildByName("Head") as Mesh3D);
      var surface:Surface3D = mesh.surfaces[0];
            
      var shader:Shader3D = surface.material as Shader3D;
            
      shader.filters[0].texture = 
picture_texture;
    }
}

Ivan Vodopiviz   «   Reply #3 on: August 08, 2012, 11:50:53 AM »
Could you post a screenshot? Your code looks fine, actually. The problem is that the texture isn't appearing in the right place?

Javier Cerdas   «   Reply #4 on: August 10, 2012, 01:56:55 PM »
Yes, correct.  The texture is just not in the right place.  Please see screenshot:

Screen2

Javier Cerdas   «   Reply #5 on: August 10, 2012, 01:57:46 PM »
And here's another angle... you can see my son's nose on the side of the head...  again, not the best model to use for this, but I think it conveys the problem haha

Screen 1

Ivan Vodopiviz   «   Reply #6 on: August 10, 2012, 03:50:59 PM »
I'm afraid those images are set as private in your flickr account... I can't see them...

Javier Cerdas   «   Reply #7 on: August 13, 2012, 05:02:47 PM »
Ahh, sorry about that... just set them to public.  You should be able to see them now.  By the way, thank you so much for spending time trying to help me with this.

Ivan Vodopiviz   «   Reply #8 on: August 14, 2012, 10:57:23 AM »
No problem :)

Those screens are really small, I'm afraid I don't really understand them. But anyway, does the model mesh have correct UV coordinates?

Javier Cerdas   «   Reply #9 on: August 16, 2012, 04:59:08 PM »
Thanks. Sorry about the size.  Regarding your question, I have no idea... it's a 3ds model I downloaded from the web (I'm not a 3d modeler, so my knowledge of the tool is very limited)  I'll see if I find a tutorial on how to check the uv coordinates with 3ds.... sounds like that would be the issue here.  Thank you.