This is G o o g l e's cache of http://www.flashsandy.org/forum/index.php?showtopic=575 as retrieved on 11 Aug 2007 04:19:35 GMT.
G o o g l e's cache is the snapshot that we took of the page as we crawled the web.
The page may have changed since that time. Click here for the current page without highlighting.
This cached page may reference images which are no longer available. Click here for the cached text only.
To link to or bookmark this page, use the following url: http://www.google.com/search?q=cache:ftDbvNaaW1MJ:www.flashsandy.org/forum/index.php%3Fshowtopic%3D575+site:www.flashsandy.org/forum&hl=en&ct=clnk&cd=92


Google is neither affiliated with the authors of this page nor responsible for its content.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> setUVCoordinates() has no effect, ...on faces. The texture mapping stays the same.
kwuntong
post Jul 3 2007, 01:28 PM
Post #1


Member
**

Group: Members
Posts: 15
Joined: 17-June 07
Member No.: 1,253



Hi!

I already issued this question there: http://www.flashsandy.org/forum/index.php?showtopic=569

But since I haven't received an answer there, and the question is now concentrating on setUVCoordinates(), I thought it is good to start a new thread, so here we are: (IMG:style_emoticons/default/smile.gif)

I try to rotate textures in 90degree steps on faces. The setUVCoordinates() method should be a very convenient way, but it just has no effect in all my tests. I looked at the source in TriFace3D.as and it is basically just:

CODE
    public function setUVCoordinates( a:UVCoord, b:UVCoord, c:UVCoord ):Void
    {
        aUv.push(a, b, c);
    }


So let me make this clear: I don't want to setup a new Object3D. I want to modify an exisisting Box. The method is just pushing the UVCoords! That cannot work, can it? (IMG:style_emoticons/default/huh.gif)

In another test, I also wrote manually into TriFace3D.aUv, but it is the same: No visual update happens. Even if I issue calls like

CODE
    faces[0].refresh();
    
    box.setModified();
    box.refresh();    
    box.render();    


Is sth. broken in Sandy? I am using Sandy1.1 BETA

Thanks a lot,
kwuntong






User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Petit
post Jul 3 2007, 06:28 PM
Post #2


Advanced Member
***

Group: Moderator
Posts: 588
Joined: 21-June 06
From: Borgholm, Sweden
Member No.: 38



QUOTE(kwuntong @ Jul 3 2007, 01:28 PM) *

Hi!
I try to rotate textures in 90degree steps on faces. The setUVCoordinates() method should be a very convenient way, but it just has no effect in all my tests. I looked at the source in TriFace3D.as and it is basically just:

I don't know if somthing is broken in Sandy 1.1 when it comes to changing UV coords, or refresh or set modified, but I don't feel that changing the UV Coord is the right ( or easy ) way to go.

Now that your question seems a bit clearer to me, I'd suggest the following:
For each image, create foour different skins with the image rotated.
You can do this by loading the image into a MovieClip, then rotating it in steps of 90 degrees and for each position drawing it into a BitmapData using its draw() method, with the extra matrix parameter to honor the rotation. Each bitmap is then used in a TextureSkin.
When you need to rotate an image, you just pick out the faces you want to change and set skin_1, skin_2 etc on them.

If you had embedded images, it wuould be much simpler to create a Movieclip for each, whith four frames, and for each frame rotate the image 90 degrees. You could then use sucha a Movieclip in a MovieSkin.
Each time you needed to rotate the image, you'ld only have to call yourMovie.gotoAndStop( n ).

Good luck!
/petit
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
kwuntong
post Jul 3 2007, 10:10 PM
Post #3


Member
**

Group: Members
Posts: 15
Joined: 17-June 07
Member No.: 1,253



QUOTE(Petit @ Jul 3 2007, 08:28 PM) *

For each image, create foour different skins with the image rotated.


Hi Petit,

Once again, thank you very much for you quick help. (IMG:style_emoticons/default/rolleyes.gif)

The way you describe would work perfectly. The only problem is, that I have to determine the orientation of the texture on the Face dynamically. (IMG:style_emoticons/default/unsure.gif)

I need a function like this

CODE


function setSkinDirectionByFaces(newSkin:Skin, face1:Face, face2:Face):Void{

// set skin on face1 and orient upper side of skin towards the (neighboring) face2

}


That means, calling:

CODE

setSkinDirectionByFaces(mySkin, frontFace, topFace);


Should place mySkin on the frontFace and orient it towards topFace, while e.g.

CODE

setSkinDirectionByFaces(mySkin, frontFace, rightFace);


should orient it towards rightFace, which is, as the name implies, right of front face within my Box.

@Petit: Can you imagine a way, how to create the described functionality using MovieClip rotation?


