Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / [SOLVED] How to reverse/flip 3D model using memblock?

Author
Message
Scribble
6
Years of Service
User Offline
Joined: 2nd Apr 2017
Location:
Posted: 10th Aug 2020 03:56 Edited at: 5th Nov 2021 11:54
Hello everybody. I have a question regarding vertex manipulation using memblock.

Let's say I have a plane object created:

planeobj = CreateObjectPlane( 2 , 2 )

I want to reverse the 3D plane object so that the vertex position is reversed left/right compared to the original object, so that the resulting new plane sort of 'mirror' the old object sidewise.
Another way to put it, I want both object to be textured with a same image, but the second (manipulated) object to be mirror image of the first object sideways (x-axis).

Can we do this in AppGameKit using memblock? May I ask for a short example code on how to do this?

Thanks in advance. All help is appreciated.

The author of this post has marked a post as an answer.

Go to answer

SFSW
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 10th Aug 2020 05:21
This post has been marked by the post author as the answer.
Here is one way to flip a plane's vertex data or UV horizontally (X/U). Simply rem and unrem the desired lines to perform either operation.



Flipping the vertex on X will likely still result in the same texture appearance, but lighting will change. So if you're trying to mirror the texture/surface details of a plane, then you may want to just flip the UV as its easier and will probably achieve the effect you are after (mirror effect in appearance).
Scribble
6
Years of Service
User Offline
Joined: 2nd Apr 2017
Location:
Posted: 10th Aug 2020 07:28 Edited at: 5th Nov 2021 11:54
Thank you SFSW. That works.

Flipping the UV seems to work perfectly for this purpose.
Flipping the vertex alone doesn't seems to flip the texture along with it, as you said.

Previously I failed because I've used wrong vertex number. I thought a plane only have 4 vertex. But it seems after checking the memblock, AGK-generated planes have 12 vertex.

Thanks again.

Login to post a reply

Server time is: 2024-03-28 22:09:49
Your offset time is: 2024-03-28 22:09:49