N3XTD: 3D engine
Re: N3XTD: 3D engine
No i dont mean the shader it self, i mean the integration in my programm vie PureBasic. I do NOT mean shaderprogramming! You know?
EDIT: If i close the application with the red cross in the right corner^^ (Close Window) the Application crashes, can you repair that ^^
With greetings from Germany
Arthur
EDIT: If i close the application with the red cross in the right corner^^ (Close Window) the Application crashes, can you repair that ^^
With greetings from Germany
Arthur
Re: N3XTD: 3D engine
@artus: if you want to close your app with the x button just use this callback (windows only)...
greetings from austria 
chi
Code: Select all
Global hWnd.l, CallBack.l, Close_n3xtd.b
Declare EnumProc(hwnd, lParam)
Declare GetCallingHwnd()
Declare Callback(Window, Message, wParam, lParam)
;...............................................................................................
IncludePath "includes" : IncludeFile "n3xtD_PB.pbi"
iSetAntiAlias(#True)
*app = iCreateGraphics3D(800, 500, 32, #False, #True, #EDT_DIRECT3D9)
Global *cam.ICamera = iCreateCamera()
iPositionNode(*cam, 0, 0, -2)
Global *cube.IMesh = iCreateCube(1.0)
hWnd = GetCallingHwnd()
CallBack = SetWindowLong_(hWnd, #GWL_WNDPROC, @Callback())
Repeat
iturnnode(*cube, 0.4, 0.4, 0.4)
iBeginScene(50, 50, 50)
iDrawScene()
iEndScene()
Until iGetKeyDown(#KEY_ESCAPE) Or Close_n3xtd = #True
iFreeEngine()
End
;...............................................................................................
Procedure EnumProc(hwnd, lParam)
*hwnd.LONG = lParam
*hwnd\l = hwnd
ProcedureReturn 0
EndProcedure
Procedure GetCallingHwnd()
*hwnd.LONG = AllocateMemory(SizeOf(LONG))
EnumThreadWindows_(GetCurrentThreadId_(), @EnumProc(),*hwnd)
ProcedureReturn*hwnd\l
EndProcedure
Procedure Callback(Window, Message, wParam, lParam)
Result = CallWindowProc_(CallBack, Window, Message, wParam, lParam)
Select Message
Case #WM_CLOSE
Close_n3xtd = #True
EndSelect
ProcedureReturn Result
EndProcedure

chi
Et cetera is my worst enemy
Re: N3XTD: 3D engine
OK, I'll get back the example 201 in the retailer.Artus wrote:No i dont mean the shader it self, i mean the integration in my programm vie PureBasic.
some global initializations,
Code: Select all
; Include files
IncludePath "includes" : IncludeFile "n3xtD_PB.pbi"
EnableExplicit
Declare CallbackShader(*services.IMaterialServices, userData.l)
; Globales
Global anglex.f, angley.f, flagXDown.w
Global mox.f, omx.f, moy.l, omy.l
Global *app.l, Quit.l, video.l
;----------------------------------------------------------
; open n3xt-D screen
*app = iCreateGraphics3D(800,600) : video = #EDT_OPENGL
; << OR >>
;*app = iCreateGraphics3D(800,600, 32, #False, #True, #EDT_DIRECT3D9) : video = #EDT_DIRECT3D9
If *app= #Null
End
EndIf
SetCurrentDirectory("media/")
;-----------------------------------------
; create skybox
Global *sky.IMesh = iCreateSkybox( iLoadTexture("up.jpg"),iLoadTexture("dn.jpg"),iLoadTexture("lf.jpg"),iLoadTexture("rt.jpg"),iLoadTexture("ft.jpg"),iLoadTexture("bk.jpg"))
Load and create two Shaders (HLSL or GLSL).
we make the difference between DX9 and OpenGL to load the correct class of shader.
We use for this, the iCreateShaderHighLevel instruction:
iCreateShaderHighLevel.l(vsFileName.s, EntryNameVS.s, psFileName.s, EntryNamePS.s, videottype.l, *constantshaderFnt.l, *materialshaderFnt.l )
with this parameters:
vsFileName: vertex shader filename to load.
EntryNameVS.s: entry name procedure inside the shader for the vertex shader program.
psFileName.s: pixel shader filename to load.
EntryNamePS.s: entry name procedure inside the shader for the pixel shader program.
videottype.l: the number of the material type which can be set in SMaterial::MaterialType to use the renderer
*constantshaderFnt.l: Pointer to an implementation of OnSetConstants in which you can set the needed vertex and pixel shader.
*materialshaderFnt.l: not used here.
Code: Select all
;-----------------------------------------
; load and create shader
Global shad.l
Global shad2.l
iVersionShader(#EVST_VS_1_1, #EPST_PS_2_0)
If video = #EDT_DIRECT3D9
shad = iCreateShaderHighLevel("d3d9.hlsl", "vertexMain", "d3d9.hlsl", "pixelMain", #EMT_SOLID, @CallbackShader(), #Null)
shad2 = iCreateShaderHighLevel("d3d9.hlsl", "vertexMain", "d3d9.hlsl", "pixelMain", #EMT_TRANSPARENT_ADD_COLOR, @CallbackShader(), #Null)
Else
shad = iCreateShaderHighLevel("opengl.vert", "vertexMain", "opengl.frag", "pixelMain", #EMT_SOLID, @CallbackShader(), #Null)
shad2 = iCreateShaderHighLevel("opengl.vert", "vertexMain", "opengl.frag", "pixelMain", #EMT_TRANSPARENT_ADD_COLOR, @CallbackShader(), #Null)
EndIf
create one cube without shader,
Code: Select all
;-----------------------------------------
; add cube
Global *cube0.IMesh = iCreateCube(1.0)
iPositionNode(*cube0, -1,-1,1)
iLoadTextureNode(*cube0, "wall.jpg")
iMaterialFlagNode(*cube0, #EMF_LIGHTING, #False)
and create two cubes with shader for de rendering.
This is the instruction line iMaterialTypeNode(*cube, shad) which assigns to our cube a specific shader.
Code: Select all
;-----------------------------------------
; add second cube
Global *cube.IMesh = iCreateCube(1.0)
iPositionNode(*cube, 0,-1.3,0)
iLoadTextureNode(*cube, "wall.jpg")
iMaterialFlagNode(*cube, #EMF_LIGHTING, #False)
iMaterialTypeNode(*cube, shad)
;-----------------------------------------
; add third cube
Global *cube2.IMesh = iCreateCube(1.0)
iPositionNode(*cube2, 1,-1.3,1)
iLoadTextureNode(*cube2, "wall.jpg")
iMaterialFlagNode(*cube2, #EMF_LIGHTING, #False)
iMaterialTypeNode(*cube2, shad2)
Code: Select all
;-----------------------------------------
; create first camera
Global *cam.ICamera = iCreateCamera( )
iPositionNode(*cam, 0,0,-3)
iTurnNode(*cam, 10,0,0)
and main loop, standart.
Code: Select all
Repeat
iTurnNode(*cube0, 0,0.5,0)
iTurnNode(*cube, 0,0.5,0)
iTurnNode(*cube2, 0,0.5,0)
; ------------------------------------------------
; move camera with dir key and mouse (left click)
If iGetKeyDown(#KEY_ARROW_UP)
iMoveNode(*cam, 0,0,0.1)
EndIf
If iGetKeyDown(#KEY_ARROW_DOWN)
iMoveNode(*cam, 0,0,-0.1)
EndIf
If iGetMouseEvent(#MOUSE_BUTTON_LEFT)
If flagXDown=0
omx = iGetMouseX()
omy = iGetMouseY()
flagXDown=11
Else
moy = iGetMouseY()-omy
angley=(moy/10.0)
omy= iGetMouseY()
mox = iGetMouseX()-omx
anglex=(mox/10.0)
omx= iGetMouseX()
iTurnNode(*cam, angley, anglex,0)
EndIf
Else
flagXDown=0
EndIf
; if Escape Key, exit
If iGetKeyDown(#KEY_ESCAPE)
Quit=1
EndIf
; ---------------
; Render
; ---------------
iBeginScene(100,100,100)
iDrawScene()
iEndScene()
Until Quit=1
; end
iFreeEngine()
Finally, an important procedure.
ShaderCallback, this procedure call at the each render pass for each node to which we assigned
a shader that link to this proceeding.
it is this area which will provide the data necessary for the shader run.
This procedure (CallBack) allows to update a set of data necessary for the proper
functioning of the shader and before each rendering.
Code: Select all
ProcedureC CallbackShader(*services.IMaterialServices, userData.l)
Protected mvp.iMATRIX
Protected invWorld.iMATRIX
Protected worldViewProj.iMATRIX
Protected pos.iVECTOR3
Protected Dim col.f(3)
Protected world.iMATRIX
iGetWorldTransform(@invWorld)
Matrix_GetInverse( @invWorld, @invWorld)
iVertexShaderConstantNMaterialServices(*services, "mInvWorld", @invWorld, 16)
;set clip matrix
iGetProjectionTransform(@worldViewProj)
iGetViewTransform(@mvp)
Matrix_Mul(@worldViewProj, @worldViewProj, @mvp)
iGetWorldTransform(@mvp)
Matrix_Mul(@worldViewProj, @worldViewProj, @mvp)
iVertexShaderConstantNMaterialServices(*services, "mWorldViewProj", @worldViewProj, 16)
; set camera position
iNodePosition(*cam, @pos)
iVertexShaderConstantNMaterialServices(*services, "mLightPos", @pos, 3)
; set light color
col(0)=0.0
col(1)=1.0
col(2)=1.0
col(3)=0.0
iVertexShaderConstantNMaterialServices(*services, "mLightColor", @col(0), 4)
; set transposed world matrix
iGetWorldTransform(@world)
Matrix_Transpose(@world)
iVertexShaderConstantNMaterialServices(*services, "mTransWorld", @world, 16)
EndProcedure
Well, I hope this clarifies a little better your lantern on the use of shaders by N3xtD and PB.
@chi good code

Re: N3XTD: 3D engine
I have try it but i have this error:
What must i do?
EDIT:
I have solution by my self, but now i get a error, at the end of teh CallBack Procedure, I becomme a IMA? why that
oh code^^
MfG
Arthur
Code: Select all
HLSL Variable to set not found: 'mWorldViewProj'. Available varia
'cameraPos' Registers:[begin:22, count:1]
'light' Registers:[begin:0, count:8]
'material' Registers:[begin:12, count:4]
'worldInverseTransposeMatrix' Registers:[begin:19, count:3]
'worldMatrix' Registers:[begin:16, count:3]
'worldViewProjectionMatrix' Registers:[begin:8, count:4]
....
EDIT:
I have solution by my self, but now i get a error, at the end of teh CallBack Procedure, I becomme a IMA? why that

oh code^^
Code: Select all
ProcedureC CallbackShader(*services.IMaterialServices, userData.l)
Protected mvp.iMATRIX
Protected invWorld.iMATRIX
Protected worldViewProj.iMATRIX
Protected pos.iVECTOR3
Protected Dim col.f(3)
Protected world.iMATRIX
iGetWorldTransform(@invWorld)
Matrix_GetInverse( @invWorld, @invWorld)
iVertexShaderConstantNMaterialServices(*services, "worldInverseTransposeMatrix", @invWorld, 16)
;set clip matrix
iGetProjectionTransform(@worldViewProj)
iGetViewTransform(@mvp)
Matrix_Mul(@worldViewProj, @worldViewProj, @mvp)
iGetWorldTransform(@mvp)
Matrix_Mul(@worldViewProj, @worldViewProj, @mvp)
iVertexShaderConstantNMaterialServices(*services, "worldViewProjectionMatrix", @worldViewProj, 16)
; set camera position
iNodePosition(*cam, @pos)
iVertexShaderConstantNMaterialServices(*services, "cameraPos", @pos, 3)
;iVertexShaderConstantNMaterialServices(*services, "light", *light, 3)
; set transposed world matrix
iGetWorldTransform(@world)
Matrix_Transpose(@world)
iVertexShaderConstantNMaterialServices(*services, "worldMatrix", @world, 16)
EndProcedure
Code: Select all
//-----------------------------------------------------------------------------
// Copyright (c) 2007-2008 dhpoware. All Rights Reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
//
// This D3DX Effect file implements tangent space normal mapping.
//
// Three techniques are provided for each of the three lighting types:
// directional lighting, point lighting, and spotlight lighting.
//
// Tangent space normal mapping involves evaluating the lighting equations per
// pixel in the surface local coordinate space of the normal map texture.
// Rather than using the mesh's interpolated vertex normals tangent space
// normal mapping uses the normals from the normal map texture instead. Doing
// this allows additional surface detail to be applied to each face of the mesh
// without requiring extra geometry to be added to each face.
//
// The lighting vectors are transformed into the normal map texture's tangent
// space using a rotation matrix. This rotation matrix must be calculated for
// each face of the mesh. Each face has its own rotation matrix because each
// face is uniquely texture mapped to the normal map texture and the rotation
// matrix must take this into consideration. The rotation matrix is constructed
// using each face's tangent, bitangent, and normal vectors.
//
// The pixel shader used in tangent space normal mapping is identical to the
// pixel shader used in per-pixel lighting. The only difference is the normal
// used is read from the normal map texture rather that being interpolated by
// the rasterizer. Prior to being stored in the normal map texture the normals
// are in the range [-1,1]. Once stored in the normal map texture the normals
// will be compressed to the range [0,255]. When the normals are accessed from
// the pixel shader HLSL will remap then to the range [0,1]. To convert the
// normals back to the original [-1,1] range we need to perform a scale and a
// bias. We do this by: tex2D(normalMap, IN.texCoord) * 2.0f - 1.0f.
//
// Light attenuation for the point and spot lighting models is based on a
// light radius. Light is at its brightest at the center of the sphere defined
// by the light radius. There is no lighting at the edges of this sphere.
//
//-----------------------------------------------------------------------------
struct Light
{
float3 dir; // world space direction
float3 pos; // world space position
float4 ambient;
float4 diffuse;
float4 specular;
float spotInnerCone; // spot light inner cone (theta) angle
float spotOuterCone; // spot light outer cone (phi) angle
float radius; // applies to point and spot lights only
};
struct Material
{
float4 ambient;
float4 diffuse;
float4 emissive;
float4 specular;
float shininess;
};
//-----------------------------------------------------------------------------
// Globals.
//-----------------------------------------------------------------------------
float4x4 worldMatrix;
float4x4 worldInverseTransposeMatrix;
float4x4 worldViewProjectionMatrix;
float3 cameraPos;
float4 globalAmbient;
Light light;
Material material;
//-----------------------------------------------------------------------------
// Textures.
//-----------------------------------------------------------------------------
texture colorMapTexture;
texture normalMapTexture;
sampler2D colorMap = sampler_state
{
Texture = <colorMapTexture>;
MagFilter = Linear;
MinFilter = Anisotropic;
MipFilter = Linear;
MaxAnisotropy = 16;
};
sampler2D normalMap = sampler_state
{
Texture = <normalMapTexture>;
MagFilter = Linear;
MinFilter = Anisotropic;
MipFilter = Linear;
MaxAnisotropy = 16;
};
//-----------------------------------------------------------------------------
// Vertex Shaders.
//-----------------------------------------------------------------------------
struct VS_INPUT
{
float3 position : POSITION;
float2 texCoord : TEXCOORD0;
float3 normal : NORMAL;
float4 tangent : TANGENT;
};
struct VS_OUTPUT_DIR
{
float4 position : POSITION;
float2 texCoord : TEXCOORD0;
float3 halfVector : TEXCOORD1;
float3 lightDir : TEXCOORD2;
float4 diffuse : COLOR0;
float4 specular : COLOR1;
};
struct VS_OUTPUT_POINT
{
float4 position : POSITION;
float2 texCoord : TEXCOORD0;
float3 viewDir : TEXCOORD1;
float3 lightDir : TEXCOORD2;
float4 diffuse : COLOR0;
float4 specular : COLOR1;
};
struct VS_OUTPUT_SPOT
{
float4 position : POSITION;
float2 texCoord : TEXCOORD0;
float3 viewDir : TEXCOORD1;
float3 lightDir : TEXCOORD2;
float3 spotDir : TEXCOORD3;
float4 diffuse : COLOR0;
float4 specular : COLOR1;
};
VS_OUTPUT_DIR VS_DirLighting(VS_INPUT IN)
{
VS_OUTPUT_DIR OUT;
float3 worldPos = mul(float4(IN.position, 1.0f), worldMatrix).xyz;
float3 lightDir = -light.dir;
float3 viewDir = cameraPos - worldPos;
float3 halfVector = normalize(normalize(lightDir) + normalize(viewDir));
float3 n = mul(IN.normal, (float3x3)worldInverseTransposeMatrix);
float3 t = mul(IN.tangent.xyz, (float3x3)worldInverseTransposeMatrix);
float3 b = cross(n, t) * IN.tangent.w;
float3x3 tbnMatrix = float3x3(t.x, b.x, n.x,
t.y, b.y, n.y,
t.z, b.z, n.z);
OUT.position = mul(float4(IN.position, 1.0f), worldViewProjectionMatrix);
OUT.texCoord = IN.texCoord;
OUT.halfVector = mul(halfVector, tbnMatrix);
OUT.lightDir = mul(lightDir, tbnMatrix);
OUT.diffuse = material.diffuse * light.diffuse;
OUT.specular = material.specular * light.specular;
return OUT;
}
VS_OUTPUT_POINT VS_PointLighting(VS_INPUT IN)
{
VS_OUTPUT_POINT OUT;
float3 worldPos = mul(float4(IN.position, 1.0f), worldMatrix).xyz;
float3 viewDir = cameraPos - worldPos;
float3 lightDir = (light.pos - worldPos) / light.radius;
float3 n = mul(IN.normal, (float3x3)worldInverseTransposeMatrix);
float3 t = mul(IN.tangent.xyz, (float3x3)worldInverseTransposeMatrix);
float3 b = cross(n, t) * IN.tangent.w;
float3x3 tbnMatrix = float3x3(t.x, b.x, n.x,
t.y, b.y, n.y,
t.z, b.z, n.z);
OUT.position = mul(float4(IN.position, 1.0f), worldViewProjectionMatrix);
OUT.texCoord = IN.texCoord;
OUT.viewDir = mul(viewDir, tbnMatrix);
OUT.lightDir = mul(lightDir, tbnMatrix);
OUT.diffuse = material.diffuse * light.diffuse;
OUT.specular = material.specular * light.specular;
return OUT;
}
VS_OUTPUT_SPOT VS_SpotLighting(VS_INPUT IN)
{
VS_OUTPUT_SPOT OUT;
float3 worldPos = mul(float4(IN.position, 1.0f), worldMatrix).xyz;
float3 viewDir = cameraPos - worldPos;
float3 lightDir = (light.pos - worldPos) / light.radius;
float3 n = mul(IN.normal, (float3x3)worldInverseTransposeMatrix);
float3 t = mul(IN.tangent.xyz, (float3x3)worldInverseTransposeMatrix);
float3 b = cross(n, t) * IN.tangent.w;
float3x3 tbnMatrix = float3x3(t.x, b.x, n.x,
t.y, b.y, n.y,
t.z, b.z, n.z);
OUT.position = mul(float4(IN.position, 1.0f), worldViewProjectionMatrix);
OUT.texCoord = IN.texCoord;
OUT.viewDir = mul(viewDir, tbnMatrix);
OUT.lightDir = mul(lightDir, tbnMatrix);
OUT.spotDir = mul(light.dir, tbnMatrix);
OUT.diffuse = material.diffuse * light.diffuse;
OUT.specular = material.specular * light.specular;
return OUT;
}
//-----------------------------------------------------------------------------
// Pixel Shaders.
//-----------------------------------------------------------------------------
float4 PS_DirLighting(VS_OUTPUT_DIR IN) : COLOR
{
float3 n = normalize(tex2D(normalMap, IN.texCoord).rgb * 2.0f - 1.0f);
float3 h = normalize(IN.halfVector);
float3 l = normalize(IN.lightDir);
float nDotL = saturate(dot(n, l));
float nDotH = saturate(dot(n, h));
float power = (nDotL == 0.0f) ? 0.0f : pow(nDotH, material.shininess);
float4 color = (material.ambient * (globalAmbient + light.ambient)) +
(IN.diffuse * nDotL) + (IN.specular * power);
return color * tex2D(colorMap, IN.texCoord);
}
float4 PS_PointLighting(VS_OUTPUT_POINT IN) : COLOR
{
float atten = saturate(1.0f - dot(IN.lightDir, IN.lightDir));
float3 n = normalize(tex2D(normalMap, IN.texCoord).rgb * 2.0f - 1.0f);
float3 l = normalize(IN.lightDir);
float3 v = normalize(IN.viewDir);
float3 h = normalize(l + v);
float nDotL = saturate(dot(n, l));
float nDotH = saturate(dot(n, h));
float power = (nDotL == 0.0f) ? 0.0f : pow(nDotH, material.shininess);
float4 color = (material.ambient * (globalAmbient + (atten * light.ambient))) +
(IN.diffuse * nDotL * atten) + (IN.specular * power * atten);
return color * tex2D(colorMap, IN.texCoord);
}
float4 PS_SpotLighting(VS_OUTPUT_SPOT IN) : COLOR
{
float atten = saturate(1.0f - dot(IN.lightDir, IN.lightDir));
float3 l = normalize(IN.lightDir);
float2 cosAngles = cos(float2(light.spotOuterCone, light.spotInnerCone) * 0.5f);
float spotDot = dot(-l, normalize(IN.spotDir));
float spotEffect = smoothstep(cosAngles[0], cosAngles[1], spotDot);
atten *= spotEffect;
float3 n = normalize(tex2D(normalMap, IN.texCoord).rgb * 2.0f - 1.0f);
float3 v = normalize(IN.viewDir);
float3 h = normalize(l + v);
float nDotL = saturate(dot(n, l));
float nDotH = saturate(dot(n, h));
float power = (nDotL == 0.0f) ? 0.0f : pow(nDotH, material.shininess);
float4 color = (material.ambient * (globalAmbient + (atten * light.ambient))) +
(IN.diffuse * nDotL * atten) + (IN.specular * power * atten);
return color * tex2D(colorMap, IN.texCoord);
}
//-----------------------------------------------------------------------------
// Techniques.
//-----------------------------------------------------------------------------
technique NormalMappingDirectionalLighting
{
pass
{
VertexShader = compile vs_2_0 VS_DirLighting();
PixelShader = compile ps_2_0 PS_DirLighting();
}
}
technique NormalMappingPointLighting
{
pass
{
VertexShader = compile vs_2_0 VS_PointLighting();
PixelShader = compile ps_2_0 PS_PointLighting();
}
}
technique NormalMappingSpotLighting
{
pass
{
VertexShader = compile vs_2_0 VS_SpotLighting();
PixelShader = compile ps_2_0 PS_SpotLighting();
}
}
MfG
Arthur
Re: N3XTD: 3D engine
I have the same problem with N3xtD and PB v4.30.I have solution by my self, but now i get a error, at the end of teh CallBack Procedure, I becomme a IMA? why that
by cons, it works fine with PureBasic v4.40 b5 and the upcoming version N3xtD (which should be available in the coming days).
Re: N3XTD: 3D engine
Hi tmyke
Thank you for your excelent work with n3xtd.
But I have a problem with sphere mapping in Directx mode. It works great in OpenGL mode.
Is this a known problem..or is it just me?
Regards
Sveinung
Thank you for your excelent work with n3xtd.
But I have a problem with sphere mapping in Directx mode. It works great in OpenGL mode.
Is this a known problem..or is it just me?
Code: Select all
*obj.IObject=iLoad3DObject("HighSphere.x")
*hsphere.IMesh=iCreateMesh(*obj)
*hs_mat.IMaterial=iNodeMaterial(*hsphere)
*hs_tex.ITexture=iLoadTexture( "blue.jpg")
iTextureMaterial(*hs_mat,0,*hs_tex)
iMaterialTypeNode(*hsphere,#EMT_SPHERE_MAP)
Sveinung
Re: N3XTD: 3D engine
Hi tmyke, what`s up with your website ? Seems down 

Athlon X2 7850 - Geforce 8800 GTS 640mb - 8 GB Ram - Vista Home Premium 64 bit SP2
- max_aigneraigner@web.de
- User
- Posts: 67
- Joined: Sun Nov 02, 2008 10:37 pm
- Location: Bavaria
- Contact:
Re: N3XTD: 3D engine
3D Projects
A ship is safest in the harbor, but that is not what ships are built for.
A ship is safest in the harbor, but that is not what ships are built for.
- max_aigneraigner@web.de
- User
- Posts: 67
- Joined: Sun Nov 02, 2008 10:37 pm
- Location: Bavaria
- Contact:
Re: N3XTD: 3D engine
LOL^^.. now the forum is down... hopefully nothing serious?
well, but: bugreport:
First:
hope to be helpful

lg
walker
ps: if the down site means something more: keep going! we stand right behind you! great engine!
[edit] if I load one mesh twice, does the engine realice that and just copy the first mesh? automatically? is it the same with textures? [/edit]
well, but: bugreport:
First:
in n3xt_AABB.pbi (n3xtd-the include file)AABBox_Extend(*ext.ivector3, *box.AABBOX)
looks like this:isn't the vec3_mulF(*ext,*ext,0.5) - Command wrong? it makes the extend of the node half es big as it is..? probably that is a "bug" I just removed that line...Code: Select all
Procedure AABBox_Extend(*ext.ivector3, *box.AABBOX) Vec3_Zero(*ext) Vec3_Sub(*ext, @*box\MaxEdge, @*box\MinEdge) Vec3_MulF(*ext, *ext, 0.5) EndProcedure
- The Command itargetcamera ( *cam , 100,0,100) doesn't work..
it should set the lookat of the camera to a specific point, shouldn't it ?
(I really need this command.. would be great to fix it)
Code: Select all
; ------------------------------------------------------------
; n3xt-D exemples
;
; Sample 002 : load a simple 3D object ad set mesh
; Historique :
; 29/03/09 19:16 TMyke
;
; ------------------------------------------------------------
; Include files
IncludePath #PB_Compiler_Home + "Examples\sample_n3xtd\includes" : IncludeFile "n3xtD_PB.pbi"
; Globales
Global anglex.f, angley.f, flagXDown.w
Global mox.f, omx.f, moy.l, omy.l
Global *app.l, Quit.l
;----------------------------------------------------------
; open n3xt-D screen
*app = iCreateGraphics3D(800,600)
; << OR >>
;*app=iCreateGraphics3D(800,600, 32, #False, #True, #EDT_DIRECT3D9)
If *app= #Null
End
EndIf
; create a mesh with one of the 3D object loaded
Global *sphere.IMesh = icreatecube ( 10)
iPositionNode ( *sphere , 100,0,100)
; set debug information
iDebugModeNode(*sphere, #EDS_BBOX )
; create a camera
Define *cam.ICamera = iCreateCamera( )
iPositionNode(*cam, 0,0,-5)
iTargetAndRotationCamera (*cam ,1)
; ---------------------------------------
; main loop
; ---------------------------------------
Repeat
itargetcamera ( *cam , 100,0,100)
; move camera with dir key and mouse (left click)
If iGetKeyDown(#KEY_ARROW_UP)
iMoveNode(*cam, 0,0,0.5)
EndIf
If iGetKeyDown(#KEY_ARROW_DOWN)
iMoveNode(*cam, 0,0,-0.5)
EndIf
If iGetMouseEvent(#MOUSE_BUTTON_LEFT)
If flagXDown=0
omx = iGetMouseX()
omy = iGetMouseY()
flagXDown=11
Else
moy = iGetMouseY()-omy
angley=(moy/10.0)
omy= iGetMouseY()
mox = iGetMouseX()-omx
anglex=(mox/10.0)
omx= iGetMouseX()
iTurnNode(*cam, angley, anglex,0)
EndIf
Else
flagXDown=0
EndIf
; just turn our sphere
iTurnNode(*sphere, 0,0.5,0)
; if Escape Key, exit
If iGetKeyDown(#KEY_ESCAPE)
Quit=1
EndIf
; ---------------
; Render
; ---------------
iBeginScene()
iDrawScene()
iDrawGUI()
iEndScene()
Until Quit=1
; end
iFreeEngine()
; IDE Options = PureBasic 4.30 Beta 5 (Windows - x86)
; ExecutableFormat = Console
; CursorPosition = 55
; FirstLine = 24


lg
walker
ps: if the down site means something more: keep going! we stand right behind you! great engine!
[edit] if I load one mesh twice, does the engine realice that and just copy the first mesh? automatically? is it the same with textures? [/edit]
3D Projects
A ship is safest in the harbor, but that is not what ships are built for.
A ship is safest in the harbor, but that is not what ships are built for.
- max_aigneraigner@web.de
- User
- Posts: 67
- Joined: Sun Nov 02, 2008 10:37 pm
- Location: Bavaria
- Contact:
Re: N3XTD: 3D engine
YEAH!!! LOL you don't KNOW how LONG I have searched to find this easy!! solution
^^
I did look in matrixcalculation, and thought about strange things like this: (doesn't function.. just to give you a look hehe ) :
(why didn't that work?)
But, What IS running is the following short codeline o.O
sofar, the problem with the targetcamera is adjustable
lg and hopefully from now on it will work fine hehe
-walker
[edit] öh ps: ifreetexture ( *texture ) causes always a program crash at the command idrawscene().. [/edit]


I did look in matrixcalculation, and thought about strange things like this: (doesn't function.. just to give you a look hehe ) :
Code: Select all
Procedure e3d_targetCamera ( CameraID.i , x.f , y.f , z.f )
Protected xaxis.ivector3 , yaxis.ivector3 , zaxis.ivector3 , cameraPosition.ivector3 , cameraUpVector.ivector3 ,mat.iMATRIX , cameraTarget.ivector3 , targetrotation.ivector3
If Not CameraID : ProcedureReturn : EndIf
iCameraUpVector ( CameraID , @cameraUpVector )
cameraTarget\x = x
cameraTarget\y = y
cameraTarget\z = z
iNodePosition ( CameraID , @cameraPosition )
Vec3_Sub ( @zaxis , @cameraTarget , @cameraPosition )
Vec3_Normalize ( @zaxis )
Vec3_CrossProduct ( @xaxis , @cameraUpVector , @zaxis )
Vec3_Normalize ( @yaxis )
Vec3_CrossProduct ( @yaxis , @zaxis, @xaxis)
mat\m[1] = xaxis\x
mat\m[2] = yaxis\x
mat\m[3] = zaxis\x
mat\m[4] = 0
mat\m[5] = xaxis\y
mat\m[6] = yaxis\y
mat\m[7] = zaxis\y
mat\m[8] = 0
mat\m[9] = xaxis\z
mat\m[10] = yaxis\z
mat\m[11] = zaxis\z
mat\m[12] = 0
mat\m[13] = -Vec3_DotProduct( @xaxis , @cameraPosition )
mat\m[14] = -Vec3_DotProduct( @yaxis , @cameraPosition )
mat\m[15] = -Vec3_DotProduct( @zaxis , @cameraPosition )
mat\m[16] = 1
; Matrix_Transpose ( @mat )
; ; Matrix_RotateVect(@mat , @targetrotation ) ; no reaction
Matrix_GetRotation ( @targetrotation , @mat )
irotatenode ( CameraID , targetrotation\x , targetrotation\y , targetrotation\z )
EndProcedure
But, What IS running is the following short codeline o.O
just another command to achieve the same thing, and THIS really WORKS heheiPointTargetNode ( *camera , px , py , pz )

sofar, the problem with the targetcamera is adjustable
lg and hopefully from now on it will work fine hehe
-walker
[edit] öh ps: ifreetexture ( *texture ) causes always a program crash at the command idrawscene().. [/edit]
3D Projects
A ship is safest in the harbor, but that is not what ships are built for.
A ship is safest in the harbor, but that is not what ships are built for.
Re: N3XTD: 3D engine
Tmyke where are you???? we need you!
MfG Arthur
MfG Arthur
Re: N3XTD: 3D engine
Does anybody have a copy of this that they can upload? I cannot find a download anywhere. 

▓▓▓▓▓▒▒▒▒▒░░░░░
- max_aigneraigner@web.de
- User
- Posts: 67
- Joined: Sun Nov 02, 2008 10:37 pm
- Location: Bavaria
- Contact:
Re: N3XTD: 3D engine
here is the build20 on the server of "chi" (german forum.. who ever it is, Thanx:D
)
http://lunamedia.heim.at/files/n3xtd_20.zip
http://lunamedia.heim.at/files/n3xtd-lightmap.zip
greetings
walker

http://lunamedia.heim.at/files/n3xtd_20.zip
http://lunamedia.heim.at/files/n3xtd-lightmap.zip
greetings
walker
3D Projects
A ship is safest in the harbor, but that is not what ships are built for.
A ship is safest in the harbor, but that is not what ships are built for.
- max_aigneraigner@web.de
- User
- Posts: 67
- Joined: Sun Nov 02, 2008 10:37 pm
- Location: Bavaria
- Contact:
Re: N3XTD: 3D engine
Ha! the site and forum are down, but the WIKI is still running
^^
hey mike, if you are working on other projects then please please just tell us or upload the site again!
even at this state n3xtd is better than every other pb-engine we had here (for free, personal opinion)

hey mike, if you are working on other projects then please please just tell us or upload the site again!
even at this state n3xtd is better than every other pb-engine we had here (for free, personal opinion)
3D Projects
A ship is safest in the harbor, but that is not what ships are built for.
A ship is safest in the harbor, but that is not what ships are built for.