I thought, setting UVCoords would be a good idea, because it uses little memory (and I have to prepare the BitmapData at runtime, quickly after user input!) and I hoped that I could use information about the shared Vertex points of face1 and face2 somehow to realise the described functionality, i.e. "finding" the direction. (IMG:style_emoticons/default/cool.gif)

But I cannot try it, because setUVCoordinates() apparently only works for generating geometry, but not for updating it. (IMG:style_emoticons/default/ohmy.gif)

Thanks a lot,
kwuntong
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Petit
post Jul 4 2007, 02:55 PM
Post #4


Advanced Member
***

Group: Moderator
Posts: 588
Joined: 21-June 06
From: Borgholm, Sweden
Member No.: 38



QUOTE(kwuntong @ Jul 3 2007, 10:10 PM) *

@Petit: Can you imagine a way, how to create the described functionality using MovieClip rotation?

But I cannot try it, because setUVCoordinates() apparently only works for generating geometry, but not for updating it. (IMG:style_emoticons/default/ohmy.gif)

On the first point I'm sorry to say I have no immidiate answer, and for the moment no resources to try anything.

On the second point, I guess only thomas knows how that works. One would certainly expect UV coords update to be possible, as the set UVCoords() is public, if I remember it right.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
kwuntong
post Jul 4 2007, 03:47 PM
Post #5


Member
**

Group: Members
Posts: 15
Joined: 17-June 07
Member No.: 1,253



QUOTE(Petit @ Jul 4 2007, 04:55 PM) *

On the first point I'm sorry to say I have no immidiate answer, and for the moment no resources to try anything.

On the second point, I guess only thomas knows how that works. One would certainly expect UV coords update to be possible, as the set UVCoords() is public, if I remember it right.


I think I will private message him. Hope he is available, since I am running into deadlines here... (IMG:style_emoticons/default/wink.gif)
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
kiroukou
post Jul 4 2007, 10:09 PM
Post #6


Administrator
***

Group: Root Admin
Posts: 913
Joined: 12-June 06
Member No.: 1



Hi kwutong (IMG:style_emoticons/default/wink.gif)

Message received, I'll try to help you during the tomorow morning. Your problem is not that simple and requires some time to think about it (IMG:style_emoticons/default/smile.gif)

I hope to come back with something, maybe during the night who knows ^
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
kwuntong
post Jul 4 2007, 11:17 PM
Post #7


Member
**

Group: Members
Posts: 15
Joined: 17-June 07
Member No.: 1,253



QUOTE(kiroukou @ Jul 5 2007, 12:09 AM) *

Hi kwutong (IMG:style_emoticons/default/wink.gif)

Message received, I'll try to help you during the tomorow morning. Your problem is not that simple and requires some time to think about it (IMG:style_emoticons/default/smile.gif)

I hope to come back with something, maybe during the night who knows ^


Cool, thank you very much, I am really looking forward to it. (IMG:style_emoticons/default/rolleyes.gif)

But, if you are short in time, a little hint on how to use setUVCoordinates() would be a starting point. I could try to figure out a solution then.

But of course, complete concepts for this are highly appreciated. (IMG:style_emoticons/default/laugh.gif)

Bye,
kwuntong
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
kiroukou
post Jul 5 2007, 09:59 AM
Post #8


Administrator
***

Group: Root Admin
Posts: 913
Joined: 12-June 06
Member No.: 1



Hi kwuntong

So here is an idea :
Get the array of uv coords of your face. The UV coords don't need to be changed in my opinion, but jsut their order.
so face.aUV contains 3 elements, if you want to rotate the texture, just change the order :
aUv Array : 0, 1, 2 to something like aUv Array rotated : 1, 2, 0

so you jsut roll the elements inside the aUv Array
Do that for all the TriFaces of your cube side, in the same order.

Now to be sure to disable the cache system that prevent an useless rendering loop, just do :
myCamera.moveforward(0); or something like that.

Hope this helps

Thomas
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
kwuntong
post Jul 5 2007, 11:55 PM
Post #9


Member
**

Group: Members
Posts: 15
Joined: 17-June 07
Member No.: 1,253



QUOTE(kiroukou @ Jul 5 2007, 11:59 AM) *

so you jsut roll the elements inside the aUv Array
Do that for all the TriFaces of your cube side, in the same order.

Now to be sure to disable the cache system that prevent an useless rendering loop, just do :
myCamera.moveforward(0); or something like that.


Hi Thomas!

Rolling the aUv array is a good idea, but I tried it, and I still don't see any feedback to the changes I apply to th UVCoords. myCamera.moveforward(0); doesnt help... (IMG:style_emoticons/default/huh.gif)

