DRAW BOX SAMPLE

Jan 17, 2015 at 12:18 PM
Edited Jan 17, 2015 at 12:19 PM
i need some samples. How i draw a box with fgl ?

Thanks for help.
Coordinator
Jan 19, 2015 at 5:57 AM
1) Create file box.nff via notepad
2) Put model definition inside box.nff
hex 0 0 0 1

format is: type <center x> <center y> <center z> <radius = edge length / 2>

3) Load your model (This.oFGLC - instance of fglc.fglc_main class)
This.oFGLC.oScene.hRenderNode = This.oFGLC.oNode.fgl_create(This.oFGLC.hScene())
This.oFGLC.oNode.fgl_name = "My Box"

LOCAL lcModelPath
lcModelPath = "box.nff"

This.oFGLC.oModel.hFGL=(This.oFGLC.loadModel(lcModelPath))
This.oFGLC.oNode.aVisuals.add(This.oFGLC.oModel.hFGL)
This.oFGLC.oNode.calcBounds()
Jan 19, 2015 at 9:15 AM

Thanks for answers.

is there any documentation or link?

i need some samples.

is it possible use glut founctions in fgl?
is it possible print out screen in fgl?
is it possible pick or select an obj in fgl? like game.

i need some samples also
draw primitive (vertex, sphere etc ) in fgl?

because i can not find in fgl library at foxpro how i can draw them.

thanks very much.


Coordinator
Jan 19, 2015 at 12:19 PM
1) There is no any documetation, I'm the single developer of this lib and bothering with my job tasks most of the time. Maybe it will apear this year

2) GLUT? No. Though If you presume quadrics, nurbs, any type of parametric surfaces I can add these features if FGL. What do you need in fact?
Rendering into external bitmap file is not implemented, so I can implement that if U need.

3) FGL doesn't give access to vertecies, so it's not allowed to manipulate each single vertex

4) Picking, selecting. Short answer is yes.

a) To test picking on particular object:

LOCAL lnXCoord, lnYCoord
lnXCoord = MCOL(0,3)
lnYCoord = MROW(0,3)


lhNode - ID of some node
lnXCoord, lnYCoord
IF This.oFGLC.oPickInfo.pick(lnXCoord, lnYCoord, lhNode)=0
RETURN .F.
ENDIF

lnPx = This.oFGLC.oPickInfo.pg.x
lnPz = This.oFGLC.oPickInfo.pg.z

b) To select object by picking
  • create subclass from fglc.fglc_obj
  • assume that class has name sampleobj
DEFINE CLASS sampleobj AS fglc_obj
Name = "sampleobj"


PROCEDURE click
    LPARAMETERS oPickInfo

    MESSAGEBOX("Click")
ENDPROC


PROCEDURE fglc_define
    DODEFAULT()

    LOCAL loModel
    loModel = This.oMain.oModel
    loModel.hFGL=(This.oMain.loadModel("data/fox.lwo"))
    This.oNode.aVisuals.add(loModel.hFGL)
ENDPROC

ENDDEFINE


This.oFGLC.oScene.hRenderNode = This.oFGLC.oNode.fgl_create(This.oFGLC.hScene())
  • add an object to scenegraph
    This.oFGLC.NewObject("oSampleObj", "sampleobj", "sample.vcx")
    This.oFGLC.oSampleObj.fglc_create()
    This.oFGLC.oSampleObj.resize() &&find bounding volume
    This.oFGLC.oSampleObj.oNode.hParent = This.oFGLC.oScene.hRenderNode
c) Also you may take a look on fglc_viewport.MouseUp method
Jan 19, 2015 at 1:13 PM
For my project , i need draw polygon, rectangle, sphere text etc. as attac picture. filled or not filled.
i wan to print out scane and also pick object. all of them possible in fgl ?


your samples usefull. i will test it. thaks.



Coordinator
Jan 19, 2015 at 1:44 PM
KAPKESART wrote:
For my project , i need draw polygon, rectangle, sphere text etc. as attac picture. filled or not filled. i wan to print out scane and also pick object. all of them possible in fgl ? your samples usefull. i will test it. thaks.
To draw polygons, rectangles, spheres you should load them from files. The simplest approach is using obj format or nff format:

http://en.wikipedia.org/wiki/Wavefront_.obj_file
http://www.cs.ucf.edu/courses/cap5725/spring2003/nff.html

sphere: s x y z r

Polygon: p N P1x P1y P1z ... PNx PNy PNz,

Text can be added via fglText object as it shown in sample project

This.oFGLC.oText.fgl_create(This.oFGLC.hScene())
WITH This.oFGLC.oText
.fgl_name = "caption"
.fontName = "Arial"
.text = "hello"
.fontType = 2
.fontSize = 1
.lineLength = 0
.alignment = 1
This.oFGLC.oMaterial.hFGL=(.hMaterial)
This.oFGLC.oMaterial.color_diffuse = RGB(255,255,255)
This.oFGLC.oMaterial.twoSided = 1
ENDWITH


Filling is property of material

This.oFGLC.oMaterial.wireframe = 1 &&unfilled
This.oFGLC.oMaterial.wireframe = 1 &&filled

If you need quick help with coding, contact me through skype (my skype id: chunihin-df@yandex.ru)
Jan 19, 2015 at 2:50 PM
i tried sphere , polygon . it is ok thanks,
is it possible print out or save output screen/scene ?