How can I?

BlitzMax Forums/MiniB3D Module/How can I?

Sanctus(Posted 2007) [#1]
Hi
I was wondering how can I render a Cube for example and over it the wireframe. I want it to look like a wireframe view in 3d max.
If you don't know wath I mean the I just want to render flatshaded and wires in the same time


klepto2(Posted 2007) [#2]

Import sidesign.minib3d

Graphics3D 800 , 600 , 0 , 2

Local Cam:TCamera = CreateCamera()

Local Light:TLight = CreateLight()

PositionEntity Cam , 0 , 10 , - 10

Local cube:TMesh = CreateCube()
PointEntity Cam,Cube


While Not KeyHit(Key_Escape)
	
	TurnEntity(cube,0.5,0.5,0.5)
	
	'FirstPass
	CameraClsMode cam,True,True

	Wireframe(False)
	
	EntityColor cube , 0 , 255 , 0
	
	RenderWorld()

	
	'Second Pass
	CameraClsMode cam , False , False
	
	EntityColor cube , 255 , 0 , 0
	
	Wireframe(True)
	
	RenderWorld()
	
	Flip
Wend



It is not commented but a look in the manual section in this forum should make the program more clear. In my hopefully soon available extended Version will be an additional command, which will enable you to choose the desired rendermode per entity(Full,Wire,Point).

greetings.


Sanctus(Posted 2007) [#3]
Thx man!
It works preety well...
Now... Do you have an ideea how can I render the points to (vertex's)?


bradford6(Posted 2007) [#4]
you would enable GL_POINTS

something like this:

Function Points_Mode(enable)
		If enable = 1
			glEnable GL_POINT_SMOOTH
			glPointSize(8)
			glPolygonMode(GL_FRONT,GL_POINT)
		EndIf
End Function



glpolygonmode can be points, line or fill. I hacked the miniB3D source to make a polymode for each entity (rather than a global one) it was just a matter of adding a field to tmesh
Field polymode:int

and putting the modechange withing the render loop.

I think Klepto and/or Simon are going to do that eventually anyway. (this way you can mix wireframe, filled and point meshes in the same scene and you do not need to Render the scene twice---you could just have a polycube and a wire cube together)


klepto2(Posted 2007) [#5]
yes, bradfords solution is the right way to achieve this. And in fact my extended Version (the part I'm working on) already has a command to Set individual Renderstyles. Currently there is Full,Wire(Line) and Point but I will add strippled lines etc later. This styles are set for each Entity so you're abel to have wireframe models and full models in 1 go without hacking with different passes etc.


bradford6(Posted 2007) [#6]
klepto is otherworldly. I think he is not one person but infact an AI composite of hundreds of AI coders

Type TKlepto
    Field Coder:Tlist
End type

for a = eachin TKlepto.Coder
      a.Write_Code()
next



Sanctus(Posted 2007) [#7]
Thx all of you.
Now I have another problem.
The code works well when I use it with graphics3d 800,600 bla bla bla.
But when I try to put the minib3d in a canvas this thing doesn't work anymore.
SuperStrict

Framework Sidesign.minib3d
Import BRL.MaxGUI
Import BRL.win32maxgui
Import BRL.EventQueue
Import BRL.retro
Import brl.max2d
Import BRL.GLMax2D
Import brl.graphics
Import brl.timer

Include "GUI_init.bmx"
Include "Global_init.bmx"


Global obj:TObject = New TObject
obj.name = "box1"
obj.entity = CreateCube()

cam:Tcamera = CreateCamera()
PositionEntity cam, 0,0,-6
Local Light:TLight = CreateLight()

CreateTimer( 60 )
While True
	WaitEvent 
	Print CurrentEvent.ToString()
	Select EventID()
	
		Case EVENT_WINDOWCLOSE
			End
		Case EVENT_TIMERTICK
		
			RedrawGadget Maincanvas
			
			TurnEntity obj.entity,1,1,1

			
		Case EVENT_GADGETPAINT
			
			
			CameraClsMode cam,True,True

			Wireframe(False)
	
			EntityColor obj.entity , 0 , 255 , 0
	
			RenderWorld()

	
			'Second Pass
			CameraClsMode cam , False , False
	
			EntityColor obj.entity , 255 , 0 , 0
	
			Wireframe(True)
	
			RenderWorld()
			
			Flip


	End Select
Wend

and here is some other code that might be needed to understand the first one:
Global MainCanvas:Tgadget = CreateCanvas(0,0,GadgetWidth(Main_Window)-200,GadgetHeight(Main_Window),Main_Window,0)


SetGraphicsDriver GLGraphicsDriver(),GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER
TGlobal.width=ClientWidth(MainCanvas)
TGlobal.height=ClientHeight(MainCanvas)

TGlobal.depth=16
TGlobal.mode=0
TGlobal.rate=60

SetGraphics CanvasGraphics(MainCanvas)

TGlobal.GraphicsInit()
Global cam:TCamera=CreateCamera()

Global ObjectList:TList = New TList

Type TObject
	Field name:String
	Field entity:Tentity
End Type

Type TObject_texture
	Field name:String
	Field brush:TBrush
End Type 

Function Points_Mode(enable:Byte)
		If enable = 1
			glEnable GL_POINT_SMOOTH
			glPointSize(8)
			glPolygonMode(GL_FRONT,GL_POINT)
		Else
			glDisable GL_POINT_SMOOTH
			glPolygonMode(GL_FRONT,GL_FILL)
		EndIf
End Function



klepto2(Posted 2007) [#8]
Just a try, are you using my extended Version?
If yes, the replace SetGraphicsDriver GLGraphicsDriver(),GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER
With

SetGraphicsDriver GLMax2DDriver(),GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER

In my next release I have 2 extra functions call CanvasGraphics3D and UpdateCanvas3D. The first will do the same as Graphics3D but will prepare a canvas for working with miniB3D, the second can be used when a canvas is resized to simply adjust the Graphicswindow.


Sanctus(Posted 2007) [#9]
No... I don't think I'm using your version... because I can't get it...(can't you please upload it somewhere pls?)
EDIT: Actualy I do use your version adn changing that doesn't do any good.
I'm just getting the wireframe render. Isn't there a way to not clear the screen before rendering or something?