What could that be? I have attached my sandbox file for it. Very messy but you will get to it. I am trying to manipulate face[0], which is one half of the "1".

Thanks,
kwuntong

Attached File  boxfaces.fla ( 378.5k ) Number of downloads: 4
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
kiroukou
post Jul 6 2007, 05:40 PM
Post #10


Administrator
***

Group: Root Admin
Posts: 913
Joined: 12-June 06
Member No.: 1



Sorry but I can't open the fla... is it flash CS3?

I usually don't touch flash IDE, and prefer some other kind of editor, so can you provide the source code, or at least your test one (short demo of what you are trying to achieve).

Thomas
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
kwuntong
post Jul 6 2007, 05:53 PM
Post #11


Member
**

Group: Members
Posts: 15
Joined: 17-June 07
Member No.: 1,253



QUOTE(kiroukou @ Jul 6 2007, 07:40 PM) *

Sorry but I can't open the fla... is it flash CS3?

I usually don't touch flash IDE, and prefer some other kind of editor, so can you provide the source code, or at least your test one (short demo of what you are trying to achieve).

Thomas


Oh, I am sorry. Here you have the complete code on frame one. It is a sandbox file, based on a tutorial I found somewhere... If that code worked, I would implement it in my application.

I am calling rotateTexture() once a second. aUvs are rolling (seen in debugger), but I can't see the result on the face.

Thank you very much,
kwuntong



CODE

import mx.utils.Delegate;
import flash.display.BitmapData;
import sandy.core.data.*;
import sandy.primitive.*;
import sandy.core.*;
import sandy.core.face.*;
import sandy.view.*;
import sandy.core.transform.*;
import sandy.core.group.*;
import sandy.skin.*;
import sandy.events.InterpolationEvent;
import sandy.util.Ease;

import de.zellcode.tools.Thread;

var rotint:RotationInterpolator;
var midX:Number = Stage.width/2;
var midY:Number = Stage.height/2;
var backCulling = true;
var isRolling = false;
var box:Object3D;
var cam:Camera3D;

var i:Number = 0;

var rotation:Transform3D; //added

function rotateTexture():Void{

    var faces:Array = box.getFaces();    
    
    
    var token:Object = faces[0].aUv.shift();
    faces[0].aUv.push(token);
    
    cam.moveForward(0);
    
    i++;
    trace(i);
    
}

function start(Void):Void {
    var w:World3D = World3D.getInstance();
    w.setRootGroup(createScene());
    w.addEventListener(World3D.onRenderEVENT, this, onRender);
    var mc:MovieClip = _root.createEmptyMovieClip('screen', 1);
    //public function ClipScreen(mc:MovieClip, w:Number, h:Number, bgColor:Number)
    var screen:ClipScreen = new ClipScreen(mc, 401, 401);
    //public function Camera3D(nFoc:Number, s:IScreen)
    cam = new Camera3D(500, screen);
    //public function setPosition(x:Number, y:Number, z:Number):Void
    cam.setPosition(0, 0, -350);
    //public function addCamera(cam:Camera3D):Number
    w.addCamera(cam);

    //cullingButton.onRelease = switchBackCulling;
    stopButton.onRelease = stop;
    rotint.pause();
    w.render();
    //backCulling = box.enableBackFaceCulling = !backCulling;
    //cullingButton.setLabel ( backCulling ? "Off" : "On" );
}



