Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, VoroneTZ), 396 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 4 of 5 1 2 3 4 5
Re: From a simple 3D Sphere to a real-size Planet. Need help! [Re: joao13pt] #423157
05/24/13 19:18
05/24/13 19:18
Joined: Mar 2013
Posts: 30
Portugal
J
joao13pt Offline OP
Newbie
joao13pt  Offline OP
Newbie
J

Joined: Mar 2013
Posts: 30
Portugal
I've been checking this website that shows how to convert a cube to a sphere, and, the result was this algorithm:

Code:
function cube_to_sphere(ENTITY* model) 
{
	
  int i = ent_status(model,0); 
  for (; i>0; i--) 
  {    														 
  	CONTACT* c = ent_getvertex(model,NULL,i);   
  	c.x = (c.x * (sqrt(1 - ((c.y^2)/2) - ((c.z^2)/2) + (((c.y^2)*(c.z^2))/3))));
  	wait(2);
  	c.y = (c.y * (sqrt(1 - ((c.x^2)/2) - ((c.z^2)/2) + (((c.x^2)*(c.z^2))/3))));
  	wait(2);
  	c.z = (c.z * (sqrt(1 - ((c.x^2)/2) - ((c.y^2)/2) + (((c.x^2)*(c.y^2))/3))));
  	wait(2);
  	c.v = NULL;   // set c.v to NULL to change c.x,y,z 
  	ent_setvertex(model,c,i); 
  	wait(4); 						 
  	}


}



The math in c.x, c.y and c.z comes from this image found in the website previously mentioned, and the result was waaaaay to horrific for me to post pics here, basically, each of the cube's 768 vertices were scattered around the level
I even added some wait() functions to slow the process down, thinking it could be the math "happenning" too fast, but the result was still awfull
Im a little tired to think where i made the mistake, i've been failling this algorithm for transforming a cube to a sphere for about a month, and now i really think i need extra help
Thanks in advance!

Re: From a simple 3D Sphere to a real-size Planet. Need help! [Re: joao13pt] #423163
05/24/13 19:54
05/24/13 19:54
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
you have a little problem here with math:
c = c with normalized x
c = c with normalized y
c = c with normalized z
so you don't normalize the vector itself but each of the components. this results in a weird shape. just use vec_normalize(c.x, 1); here instead of the whole normalization code


Visit my site: www.masterq32.de
Re: From a simple 3D Sphere to a real-size Planet. Need help! [Re: MasterQ32] #423193
05/25/13 13:18
05/25/13 13:18
Joined: Mar 2013
Posts: 30
Portugal
J
joao13pt Offline OP
Newbie
joao13pt  Offline OP
Newbie
J

Joined: Mar 2013
Posts: 30
Portugal
Didn't work aswell..
i don't think you understand what im trying to achieve
So, i have an actuall cube model, it has 768 faces in total
I want to convert each of it's vertices's (x,y,z) values that make it have the shape of a cube, into values that form a sphere
basically i want to wrap this cube into a sphere
Thus that whole complicated math
using vec_normalize(c.x, 1) and doing the same for c.y and c.z isn't helping, because im not actually telling the program to turn it into a sphere, im just reducing it's size
Please explain the whole process to me, i'd be very gratefull, something is missing in my way of thinking and it's driving me crazy
Thank you


----------------------------- EDIT -------------------------
Exactly 10 seconds after writing the above post, i decided to try just changing the c.x, then just the c.y and then just the c.z
just to watch it fail again
and it work right away with the c.x
thank you so very much! I've been waiting for ever to have this result! thank you thank you thank you man!
Aparently i was confusing c.x,y,z with actual x,y,z values
was i thinking right or wrong? Because i just changed the vertice's X (c.x) value and the cube turned into a sphere shocked
I was not expecting it, but it worked out and THANK YOU!
here's the inicial cube


And the final sphere

Last edited by joao13pt; 05/25/13 14:00.
Re: From a simple 3D Sphere to a real-size Planet. Need help! [Re: joao13pt] #423214
05/25/13 15:32
05/25/13 15:32
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
Quote:
i don't think you understand what im trying to achieve

