/********************************************************************/ /* Copyright (c) 2017 System fugen G.K. and Yuzi Mizuno */ /* All rights reserved. */ /********************************************************************/ #if !defined(_MGVBOLEAF__INCLUDED_) #define _MGVBOLEAF__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "MGCLStdAfx.h" #include "mgGL/Color.h" #include "mgGL/VBOElement.h" class MGPosition; class MGBPointSeq; class MGCurve; class mgVBO; class mgVBOLeafBuilder; class mgTexture; /** @file */ /** @addtogroup DisplayHandling * @{ */ ///////////////////////////////////////////////////////////////////////////// // mgVBOLeaf ///mgVBOに対して描画データ作成後の情報を保持するためのクラス. ///mgVBOはmgVBOLeafとmgVBO自身をelementとして保持する。 ///mgVBOをelementとするのはMGGroupまたはMGShellのメンバーデータの表示情報を ///保持するため class MG_DLL_DECLR mgVBOLeaf:public mgVBOElement{ ///Used to judge the polygon mode of the polygon if this mgVBOLeaf is a triangle. ///When polygon mode = GL_LINE, m_size=the line width. ///When polygon mode = GL_POINT, the point size=m_size-m_PolygonModePointSizeBase. ///That is, if m_size>m_PolygonModePointSizeBase, its polygon mode is GL_POINT and ///the point size=m_size-m_PolygonModePointSizeBase. In other words, maximum line width ///is m_PolygonModePointSizeBase. static const GLfloat m_PolygonModePointSizeBase; friend class mgVBO; public: mgVBOLeaf(); mgVBOLeaf(GLfloat size,MGColor& color); mgVBOLeaf(const mgVBOLeaf& vbol); mgVBOLeaf(const mgVBOLeafBuilder& builder); ~mgVBOLeaf(); ///Cloned mgVBOLeaf has only static attributes copied. ///All the other data are initialized. //mgVBOLeaf* clone()const; ///このmgVBOElementがnull(いまだdraw/make_display_list()処理されていない)かを判定 ///mgVBOはm_gelに対するmake_display_list()処理がなされていないときfalseが返される ///mgVBOLeafはmake_display_list()されたときのみ存在するため常にtrueが返る。 bool is_made(MGCL::VIEWMODE viewMode=MGCL::DONTCARE){return true;}; ///すでに作成済みであっても強制的に再作成を行う。 ///mgVBOLeafは作成済みの場合のみ存在するため何もしない。 void make_display_list(MGCL::VIEWMODE vmode=MGCL::DONTCARE){;}; ///描画関数draw()は、is_made()であれば、作成し、表示処理をする。 ///!is_made()(描画データ作成済み)であれば、すでに作成されたmgVBOElementの描画を行う。 ///mgVBOLeafでは常に作成すみであり表示処理をおこなう。 void draw(MGCL::VIEWMODE viewMode=MGCL::DONTCARE); ///draw()はmgVBOLeafが作成済み(not null)であれば作成処理を行わないが、 ///redraw()は強制的に再作成を行い描画処理をおこなう。 ///mgVBOLeafでは常に作成すみであり表示処理をおこなう。 void redraw(MGCL::VIEWMODE viewMode=MGCL::DONTCARE){draw(viewMode);}; ///描画関数selectionDraw()は、Object選択のための表示処理をする。 ///通常のdrawとの相違:///Colorとしてm_bufferIDを用い、size処理以外の ///attributesの処理(normal, texture, color)をしない。 virtual void selectionDraw(MGCL::VIEWMODE viewMode=MGCL::DONTCARE); // /////Function IDをセットする //void setFunctionID(int functionID){m_functionID=functionID;}; //int getFunctionID()const{return m_functionID;}; ///DrawTypeをセットする void setDrawType(mgGLSL::DrawType drawType){m_drawType=drawType;}; mgGLSL::DrawType getDrawType()const{return m_drawType;}; ///Textureをset/getする。 ///textureは参照するのみ void setTexture(mgTexture* texture); ///Textureをset/getする。 const mgTexture* getTexture()const; mgTexture* getTexture(); ///Test if a texture is binded. bool texture_is_bound()const; ///作成済のmgVBOLeafのIDの位置のVertex dataをPのデータに置き換える。 ///0<= ID & Ps); ///作成済のmgVBOLeafのstartIDの位置からnum個のVertex dataをPsのデータに ///置き換える。 0<= startID , startID+num<=getVerticesNumber(). ///Here num=Ps.length(); void updateVertices(unsigned startID, const MGBPointSeq& Ps); ///作成済のmgVBOLeafのstartIDの位置からnumVertices個の頂点dataをareaのデータに ///置き換える。 0<= startID , startID+numVertices<=getVerticesNumber(). ///areaの配列の長さ=numVertices*3となる void updateVertices(unsigned startID, unsigned numVertices, const float* area); ///Vertexの数を求める unsigned getVerticesNumber()const{return m_count;}; ///Obtain display list name. ///0(null) はこのmgVBOElementはmgVBOLeafであり、名前をもたないことを示す。 ///名前はmgVBOだけが持つ unsigned getDName()const{return 0;}; ///Selectionに設定する名前を求める。=0のとき、名前の設定処理をしない。 ///0(null) はこのmgVBOElementはmgVBOLeafであり、名前をもたないことを示す。 ///名前はmgVBOだけが持つ virtual GLuint getSelectionName()const{return 0;}; ///m_primitiveMode=GL_QUAD_STRIP, GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN ///のときにのみ有効でそのPolygonMode(GL_POINT, GL_LINE, GL_FILL)を指定する. ///setPolygonModeしていないmgVBOLeafはGL_FILLとされる。 void setPolygonMode(GLenum mode); void setStaticAttribColor(const MGColor& color){//colorにはundefinedのものも許される m_color=color; }; void setPrimitiveMode(GLenum primitiveMode){m_primitiveMode=primitiveMode;}; ///Set light mode. mode=-1:undefined, =0:disabled, =1:enabled. void setLightMode(int mode); ///Line stipple属性をセットする。 ///When factor=0 is input, line pattern is disabled. This means the line is solid. ///When factor<0, the stipple attribute is undefined. This means the attribute ///is defined by the environment. ///When factor<=0, pattern is unnecessary. void setLineStipple(short int factor, GLushort pattern); void setStaticAttribLineWidth(GLfloat size);///size<=0. はundefinedを示す void setStaticAttribPointSize(GLfloat size);///size<=0. はundefinedを示す protected: private: //int m_functionID;///the function ID to set to the current mgGLSLProgram. // ///mgVBO will invoke setUniform("functionID",m_functionID); // ///Initially m_functionID=0. mgGLSL::DrawType m_drawType;/// 描画モード mgGLSL::DrawTypeの値が入る GLuint m_bufferID;///0:Light is enabled. void execStaticAttrib(MGCL::VIEWMODE viewMode, bool selection=false); }; /** @} */ // end of DisplayHandling group #endif // !defined(_MGVBOLEAF__INCLUDED_)