Page 1 of 1

using Sculptris 3D modelling for PureBasic

Posted: Mon Aug 12, 2013 7:14 pm
by applePi
this is about using Sculptris to make models and texturing it for using it in purebasic
at first the project in witch a plane prepared and textured by Sculptris, then converted by OgreAssimpConverter (download it from Ogre tools/3D Programming section) to *.mesh then used by a purebasic program
here is the project and the purebasic code to display the result
http://www.mediafire.com/?zz5gj90cz5vqqao
Image
may be Lexicon means like this in his post here http://www.purebasic.fr/english/viewtop ... 36&t=55816

Code: Select all

Enumeration
   #MESH = 100
   #MAT
   #plane
   #LIGHT
   #CAMERA
   #mainwin
   #ball
   
EndEnumeration
Global Quit.b = #False

ExamineDesktops()
OpenWindow(#mainwin, 0, 0, DesktopWidth(0), DesktopHeight(0), "multi textures", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
;Initialize environment
InitEngine3D()
InitSprite()
InitKeyboard()
OpenWindowedScreen(WindowID(#mainwin), 0, 0, DesktopWidth(0), DesktopHeight(0)-50, 0, 0, 0)

WorldShadows(#PB_Shadow_Modulative)
  
EnableWorldPhysics(#True)
EnableWorldCollisions(#True)
SetFrameRate(60)

Add3DArchive(".", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
Parse3DScripts()

LoadMesh(#plane, "plane_obj.mesh")
CreateEntity (#plane, MeshID(#plane), #PB_Material_None )
ScaleEntity(#plane,4,1,4)
EntityPhysicBody(#plane, #PB_Entity_StaticBody )
;SkyDome("clouds.jpg", 80) 
; create white texture
CreateTexture(7,16,16)
StartDrawing(TextureOutput(7))
Box(0, 0, 16, 16,RGB(0,255,0))
StopDrawing()
CreateMaterial(7, TextureID(7))
DisableMaterialLighting(7, #True)

CreateCube(#ball,0.5)
CreateEntity(#ball, MeshID(#ball), MaterialID(7),-2 ,5, 2)
;ScaleEntity(#ball,0.5,0.5,0.5)
;CreateLight(0,RGB(255,255,255),-100,40,30)
CreateLight(0,RGB(255,255,255),0,40,10)
AmbientColor(RGB(100,100,100))

EntityPhysicBody(#ball, #PB_Entity_BoxBody    ,1,0,0.2)

CreateCamera(#CAMERA, 0, 0, 400, 400)
MoveCamera(#CAMERA, 0, 4, 12)
CameraLookAt(#CAMERA, 0, 2, 0)

RotateCamera(#CAMERA, -15, 0, 0)

;WorldGravity(-2) ; less than normal gravity -9.8
rot.l=1
;Main loop
Repeat
  ExamineKeyboard()
  Event = WindowEvent()
  If KeyboardPushed(#PB_Key_Up)
    xxx.f+1
    RotateEntity(#plane, xxx,0,0)
  ElseIf KeyboardPushed(#PB_Key_Down)
    xxx.f-1
    RotateEntity(#plane, xxx,0,0)
  EndIf  
  x.f + rot
    
     
  RenderWorld()
   
  FlipBuffers()

Until KeyboardReleased(#PB_Key_Escape) Or Event = #PB_Event_CloseWindow

   
    
download Sculptris from here for free, they will send you a link to your email
http://pixologic.com/sculptris/
run Sculptris, click on new Plane, new scene. a default plane will created, click on symmetry button (to disable it)
Image
now you can rotate the plane by right mouse button
when you orient the plane just click on it to make hills and every click will make it bigger.
Image
now click on Paint button at the top right then ok,
click on show advanced tools (look below)
Image
enable texture button and disable brush (look above)
now click on the texture button and then click on New
now open the texture file , and it will be added to the list
click again on new and open another texture, and so on
Image
now click on save set, after finish click cancel to return to main progtam
now you can paint the texture which appears on the texture button, you can choose another textures
when you finish click on save texmap (the button are there if you previously clicked on show advanced tools), also save normal, and save bumps
now click on export to obj. and we finish the task
Image
============================
now you have something like plane.obj + texmap.png.
create a file called plane.mtl and write in it the following

Code: Select all

newmtl defaultMat
map_Kd texmap.png
now open the plane.pbj in notepad (since it is a text file in reality) and add these lines to the top

Code: Select all

mtllib plane.mtl
usemtl defaultMat
now copy all the files plane.obj, plane.mtl, texmap.png etc to the folder contains the utility OgreAssimpConverter http://www.purebasic.fr/english/viewtop ... 36&t=53022
from the command prompt write OgreAssimpConverter plane.obj
now there is a new plane_obj.mesh and plane_obj.material . change the characteristic of plane_obj.material as you want such as adding
cull_hardware none
cull_software none

to see the plane bottom
this procedure of manipulating the obj files i have found myself, but it is there in the web here http://blog.sculpteo.com/2010/08/06/tut ... ee-points/
http://www.drpetter.se/project_sculpt.html
http://www.photosculpt.net/dump/2010/11 ... -zbru.html

Re: using Sculptris 3D modelling for PureBasic

Posted: Tue Aug 13, 2013 12:58 pm
by Lexicon
applePi wrote:this is about using Sculptris to make models and texturing it for using it in purebasic
at first the project in witch a plane prepared and textured by Sculptris, then converted by OgreAssimpConverter (download it from Ogre tools/3D Programming section) to *.mesh then used by a purebasic program
Thanks applePi! I'll see this tool.

Re: using Sculptris 3D modelling for PureBasic

Posted: Tue Aug 13, 2013 7:10 pm
by DK_PETER
Good info ApplePi :-)