Really?

And congrats that it works now


Visit my site: www.masterq32.de
Re: From a simple 3D Sphere to a real-size Planet. Need help! [Re: MasterQ32] #423227
05/25/13 19:08
05/25/13 19:08
Joined: Mar 2013
Posts: 30
Portugal
J
joao13pt Offline OP
Newbie
joao13pt  Offline OP
Newbie
J

Joined: Mar 2013
Posts: 30
Portugal
Sorry about that, i really wans't thinking in what i was saying frown
It only works because of your help! thank you again!
Now i'll continue to create my virtual universe

Re: From a simple 3D Sphere to a real-size Planet. Need help! [Re: joao13pt] #423753
06/04/13 19:59
06/04/13 19:59
Joined: Mar 2013
Posts: 30
Portugal
J
joao13pt Offline OP
Newbie
joao13pt  Offline OP
Newbie
J

Joined: Mar 2013
Posts: 30
Portugal
Hello!
When moving or rotating the sphere that used to be a cube, it wont update it's shadow
But when i do the same with a sphere model from MED, it does update it's shadow without any issues
What's wrong?

Re: From a simple 3D Sphere to a real-size Planet. Need help! [Re: joao13pt] #423754
06/04/13 20:01
06/04/13 20:01
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
how do you transform your cube?


Visit my site: www.masterq32.de
Re: From a simple 3D Sphere to a real-size Planet. Need help! [Re: joao13pt] #423756
06/04/13 21:35
06/04/13 21:35
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Originally Posted By: joao13pt
it wont update it's shadow


I guess you mean the shading? When you just move the vertices around, the normals won't be updated. Try ent_fixnormals.

Re: From a simple 3D Sphere to a real-size Planet. Need help! [Re: MasterQ32] #423757
06/04/13 22:16
06/04/13 22:16
Joined: Mar 2013
Posts: 30
Portugal
J
joao13pt Offline OP
Newbie
joao13pt  Offline OP
Newbie
J

Joined: Mar 2013
Posts: 30
Portugal
Originally Posted By: MasterQ32
just use vec_normalize(c.x, 1); here instead of the whole normalization code

I transform it into a sphere like you told me to, using this:

Code:
function cube_to_sphere(ENTITY* model) 
{
	
  int i = ent_status(model,0); 
  for (; i>0; i--) 
  {    														 
  	CONTACT* c = ent_getvertex(model,NULL,i);   
  	vec_normalize(c.x, 112);
  	c.v = NULL;   // set c.v to NULL	to change c.x,y,z 
  	ent_setvertex(model,c,i);
  	wait(5); 					 
  	}
  	
	ent_fixnormals(model, 0); // THIS PART OF THE CODE WAS ADDED AFTER READING THE PREVIOUS REPLY

}



The ent_fixnormals() worked out! thank you again for all your help fellow programmers!

Re: From a simple 3D Sphere to a real-size Planet. Need help! [Re: joao13pt] #423984
06/08/13 23:15
06/08/13 23:15
Joined: Mar 2013
Posts: 30
Portugal
J
joao13pt Offline OP
Newbie
joao13pt  Offline OP
Newbie
J

Joined: Mar 2013
Posts: 30
Portugal
Im sorry if i'm being annoying, i keep coming here with problems and questions and doubts
But now i need guidance to achieve my next goal, the one i was fearing most from the start, the part where i make my "procedural" planet, procedural: tessellation, face subdivision algorithms (this last one, im sure i could handle, i just can't freaking find any algorithm online nor any explanation of how to do it) and all of those things
I need advice on where to start
By now i've researched ALOT actually about procedural planets and all that stuff, and i've come to a (possibly wrong?) conclusion that real-time face subdivision is made through shaders, is it?
I really don't have the smallest clue on where to start, so any help from this community will be kindly apreciated
Thank you! smile

Page 4 of 5 1 2 3 4 5

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1