Hi all,
I was vanishing for a while , but i am here again.
Here is my latest test for MagicPro , it uses irrlicht for playing 2 3d objects , ninja (is a b3d file fromat) and
dragon (is a MD2 file format).
also uses indieLib for render indie 2d entity ( loading octopus image in indie surface the assign it to
a 2d Entity)
Here is the source code of the demo , screen shot in the botton.
//****************************//
// ************ //
// ***MagicPro library*** //
// ************ //
//****************************//
//includepath "$/inc/"
$ filename "INDtest1.exe"
#include "..\..\inc\RTL32.inc"
#include "MagicPro.inc"
sys cam,ogrehead,light,SPrg,MskPrg,mskId,Movie,hgeSprite,MousX,MousY
sys IND_Surf,IND_Entty2d
void QueueStarted() , callback
{
Screen_Use2DView()
ML_StartShaderPrg(SPrg)
DrawMovieToScreen(Movie,0,0,1024,768)
ML_StartShaderPrg(MskPrg)
ML_SetTexture(Image_GetPointer(mskId),1)
hgeSprite_Render(hgeSprite,MousX,MousY)
ML_SetTexture(0,1)
ML_StopShaderPrg()
IND_RenderEntities2d()
Screen_Stop2DView()
}
void QueueMain() , callback
{
IrrDrawSceneEx( RenderLights | RenderDefaultObjects)
}
Init("MagicPro IndieLib Test #1")
Graphics3D(1024,768)
defineQueueStarted(@QueueStarted)
defineQueueMain(@QueueMain)
setMediaDir("ZipMedia.zip")
setMediaDir("media")
setAmbientLight(30.0,30.0,50.0)
cam = CreateCamera
CameraRange(cam,1.0,1000.0)
ogrehead = LoadMesh("ogrehead.mesh",0,"")
PositionEntity(ogrehead,0.0,0.0,-150.0)
light = CreateLight()
PositionEntity(light,-100.0,100.0,0.0)
LightColor(light,255.0,200.0,150.0)
Movie = LoadMovie("Sandra - Infinite Kiss ( 2012 ).mpg")
LoopMovie(Movie,true)
RunMovie(Movie)
SPrg = ML_CreateHLSLPrg()
ML_EditPixelPrg(SPrg)
ML_AddToPrg("sampler2D tex0; ")
ML_AddToPrg("float4 main( float2 TexCoord : TEXCOORD0) : COLOR0 ")
ML_AddToPrg("{ ")
ML_AddToPrg(" float4 col = tex2D( tex0, TexCoord ); ")
ML_AddToPrg(" float gry = col.r*0.299+col.g*0.587+col.b*0.184; ")
ML_AddToPrg(" return float4(gry,gry,gry,col.a); ")
ML_AddToPrg("} ")
ML_CompilePixelPrg(SPrg,"main")
sys id = GetImageIDOfMovie(Movie)
single imgh = Image_GetHeight id
single imgw = Image_GetWidth id
hgeSprite = make_hgeSprite(id,0.0,0.0,imgw,imgh)
mskId = Image_GetFreeID()
Image_load ( mskId , "irr_media/lightFalloff.png")
MskPrg = ML_CreateHLSLPrg()
ML_EditPixelPrg(MskPrg)
ML_AddToPrg("sampler2D tex0; ")
ML_AddToPrg("sampler2D tex1; ")
ML_AddToPrg("float4 main( float2 TexCoord : TEXCOORD0) : COLOR0 ")
ML_AddToPrg("{ ")
ML_AddToPrg(" float4 c1 = tex2D( tex0, TexCoord ); ")
ML_AddToPrg(" float4 c2 = tex2D( tex1, TexCoord ); ")
ML_AddToPrg(" return float4(c1.r,c1.g,c1.b,c2.r); ")
ML_AddToPrg("} ")
ML_CompilePixelPrg(MskPrg,"main")
sys mesh,node,node2
mesh = IrrGetMesh("irr_media/ninja.b3d",true)
node = IrrAddMeshToScene(mesh)
IrrSetNodePosition(node,0.0,0.0,-80.0)
IrrSetNodeMaterialFlag(node,IRR_EMF_LIGHTING,true)
mesh = IrrGetMesh("irr_media/dragon.md2",true)
node2 = IrrAddMeshToScene(mesh)
id = Image_GetFreeID()
Image_load(id,"irr_media/dragon.bmp")
sys IrrTxt = Image_GetIrrTexture(id)
IrrSetNodeMaterialTexture( node2 ,IrrTxt)
IrrSetNodePosition(node2,-30.0,0.0,-80.0)
IrrSetNodeScale(node2,0.25,0.25,0.25)
IrrSetNodeRotation(node2,0.0,-90.0,0.0)
IrrSetAmbientLight(1.0,1.0,1.0)
IND_Surf = IND_NewSurface()
IND_SurfaceMgrAdd(IND_Surf, "octopus.png", IND_ALPHA, IND_32)
IND_Entty2d = IND_NewEntity2d()
IND_Entity2dMgrAdd(IND_Entty2d)
IND_Entity2dSetSurface(IND_Entty2d,IND_Surf)
IND_Entity2dSetPosition(IND_Entty2d,700.0, 270.0, 0)
while not OIS_isKeyDown(KC_ESCAPE)
{
DoEvents
MousX = OIS_mouseX()
MousY = OIS_mouseY()
RenderWorld()
Sync()
}
DeleteMovie(Movie)
EndGraphics()
X