Using VRML to do Computer Graphics

As part of my semester abroad in Singapore at NTU, I took the Computer Graphics class or CZ2003. The last two projects, as part of assignments, gave the student a bit more freedom and the opportunity to create 1) a 3D form and 2) an animated 3D form.

To visualize the forms and play with the viewing angle, I would recommend to download BS Connect Contact Player. As for the best free editor, using VRMLPad is a the obvious best way, but you can also use sublime.

For both, I have hosted my code on Github. These projects were interesting to create and showed what you can do when you have a good grasp on geometrical forms, mathematical equations and programming skills. Here are some screenshot of the two projects and the implicit equation used:

1) Implicit Solid: Minnie Mouse using VRML

face=1-x^2-y^2-z^2;

out1=0.75^2-(x-1)^2-(y-1)^2-z^2;
out2=0.75^2-(x+1)^2-(y-1)^2-z^2;
in1=0.75^2-(x-1)^2-(y-1)^2-(z-0.2)^2;
in2=0.75^2-(x+1)^2-(y-1)^2-(z-0.2)^2;
ears=max(min(out1, -in1), min(out2, -in2));

bigform=1-(x/1.1)^2-((y+0.3)/0.5)^2-((z-0.75)/0.5)^2;
tip=1-(x/0.3)^2-((y+0.3)/0.25)^2-((z-1.2)/0.25)^2;
nose=max(bigform, tip);

cone1=min(min(((x/1.5)^2-(z-0.2)^2-((y-1))^2), x-0.25), 0.75-x);
cone2=min(min(((x/1.5)^2-(z-0.2)^2-((y-1))^2), -x-0.25), 0.75+x);
cylinder=min(min((1/50-(z-0.2)^2-((y-1))^2), 0.25-x), 0.25+x);
sides=max(cone1, cone2);
ribbon=max(sides, cylinder);

eye1=1-((x-0.3)/0.2)^2-((y-0.54)/0.39)^2-((z-1)/0.2)^2;
ball1=0.02^1-(x-0.3)^2-(y-0.4)^2-(z-1.1)^2;
eye2=1-((x+0.3)/0.2)^2-((y-0.54)/0.39)^2-((z-1)/0.2)^2;
ball2=0.02^1-(x+0.3)^2-(y-0.4)^2-(z-1.1)^2;
eyes=max(min(eye1, -ball1), min(eye2, -ball2));

final=max(max(max(max(nose, ears), face), ribbon), eyes);

2) Animated Solid: Slow Merging of 2 3D Forms

function parametric_x(u,v,w,t){
x1=1.6*cos(u*pi)^3;
x2=cos(u*pi)*sin(u*pi);
return x1+(x2-x1)*t;
}

function parametric_y(u,v,w,t){
y1=1.6*(cos(2*v*pi)*sin(u*pi))^3;
y2=cos(2*v*pi)*sin(u*pi);
return y1+(y2-y1)*t;
}

function parametric_z(u,v,w,t){
z1=1.6*sin(2*v*pi)*sin(u*pi);
z2=sin(v*pi*2)*sin(pi*u);
return z1+(z2-z1)*t;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s