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.

Author
Message
JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 11th Jan 2012 03:43 Edited at: 11th Jan 2012 04:27
Hey guys, well here is my problem. I am trying to convert a cube to a sphere and still keep the cube like qualities so that I can map a texture to it better. I have been all over this forum and the help that is here was no help at all.





This is the code for a start, now how would I convert this cube into a sphere. I do NOT want to call the sphere command just to create a sphere. It defeats the whole purpose here.

Am I going to need to create actual vertices instead of using the cube as an object if I am wanting to patch in LOD chunks to this ? I am trying to solve this before I get half way into my work to realize I have to start all over.

My end goal is to make a Procedural planet and the idea is to see more detail the closer to the planet I get. But to do that I need to setup the cube to sphere first.


EDIT : I think this is what I am looking for.. but how to implement it I am unsure of yet --> CUBEMAP. Am I supposed to make a sphere, and then apply a Cube Patch of some sort ?

"Life is like a box of chocolates.. eat it before it melts."
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 11th Jan 2012 13:01 Edited at: 11th Jan 2012 13:02
I've been looking into ways of doing that for some time now and recently acquired a paper on cubemapping a spherical object. As noisemaps and positioning is greatly enhanced. I've found some code but as of yet not started looking into it.

If I come up with something I'll let you know as soon as. My first attempts at this failed miserably.

Using DBP you're most likely to want to use IanM's Matrix1 command MakeObjectNew and create the vertices manually.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 11th Jan 2012 13:05
Quote: "Using DBP you're most likely to want to use IanM's Matrix1 command MakeObjectNew and create the vertices manually."


I was just thinking about that in fact. CUBEMAP is wrong as I am not trying to reflect anything.

So I'm at a loss now since I'm not a math genius anymore. lol

Making the cube into a planet.. not easy.

"Life is like a box of chocolates.. eat it before it melts."
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 11th Jan 2012 13:13
Cube UV mapping a sphere is the way to go as reading and writing positions with the calculations within the paper I've been reading through is the right way according. I'm no maths genius either but this tinterweb lark has taught me an awful lot.

It'll also be better for creating procedural textures as there's a 3d perlin noise (not just 2d) that can be placed seamlessly on a cube map for planet textures, bump mapping, heights, etc. I've yet to experiment with it but it does cut out the pinching produced by a plane texture.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 11th Jan 2012 13:39 Edited at: 11th Jan 2012 13:39
uhgg and from our other conversations you have to be a math genius to do it since there are no commands in DBP on how to do this. No wonder no one else has figured this out.

"Life is like a box of chocolates.. eat it before it melts."
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 11th Jan 2012 13:46 Edited at: 11th Jan 2012 14:13
Why not just edit the vertexdata:
1-Get each vertex x,y,z
2-Get a unit Vector to the vertex
3-Reposition the vertex at radius*unitvectors out from the centre

Sounds a little simpler than it is but it might just work...

EDIT: You'd have to use a cube with more vertices than a standard DBP primitive though...

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 11th Jan 2012 14:08 Edited at: 11th Jan 2012 14:09
Quote: "Why not just edit the vertexdata:"


baxslash has the right solution.


Quote: "uhgg and from our other conversations you have to be a math genius "


That's not to difficult....take a look to this sphere to cube morphing code, and try to do the same from cube to sphere( the cube is not a real cube....is just an sphere manipulated with vertextada that will grow up to became a sphere. I hope this code help someone.




Cheers.



I'm not a grumpy grandpa
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 11th Jan 2012 14:12 Edited at: 11th Jan 2012 14:14
Attached is my own version... but starting with a cube I just made. Beat me to it chafari!



EDIT: ...and the code:


chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 11th Jan 2012 14:24 Edited at: 11th Jan 2012 14:30
@baxslash

That's great. Your example is more elaborated....I just make my example on the fly

Cheers.

I'm not a grumpy grandpa
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 11th Jan 2012 14:28
Well, to be fair my code is adapted from some scaling code by "David W"... whoever he is

I did have to make a new cube in sketchup to make it work. I don't think there's a simpler way of making a cube like that.

JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 11th Jan 2012 14:33
that is brilliant guys.. thank you both for this..

I originally got the idea from this website :

http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html

But again.. not a math genius any more. I used to eat algebra in my sleep. Now I dream of the day I can grasp it again.. hahaha

Again, BIG ty to you both !!!

"Life is like a box of chocolates.. eat it before it melts."
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 11th Jan 2012 14:36
Glad to help

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 11th Jan 2012 21:11
Nice idea!

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 11th Jan 2012 21:33
Nice! Very cool...

Now it's adapting the code to fit the requirements...

(Can't believe it's just that amount of code for something so big and idea)

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 11th Jan 2012 23:40 Edited at: 11th Jan 2012 23:40
Well if what WLGfx and I are doing works, we can make a cubic sphere without needing a mesh. We been both working together on designing one that can be made without needing DATA in the code. But one that we can do on the fly to make the cube. We already have a working cube made from Verts. Now we are going back and forth on how to make it dynamic and convert it to sphere from there.

