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

### 3 Dimensional Chat / Rotate a plane like a page in a book?

Message
Posted: 23rd Mar 2015 01:14
Hi all,

I want to rotate a plane around its lefthand edge like a page anchored to the spine of a book.

What I have tried so far is the following:

CreateObjectPlane(1,64,64) - this is centered at 0,0,0 on the x,y,z axis.

SetObjectPosition(1,32,0,0) - Move the plane 32 units to the right along the x axis so that the left-hand edge is now at 0.

SetCameraPosition(1,0,0,-500)

SetCameraLookAt(1,0,0,0,0)

do

RotateObjectGlobalY(1,1) - Rotate the object around the global Y axis.

loop

At this point I expected the rotation around the global Y axis to give me the effect I'm looking for, but for some reason it still seems as if the plane is rotating around its own local axis.

What have I overlooked?

Thanks.

//******************************
// Coding In BASIC using AppGameKit V2
//******************************
Posted: 24th Mar 2015 11:54
Your almost there - but you have to think in terms of limbs.

When you create your plain, it's offset is at 0,0,0 so you would only ever rotate it around that offset. But when you create a plain, your actually creating an object and a limb - any mesh attached to an object is a limb, and limbs can be offset separately.

So, make your 64x64 plain, but then offset limb 0 to 0,0,32 or something like that - and then when you rotate the object, it'll rotate on the edge. You can rotate the limb as well, but for your needs just offsetting and rotating the whole object should give the effect you want.

One other thing to consider with this - you could use an object for the page, and have an actual bend in it. I did this with a virtual book in an AppGameKit project, then just scaled the page to flatten it, or flip the bend the other way. I have 2 halves of a book and a single page, and I open the book and flick between the pages - it's a pretty neat effect and no complex animation really. I use text files which are loaded and rendered to memblock images, so to add a book to my game I just need a text file, works a bit like Oblivion/Skyrim, but with a fully 3D virtual book.

I am the one who knocks...
Posted: 25th Mar 2015 23:14
Thank you for your help Van B.

I've been reading the chapter on 3D in Hands On AppGameKit BASIC, I don't see any reference to limbs in it, and there is no mention of limbs in the online help section for 3D either - http://www.appgamekit.com/documentation/Reference/3D.htm

Could you elaborate a little on their usage and post a small snippet of code to point me in the right direction?

Thanks.

//******************************
// Coding In BASIC using AppGameKit V2
//******************************
Posted: 26th Mar 2015 15:05
Ahh, this is AppGameKit - which your right, has no limbs - I assumed DBPro.

Anyway it's all good, instead of creating an object and offsetting the limb, AppGameKit works differently. Each object is just 1 single mesh, so any animation has to be done with code - might sound horrible but AppGameKit also has several object movement and rotation functions. Like - if you position an object at the required pivot point, you can just move the object each time, which is the equivalent of using a limbs offset.

I will make a small demo to show what I mean - but if you'd like to make a virtual 3D book thing I'd be happy to help.

I am the one who knocks...
Posted: 29th Mar 2015 00:07
Thanks Van B, A demo would be appreciated.

Upon further reading of the Hands On AppGameKit Book my mistake becomes clear:

RotateObjectGlobalX(), Y(), or Z() rotates an object around its own inertial axis - an axis local to the object that is not affected by the object's orientation. These inertial axis always remain parallel to the world axis.The word Global in the function name is a little confusing.

I don't see any commands listed in the book's index for rotation around the world axis.

//******************************
// Coding In BASIC using AppGameKit V2
//******************************
Posted: 7th Apr 2015 12:51
Sorry I haven't got this to you yet - I will try and get round to it tonight or tomorrow.

I am the one who knocks...
Posted: 8th Apr 2015 02:13
Something like this maybe?

+ Code Snippet

You could also look at using the RotateObjectLocal/Global commands depending on what you're trying to do.

The other option is to make a plane in a 3D program and centre it on one the edges before exporting it.