Skip to content

Commit

Permalink
Merge pull request #8 from dipsywong98/daniel
Browse files Browse the repository at this point in the history
Shaking hand and 3 point lighting>~<
  • Loading branch information
dipsywong98 authored Mar 19, 2019
2 parents 1e22412 + 0584da2 commit a042021
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 16 deletions.
52 changes: 41 additions & 11 deletions MyModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,23 @@ void MyModel::draw()
lightPosition0[3] = 1;
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition0);

if (VAL(LIGHT_3_PT))
{
glEnable(GL_LIGHT2);
GLfloat lightPos0[] = { -26.8f, 30.f, 8.f, 1.f };
GLfloat lightPos1[] = { 14.5f, 0.8f, 15.5f, 1.f };
GLfloat lightPos2[] = { -1.8f, -7.3f, -14.7f, 1.f };
GLfloat lightIntensity0[] = { 1.f, 1.f, 1.f, 1.f };
GLfloat lightIntensity1[] = { 0.5f, 0.5f, 0.5f, 0.f };
GLfloat lightIntensity2[] = { .2f, .2f, .2f, .2f };
glLightfv(GL_LIGHT0, GL_POSITION, lightPos0);
glLightfv(GL_LIGHT1, GL_POSITION, lightPos1);
glLightfv(GL_LIGHT2, GL_POSITION, lightPos2);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightIntensity0);
glLightfv(GL_LIGHT1, GL_DIFFUSE, lightIntensity1);
glLightfv(GL_LIGHT2, GL_DIFFUSE, lightIntensity2);
}

// draw the floor
setAmbientColor(.1f, .1f, .1f);
setDiffuseColor(COLOR_RED);
Expand All @@ -127,9 +144,21 @@ void MyModel::draw()
glPushMatrix();
setDiffuseColor(0.5f, 0.9f, 0.9f);
glTranslated(-4, 0.001, -4);
drawLathe({ {0.0, 1.0}, {1.0, 2.0}, {1.2, 2}, {0.1, 0.9}, {0.1, 0.1}, {1.0, 0.0}, {0.0, 0.0} });
drawLathe({ {0.0, 1.0}, {1.0, 2.0}, {1.2, 2}, {0.1, 0.9}, {0.1, 0.1}, {1.0, 0.0}, {0.0, 0.0} }); //martini
glPopMatrix();

glPushMatrix();
setDiffuseColor(0.5f, 0.9f, 0.9f);
glTranslated(-4, 0.001, -1);
drawLathe({ {0, 0.96}, {0.5, 1}, {0.84, 1.3}, {0.83, 1.84}, {0.5, 2.6}, {0.6, 2.6}, {0.94, 1.84}, {0.94, 1.25}, {0.54, 0.91}, {0.1, 0.86}, {0.1, 0.1}, {1, 0}, {0,0} }); //wine glass
setDiffuseColor(0.4f, 0.f, 0.f);
drawLathe({ {0, 0.96}, {0.5, 1}, {0.84, 1.3}, {0.83, 1.84}, {0, 1.84}});
glPopMatrix();

if (VAL(SHOWPRISM)) {
drawTest();
}

