OLD | NEW |
1 //-***************************************************************************** | 1 //-***************************************************************************** |
2 // | 2 // |
3 // Copyright (c) 2009-2011, | 3 // Copyright (c) 2009-2011, |
4 // Sony Pictures Imageworks, Inc. and | 4 // Sony Pictures Imageworks, Inc. and |
5 // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. | 5 // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. |
6 // | 6 // |
7 // All rights reserved. | 7 // All rights reserved. |
8 // | 8 // |
9 // Redistribution and use in source and binary forms, with or without | 9 // Redistribution and use in source and binary forms, with or without |
10 // modification, are permitted provided that the following conditions are | 10 // modification, are permitted provided that the following conditions are |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 m_bounds.extendBy( m_drwHelper.getBounds() ); | 123 m_bounds.extendBy( m_drwHelper.getBounds() ); |
124 } | 124 } |
125 */ | 125 */ |
126 } | 126 } |
127 | 127 |
128 | 128 |
129 //-***************************************************************************** | 129 //-***************************************************************************** |
130 void INuPatchDrw::draw( const DrawContext &iCtx ) | 130 void INuPatchDrw::draw( const DrawContext &iCtx ) |
131 { | 131 { |
132 | 132 |
133 const V3f *points = m_positions -> get(); | 133 const V3f * oldPoints = m_positions -> get(); |
| 134 std::vector<GLfloat> points(m_positions->size() * 3); |
| 135 unsigned int curPos = 0; |
| 136 for (unsigned int v = 0; v < m_nv; ++v) |
| 137 { |
| 138 for (unsigned int u = 0; u < m_nu; ++u, ++curPos) |
| 139 { |
| 140 // go from u,v order to reversed v, u order |
| 141 unsigned int glIndex = (u * m_nv + (m_nv - v - 1)) * 3; |
| 142 points[glIndex] = oldPoints[curPos].x; |
| 143 points[glIndex+1] = oldPoints[curPos].y; |
| 144 points[glIndex+2] = oldPoints[curPos].z; |
| 145 } |
| 146 } |
| 147 |
134 const float *u_knot = m_uKnot -> get(); | 148 const float *u_knot = m_uKnot -> get(); |
135 const float *v_knot = m_vKnot -> get(); | 149 const float *v_knot = m_vKnot -> get(); |
136 size_t nknotu = m_uKnot -> size(); | 150 size_t nknotu = m_uKnot -> size(); |
137 size_t nknotv = m_vKnot -> size(); | 151 size_t nknotv = m_vKnot -> size(); |
138 ···· | 152 ···· |
139 glColor3f(1.0, 1.0, 1.0); | 153 glColor3f(1.0, 1.0, 1.0); |
140 ···· | 154 ···· |
141 gluBeginSurface(nurb); | 155 gluBeginSurface(nurb); |
142 | 156 |
143 gluNurbsSurface( nurb, | 157 gluNurbsSurface( nurb, |
144 nknotu, (GLfloat *) &u_knot[0], | 158 nknotu, (GLfloat *) &u_knot[0], |
145 nknotv, (GLfloat *) &v_knot[0], | 159 nknotv, (GLfloat *) &v_knot[0], |
146 m_nu*3, 3, // stride | 160 m_nv*3, 3, // stride |
147 (GLfloat *) &points[0][0], | 161 &(points.front()), |
148 m_uOrder, m_vOrder, //orders | 162 m_uOrder, m_vOrder, //orders |
149 GL_MAP2_VERTEX_3 | 163 GL_MAP2_VERTEX_3 |
150 ); | 164 ); |
151 ···· | 165 ···· |
152 gluEndSurface(nurb); | 166 gluEndSurface(nurb); |
153 ···· | 167 ···· |
154 ···· | 168 ···· |
155 IObjectDrw::draw( iCtx ); | 169 IObjectDrw::draw( iCtx ); |
156 } | 170 } |
157 | 171 |
158 } // End namespace SimpleAbcViewer | 172 } // End namespace SimpleAbcViewer |
OLD | NEW |