PDA

View Full Version : egg / raindrop shape, how?



10-17-2002, 05:45 PM
I have been trying to model an egg shape with a sphere and an ellipse without being very succesful. Now things are worse because I need to apply a texture to it.

Does anyone know how could I deform a sphere so that it looks like an egg?

Thanks
Joan

nexusone
10-17-2002, 05:56 PM
As you get to more advanced 3D models, most peole start using a 3D modeling program to design their object.

With a drop, try drawing it out on paper then build it using a vertex array.
Should not be that hard to do.



Originally posted by jpuig:
I have been trying to model an egg shape with a sphere and an ellipse without being very succesful. Now things are worse because I need to apply a texture to it.

Does anyone know how could I deform a sphere so that it looks like an egg?

Thanks
Joan

31337
10-17-2002, 06:00 PM
If I was you I would write an OBJ loader and model it with a 3d modeling program like MAYA then load it into memory with your code and draw it.

10-18-2002, 03:30 AM
First of all, thanks for all your replies.
A modeller is not going to help me because I need to be able to change the shape of it in run-time

I was hoping there would be some sort of transformation matrix that would help me with that

Thanks
Joan

nexusone
10-18-2002, 04:00 AM
There are examples of changing object shape during run-time. nehe.gamedev.net has a tutor on that, also I have seen some others out there.

But it you build with array's, you need only make changes on the effected array values to make a object deform or change shape.

example:

array1 sphere = data_set1;
array2 drop = data_set2;
both data set's have same amount of points.

array3 drawing_data; here is where you will store data to be drawn.
You will start with drawing_data = sphere;
then have the vertex point start moving to the vertex points in drop. This will make the object morf into one or the other.



Originally posted by jpuig:
First of all, thanks for all your replies.
A modeller is not going to help me because I need to be able to change the shape of it in run-time

I was hoping there would be some sort of transformation matrix that would help me with that

Thanks
Joan

John Jenkins
10-18-2002, 04:21 AM
I draw alot of my stuff with rings. What you could do is draw a series of rings with different diameters. I draw pipes that way. I connect all the rings together. and it looks like one piece if you do the same but adjust the diameters as you go then you can have an egg.

coredump
10-18-2002, 05:17 AM
grab milkshape (http://www.swissquake.ch/chumbalum-soft) . it's only $20 and the file format is quite simple. come's with an SDK for creating your own plug-ins.

b

10-18-2002, 06:11 AM
Using rings seems like a very good idea (the second thing that came to my mind after a fransformation matrix), but the reason why I posted in the begginer forum is because I can't do anything above the real basic stuff. I would like to know if there is a tutorial online that I could use to get me started, or if it is very simple, could you post some sample code

Thanks
Joan

fringe
10-18-2002, 06:32 AM
Hmm, try this. I am at work so can't try it but It is an idea.

extra=1.5; //extra length in the egg direction
for (int i=0;i<=upsegs;i++)
{
glBegin(TriangleStrip)
for (int j=0;j<=segs;j++){
if (i<upsegs/2)
{
glTexCoord2f(j/segs,i/upsegs);
glVertex3f(r*Sin(i*2PI/upsegs)*Cos(j*2Pi/segs),r*Sin(i*2Pi/upsegs)*Sin(j*2PI/segs),r*Cos(j*2PI/upsegs));
glTexCoord2f(j/segs),(i+1)/upsegs);
glVertex3f(r*Sin((i+1)*2PI/upsegs)*Cos(j*2Pi/segs),r*Sin(i+1*2Pi/upsegs)*Sin(j*2PI/segs),r*Cos(j+1*2PI/upsegs));
}
else
{
glTexCoord2f(j/segs,i*extra/upsegs);
glVertex3f(r*Sin(i*2PI/upsegs)*Cos(j*2Pi/segs),r*Sin(i*2Pi/upsegs)*Sin(j*2PI/segs),r*Cos(j*2PI/upsegs)*extra);
glTexCoord2f(j/segs),(i+1)*extra/upsegs);
glVertex3f(r*Sin((i+1)*2PI/upsegs)*Cos(j*2Pi/segs),r*Sin(i+1*2Pi/upsegs)*Sin(j*2PI/segs),r*Cos(j+1*2PI/upsegs)*extra);
}
}


glEnd();

The idea is to create a sphere but with the bottom half z vaklues multiplied by 1.5 (extra). The texture coorinates then just follow the same rule (although this means they are repeated at the top) If you want a single texture to wrap the object them you have to work out the extra length (post here and I will have a think),

fringe