void display(void) { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); //Model Matrix Angel::mat4 model_ = mat4(1.0); Angel::vec3 scaleVec(scale_size,scale_size,scale_size); //Angel::vec3 transVec(4.0,0.0,0.0); Angel::vec3 transVec(u_disp,v_disp,0.0); Angel::mat4 scaleMat = Scale(scaleVec); Angel::mat4 xRotMat = RotateY(x_angle); Angel::mat4 yRotMat = RotateX(y_angle); Angel::mat4 transMat = Translate(transVec); model_ = scaleMat*xRotMat*yRotMat*transMat; //Viewing Matrix point4 at(0.0,0.0,0.0,1.0); point4 eye(0.0,5.0,3.0,1.0); vec4 up(0.0,0.0,1.0,0.0); mat4 view_ = LookAt(eye,at,up); mat4 modelView_ = model_*view_; glUniformMatrix4fv(ModelView,1,GL_TRUE,modelView_); glDrawArrays(GL_TRIANGLE_STRIP,0,numVertices); glutSwapBuffers(); }
/*! @function TranslationV1ToObject @abstract Attempt to convert a VRML 1 Translation node to a Quesa object. @param ioNode Node to convert. @param inReader The reader object. @result An object reference, or NULL on failure. */ CQ3ObjectRef TranslationV1ToObject( PolyValue& ioNode, CVRMLReader& inReader ) { #pragma unused( inReader ) CQ3ObjectRef theTransform; PolyValue::Dictionary& theDict( ioNode.GetDictionary() ); if (IsKeyPresent( theDict, "translation" )) { PolyValue& transValue( theDict["translation"] ); if (transValue.IsNumberVec()) { PolyValue::FloatVec& transVec( transValue.GetFloatVec() ); if (transVec.size() == 3) { TQ3Vector3D translate = { transVec[0], transVec[1], transVec[2] }; theTransform = CQ3ObjectRef( Q3TranslateTransform_New( &translate ) ); if (theTransform.isvalid()) { SetCachedObject( ioNode, theTransform ); } } } } return theTransform; }
void StGeometryTest::stglDraw(unsigned int ) { StGLContext& aCtx = getContext(); GLint aViewPort[4]; aCtx.core20fwd->glGetIntegerv(GL_VIEWPORT, aViewPort); StGLVec4 transVec(1.0f / (GLfloat )aViewPort[2], 1.0f / (GLfloat )aViewPort[3], 0.0f, 0.0f); StGLVec4 scaleVec(1.0f - 2.0f * transVec.x(), 1.0f - 2.0f * transVec.y(), 1.0f, 1.0f); aCtx.core20fwd->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); aCtx.core20fwd->glEnable(GL_BLEND); stProgram.use(aCtx); stProgram.setScaleTranslate(aCtx, scaleVec, transVec); myGrid.draw(aCtx, stProgram); for(size_t aCircleId = 0; aCircleId < 5; ++aCircleId) { myCircles[aCircleId].draw(aCtx, stProgram); } myColors.draw(aCtx, stProgram); myBrightness.draw(aCtx, stProgram); stProgram.unuse(aCtx); aCtx.core20fwd->glDisable(GL_BLEND); }
/*! @function RotationV1ToObject @abstract Attempt to convert a VRML 1 Rotation node to a Quesa object. @param ioNode Node to convert. @param inReader The reader object. @result An object reference, or NULL on failure. */ CQ3ObjectRef RotationV1ToObject( PolyValue& ioNode, CVRMLReader& inReader ) { #pragma unused( inReader ) CQ3ObjectRef theTransform; PolyValue::Dictionary& theDict( ioNode.GetDictionary() ); if (IsKeyPresent( theDict, "rotation" )) { PolyValue& transValue( theDict["rotation"] ); if (transValue.IsNumberVec()) { PolyValue::FloatVec& transVec( transValue.GetFloatVec() ); if (transVec.size() == 4) { TQ3RotateAboutAxisTransformData rotData; rotData.origin.x = 0.0f; rotData.origin.y = 0.0f; rotData.origin.z = 0.0f; rotData.orientation.x = transVec[0]; rotData.orientation.y = transVec[1]; rotData.orientation.z = transVec[2]; rotData.radians = transVec[3]; // The axis should be normalized float axisLen = Q3FastVector3D_Length( &rotData.orientation ); if (axisLen > FLT_EPSILON) { Q3FastVector3D_Scale( &rotData.orientation, 1.0f/axisLen, &rotData.orientation ); theTransform = CQ3ObjectRef( Q3RotateAboutAxisTransform_New( &rotData ) ); if (theTransform.isvalid()) { SetCachedObject( ioNode, theTransform ); } } else if (inReader.GetDebugStream() != NULL) { *inReader.GetDebugStream() << "Rotation node has zero axis!" << std::endl; } } } } return theTransform; }