Its a lot of work, but now that we had an idea from baxslash and chafari, we can finally do this. After we get this part done, I am going to be able to work in the code to convert this sphere to handle heightmapping and from there zoom in from space to planet as if your flying into the land itself from space. Like you see on this video :

https://www.youtube.com/watch?v=0bQz5ugtfLY

"Life is like a box of chocolates.. eat it before it melts."
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 12th Jan 2012 00:50 Edited at: 12th Jan 2012 00:51
Grrr. Sidetracked again, but at least this will complete something that I failed miserably to figure out sometime ago.

I'll start this tomorrow morning when my brain cell is fresh.

1. Create 6 seperate subdivided faces and set verts UV coords.
2. Spherise each face (prob in just 3 loops hopefully)
3. Optimise mesh by removing duplicated verts but keeping edge verts. "re-ka-jigging" indices.
4. Use that amazing command SET OBJECT NORMALS... he he "jobs a guddun"

Alright, object will have 6 limbs I'm guessing. I'm googling a bit more on this...

Darn it, hate having to think lots and lots... I'm real bad when it comes to maffs...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 12th Jan 2012 01:12 Edited at: 12th Jan 2012 01:28
Quote: "I'll start this tomorrow morning when my brain cell is fresh"


I'm the same boat....I can't find the correct solution to rotate texture...I'v been googling and tried to translate some c++ code, but all I can do, is rotate image 70ª....so I need to make four function . What I want is to be capable of rotate texture 360º just in one funcion.

That is what I have so far



Does someone know a good funtion to rotate object texture ??



Cheers.

I'm not a grumpy grandpa
JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 12th Jan 2012 01:44
Isn't it like rotate sprite ? Which can rotate any image 360 degrees ?




"Life is like a box of chocolates.. eat it before it melts."
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 12th Jan 2012 01:48
Not exactly....we can paste sprite or and get a new image rotated, but what I need, is to rotate texture, and when we save the object as dbo, the object will have the texture rotated.

Cheers.

I'm not a grumpy grandpa
JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 12th Jan 2012 02:53 Edited at: 12th Jan 2012 02:54
Yea, even Rotate Image is in the HELP list, but when you go to compile it shows up as an obsolete command. I wonder why it was removed ?

"Life is like a box of chocolates.. eat it before it melts."
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 12th Jan 2012 03:26
There is likely to be a fancy mathematical solution; but I can only think up a long winded one.

Save the cube object and open it up in a 3D editor; adjust the UVs manually. Export that then load it back into DBPRO then use the new UVs location as a reference for the transition; curve animate the UVs to and from the cube and sphere locations.

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 12th Jan 2012 09:19
Image kit has this command:
IK Paste Image On Image Rotated Image Number, X, Y [, Angle]

Maybe that could help?

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 12th Jan 2012 11:17
I was assuming that with it being a cube mapped sphere then it would need 6 textures for each face. Also the end result would need 6 limbs.

I'm also thinking of using 3d noise to create a planet surface texure on the cube map which can also be used for bump mapping for distance LOD. On another forum post someone had come up with converting a standard texture to a normal map.

Image Kit is probably going to be need with this or some more maffs.

Watching Xena Warrior Princess then I'll see what I come up with.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 12th Jan 2012 13:49 Edited at: 12th Jan 2012 14:08
Quote: "Save the cube object and open it up in a 3D editor"

Yeah...that is obvious, but I need to rotate image in the same 3D program I'm programming, like Mapscape.


Quote: "Image kit has this command:
IK Paste Image On Image Rotated Image Number, X, Y [, Angle]"



The problem is not rotating image....is not the same ROTATE IMAGE and ROTATE TEXTURE

If we rotate the image with any plug in and we apply it to the object, the texture in the object will keep the correct zero angle, so we need to rotate texture directy with vertexdata of the object to save it with the texture rotated. I'v got it nearly done but I know that there's something wrong.

This piece of code shows what I mean. we can save the object to dbo and we can load it again and when we give texture to the object, the texture will be rotated.

I have to put this into a function, to change on the fly the angle of the texture in real time. Use any image you have to test.



Cheers.

I'm not a grumpy grandpa
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 12th Jan 2012 17:06 Edited at: 12th Jan 2012 17:09
Quote: "Yeah...that is obvious, but I need to rotate image in the same 3D program I'm programming, like Mapscape."


Right. A 3d editor.

The UV coordinates can be rotated by PivotPointU + ( Sin( Angle# ) * Distance# ) : PivotPointV + ( Cos( Angle# ) * Distance# )

You probably know how to get the distance from the pivotpoint coordinate and the UV coordinate. In general the pivot point can be the middle (0.5,0.5)

Surely this has got to work, a coordinate is a coordinate, be it UV, pixel or 3d space; coordinates can get rotated from each other.

Otherwise, where are the trig gurus...

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 12th Jan 2012 20:23


That's what I meant ...we can rotate texture fro 0 to 1 and then we have to use other function to start again. I just can rotate from 0 to 90º when the texture is in 90º I have to fix texture like if it 0 and rotate again .

Cheers.

I'm not a grumpy grandpa

Login to post a reply

Server time is: 2026-07-10 08:27:34
Your offset time is: 2026-07-10 08:27:34