// draw ik target point
if(VAL(IKENABLE))
{
Expand Down Expand Up @@ -207,18 +236,19 @@ void MyModel::drawArm(int levels, int curDept)
glRotated(VAL(ARM1V + curDept*2)+(mood==1)*moodTick, 0, 1, 0);

if (mood == 2)
glTranslated(levels*sin(32 * rad(levels*moodTick)) / 1000.f, 0, levels*cos(32 * rad(levels*moodTick)) / 1000.f);
glTranslated(levels*sin(32 * rad(levels*moodTick)) / 100.f, 0, levels*cos(32 * rad(levels*moodTick)) / 100.f);

//vertical arm cylinder
glPushMatrix();
if(VAL(BOXARMS)==0)
{
glRotated(-90, 1, 0, 0);
drawCylinder(2, 1, 1);
}else
{
glTranslated(-1, 0, -0.5);
drawBox(2, 2, 1);
}
if(VAL(BOXARMS)==0)
{
glRotated(-90, 1, 0, 0);
drawCylinder(2, 1, 1);
}else
{
glTranslated(-1, 0, -0.5);
drawBox(2, 2, 1);
}
glPopMatrix();

//joint cylinder
Expand Down
4 changes: 3 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ int main()
controls[LIGHTX] = ModelerControl("Light X", -30, 30, 0.1, -20);
controls[LIGHTY] = ModelerControl("Light Y", -30, 30, 0.1, 12);
controls[LIGHTZ] = ModelerControl("Light Z", -30, 30, 0.1, 20);
controls[LIGHT_3_PT] = ModelerControl("Enable 3 Point Lighting", 0, 1, 1, 0);
controls[LEVELDETAILS] = ModelerControl("Level of Details", 0, 10, 1, 10);
controls[ENABLEANIM] = ModelerControl("Enable Anim", 0, 1, 1, 0);
controls[CYCLINGMOOD] = ModelerControl("Cycling Mood", 0, 2, 1, 0);
Expand All @@ -61,14 +62,15 @@ int main()
controls[LTHICKNESS] = ModelerControl("Lsystem: thickness", 0.01, 1, 0.01, 0.1);
controls[LDECAYTHICKNESS] = ModelerControl("Lsystem: decay thickness", 0.01, 10, 0.01, 1);
controls[LDECAYLENGTH] = ModelerControl("Lsystem: decay length", 0.01, 10, 0.01, 1);
controls[BALLJOINTS] = ModelerControl("Ball joints", 0, 1,1, 0);
controls[BALLJOINTS] = ModelerControl("Ball joints", 0, 1,1, 1);
controls[BOXARMS] = ModelerControl("Box Arms", 0, 1,1, 0);
controls[IKENABLE] = ModelerControl("IK: enable", 0, 1,1, 0);
controls[IKX] = ModelerControl("IK: X", -10, 10,0.01, 3);
controls[IKY] = ModelerControl("IK: Y", -10, 10,0.01, 3);
controls[IKZ] = ModelerControl("IK: Z", -10, 10,0.01, 3);
controls[IKMIN] = ModelerControl("IK: Min", -180, 180,1, -90);
controls[IKMAX] = ModelerControl("IK: Max", -180, 180,1, 90);
controls[SHOWPRISM] = ModelerControl("Show Prism", 0, 1, 1, 0);

ModelerApplication::Instance()->Init(&createSampleModel, controls, NUMCONTROLS);
return ModelerApplication::Instance()->Run();
Expand Down
5 changes: 3 additions & 2 deletions modelerglobals.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ enum SampleModelControls
{
XPOS, YPOS, ZPOS, HEIGHT, ROTATE,
ARM1V, ARM1H, ARM2V, ARM2H, ARM3V, ARM3H, CLAMPWIDTH,
LIGHTX, LIGHTY, LIGHTZ, LEVELDETAILS,
LIGHTX, LIGHTY, LIGHTZ, LIGHT_3_PT, LEVELDETAILS,
ENABLEANIM, CYCLINGMOOD,
LDISP, LDEPTH, LANGLE, LLEN, LTHICKNESS, LDECAYTHICKNESS, LDECAYLENGTH,
BALLJOINTS, BOXARMS,
IKENABLE, IKX, IKY, IKZ, IKMIN, IKMAX, NUMCONTROLS
IKENABLE, IKX, IKY, IKZ, IKMIN, IKMAX,
SHOWPRISM, NUMCONTROLS
};

// Colors
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ B: Bell, W: Whistle, 1B=2W
- [x] (1B) Widget to control param and create individual-looking instances
- [x] **(1B)** Fit whole model in camera (Frame All)
- [x] (1B1W) an intuitive way for the user to twist the camera via mouse control.
- [ ] *(2B)* New primitives (is it 2B for each)
- [x] *(2B)* New primitives (is it 2B for each)
- [ ] 1. Given Curve A and B, surface form by sweep A through B
- [ ] 2. Given Curve A and stright line L, surface form by rotate A about L
- [x] 2. Given Curve A and stright line L, surface form by rotate A about L
- [ ] 3. Torus
4. Others base on coolness
- [x] (2B) procedural modelling with parameter control [L-system](https://en.wikipedia.org/wiki/L-system)
Expand Down

0 comments on commit a042021

Please sign in to comment.