rotint.resume();
function stop() {
    if (isRolling) {
        rotint.pause();
        stopButton.setLabel("Start");
    } else {
        rotint.resume();
        stopButton.setLabel("Stop");
    }
    isRolling = !isRolling;
}
//public function createScene(bg:Group):Void
//Method to overload in your application.
//In this method you have to create your scene graph and use the argument bg as the tree's root.
function createScene(Void):Group {
    var g:Group = new Group();
    //public function TextureSkin(t:BitmapData)
    //t : The actionScriptLink of the bitmap;
    
    var skin1:TextureSkin = new TextureSkin(BitmapData.loadBitmap("side1"));
    var skin2:TextureSkin = new TextureSkin(BitmapData.loadBitmap("side2"));
    var skin3:TextureSkin = new TextureSkin(BitmapData.loadBitmap("side3"));
    var skin4:TextureSkin = new TextureSkin(BitmapData.loadBitmap("side4"));
    var skin5:TextureSkin = new TextureSkin(BitmapData.loadBitmap("side5"));
    var skin6:TextureSkin = new TextureSkin(BitmapData.loadBitmap("side6"));

    /**
mc_image.img._rotation = 90;

var skin1_bitmap:BitmapData = new BitmapData(mc_image._width, mc_image._height,true);
skin1_bitmap.draw( mc_image, mc_image.transform.matrix );
var skin2 = new TextureSkin(skin1_bitmap);
    */

    var thread:Thread = new Thread(Delegate.create(this, this.rotateTexture), 1000);
    thread.start();

    box = new Box(80, 80, 80, "tri", 1);
    var faces = box.getFaces();
    faces[0].setSkin(skin1); faces[1].setSkin(skin1);
    faces[2].setSkin(skin2); faces[3].setSkin(skin2);
    faces[4].setSkin(skin3); faces[5].setSkin(skin3);
    faces[6].setSkin(skin4); faces[7].setSkin(skin4);
    faces[8].setSkin(skin5); faces[9].setSkin(skin5);
    faces[10].setSkin(skin6); faces[11].setSkin(skin6);

    //faces[9].setSkin(skin); faces[9].setBackSkin(skin);
    // Transforms
    var ease:Ease = new Ease();
    var tg:TransformGroup = new TransformGroup();
    rotint = new RotationInterpolator(ease.create(), 400);
    //public function setPointOfReference(v:Vector):Void
    //Allows you to make your object rotate around a specific
    //position and not anymore around its center. The value passed in
    //argument represents an offset to the object position.
    //It is NOT the real position of the rotation center.
    //v Vector the offset to apply to change the rotation center.
    rotint.setAxisOfRotation(new Vector(2, 0, 1));
    rotint.addEventListener( InterpolationEvent.onEndEVENT, this, loop);
    rotation = new Transform3D();//added
//    rotation.rot( 20, 20, 180);//added
    tg.setTransform(rotation);//changed
    tg.addChild(box);
    g.addChild(tg);
    return g;
}



// Interpolator event handler
function loop(e:InterpolationEvent):Void {
    // we call the redo method of the Interpolator to continue
    e.getTarget().redo();
}
function camMove():Void {
    var cam:Camera3D = World3D.getInstance().getCamera();
    // Moving the camera in and out along its direction of view axis
    if (Key.isDown(Key.UP)) {
        cam.moveForward(5);
    }
    if (Key.isDown(Key.DOWN)) {
        cam.moveForward(-5);
    }
}
function changeRotation(e:InterpolationEvent):Void {
    //rotint.setAxisOfRotation(new Vector(_ymouse-midY, midX-_xmouse, 0));
    rotation.rot( _ymouse, _xmouse, 0); //added
}
function onRender():Void {
    changeRotation();
    camMove();
}
// Get started
start();


User is offlineProfile CardPM
Go to the top of the page
+Quote Post
kiroukou
post Jul 12 2007, 07:58 AM
Post #12


Administrator
***

Group: Root Admin
Posts: 913
Joined: 12-June 06
Member No.: 1



Hi ,

After a look at your code, it seems ok to me. I can't understand why there's no visual update. I have to say that the 1.1 and even the 1.2 versions are very far in my mind, since I'm working on new versions for a while now.

The 1.2 is a little bit faster and quite robust too. The API hasn't changed a lot (check the FAQ). This migration can be considered for you.

Otherwise word well :
if your texture rotation function, you trace the i variable, is the output ok? Can you also trace more information about the face, the UVCoord you shift, the array size etc.

(I'm sorry, donc have the time to test directly myself, I've a deadline here which is very close...)
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
kwuntong
post Jul 12 2007, 11:46 AM
Post #13


Member
**

Group: Members
Posts: 15
Joined: 17-June 07
Member No.: 1,253



Hi kiroukou,

Thanks for your reply. I will give 1.2 a try in my sandbox, then.

I was inspecting the face's UV coords with the XRay inspector and I saw the UVs rolling - well, without visual feedback on the face as mentioned.

It is absolutely ok that you don't run the code, of course.

Any other ideas, why those updates aren't visible? More caches? Other events to trigger refresh?

Thanks and I am looking forward to the stable AS3 version, (IMG:style_emoticons/default/rolleyes.gif)
kwuntong


User is offlineProfile CardPM
Go to the top of the page
+Quote Post
kiroukou
post Jul 12 2007, 11:57 AM
Post #14


Administrator
***

Group: Root Admin
Posts: 913
Joined: 12-June 06
Member No.: 1



Hum after a fast look at the code...

After the texture coords rolling, try to add this :

faces[0]['tMat'] = undefined;
or
delete faces[0]['tMat'];

(IMG:style_emoticons/default/wink.gif)
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
kwuntong
post Jul 16 2007, 07:26 AM
Post #15


Member
**

Group: Members
Posts: 15
Joined: 17-June 07
Member No.: 1,253



That worked! (IMG:style_emoticons/default/biggrin.gif) Also for Sandy 1.1

Thank you very much,
kwuntong
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

- Lo-Fi Version Time is now: 11th August 2007 - 03:57 AM
phpMyVisites