![Smile :-)](./images/smilies/icon_smile.gif)
*EDIT* yup that's all it was, performs fantastic now.
![Smile :-)](./images/smilies/icon_smile.gif)
I think now I would definitely prefer this ove rthe stock wrapper. should be much easier to customize. If we could make all the scenenodes inheritable, we will have it made
![Smile :-)](./images/smilies/icon_smile.gif)
The kid on my avatar wrote:A painless lesson is one without any meaning
PS : Due to a stupid bug, I had to move the files to a temporary ftp, right here :Change Log wrote:Irrlicht .NET CP 0.4 :
-Corrected F Key enumeration (thanks to Rowan Lewis)
-Added Vector2D structure (thanks to sh1ny)
-Added VideoDriver.DeleteAllDynamicLights (thanks to sh1ny)
-Added ToBCL/FromBCL methods to Color/Colorf and Rect structures. These methods can be used to convert to standard .NET.
-Changed main namespace from "Irrlicht.NET" to "IrrlichtNETCP" due to several issues (thanks to dmoonfire for the idea)
-Improved a lot MeshManipulator wrapper with documentation.
-Now uses Irrlicht 1.1, list of modifications :
-Changed AddTestSceneNode to AddCubeSceneNode.
-Added AddSkyDomeSceneNode
-Added AddSphereSceneNode
-Added Material type : PointCloud
-Added Texture3 and Texture4 on Material class (also corrected GetTexture2 that returned Texture1)
-Added SceneManager.SaveScene/LoadScene
-Added VideoDriver.CreateScreenShot and VideoDriver.WriteImageToFile. Notice that Irrlicht.NET CP's WriteImageToFile supports
a lot of formats whereas Irrlicht's writeImageToFile only supports bmp for now. So you can save screenshots with this wrapper
in bmp, png, jpeg, gif... Whatever !
-Added VideoDriver.TextureCount, VideoDriver.PrimitiveDrawnCount and VideoDriver.GetTextureByIndex
The kid on my avatar wrote:A painless lesson is one without any meaning
The kid on my avatar wrote:A painless lesson is one without any meaning
Code: Select all
Vector3D intersection;
Triangle3D tri;
if (smgr.CollisionManager.GetCollisionPoint(
line,selector,out intersection, out tri))
{
Console.WriteLine("intersection : " + intersection);
Console.WriteLine("tri A: " + tri.PointA);
Console.WriteLine("tri B: " + tri.PointB);
Console.WriteLine("tri C: " + tri.PointC);
counter++;
bill.Position=intersection;
tracer2.Position = intersection;
//driver.SetTransform(TransformationState.WORLD, new Matrix4());
//driver.SetMaterial(material);
driver.Draw3DTriangle(tri,new Color(0,255,0,0));
}
Code: Select all
intersection : "Type = IrrlichtNETCP.Vector3D; X = 0; Y = 0; Z = 0"
tri A: "Type = IrrlichtNETCP.Vector3D; X = 0; Y = 0; Z = 0"
tri B: "Type = IrrlichtNETCP.Vector3D; X = 0; Y = 0; Z = 0"
tri C: "Type = IrrlichtNETCP.Vector3D; X = 0; Y = 0; Z = 0"
Code: Select all
using System;
using System.Text;
using System.IO;
using IrrlichtNETCP;
namespace _07._Collisions
{
class Program
{
int counter;
string path="";
IrrlichtDevice device;
/// <summary>
/// Main entry point for the program.
/// </summary>
/// <param name="args">Arguments to pass the software.</param>
[STAThread]
static void Main(string[] args)
{
Program prog = new Program();
prog.run();
}
public void run()
{
DriverType driverType;
StringBuilder sb = new StringBuilder();
sb.Append("Please select the driver you want for this example:\n");
sb.Append("\n(a) Direct3D 9.0c\n(b) Direct3D 8.1\n(c) OpenGL 1.5");
sb.Append("\n(d) Software Renderer\n(e) Apfelbaum Software Renderer");
sb.Append("\n(f) Null Device\n(otherKey) exit\n\n");
driverType = DriverType.Direct3D9;
// Create device and exit if creation fails:
device = new IrrlichtDevice(driverType, new Dimension2D(800, 600), 32, false, true, false,false);
if (device == null)
{
//tOut.Write("Device creation failed.");
return;
}
SceneManager smgr=device.SceneManager;
VideoDriver driver=device.VideoDriver;
device.FileSystem.AddZipFileArchive(path+"map-20kdm2.pk3",true,true);
AnimatedMesh q3levelmesh = smgr.GetMesh("20kdm2.bsp");
SceneNode q3node = null;
if (q3levelmesh!=null)
q3node=smgr.AddOctTreeSceneNode(q3levelmesh.GetMesh(0),null,0,128);
TriangleSelector selector = null;
if (q3node!=null)
{
q3node.Position= new Vector3D(-1370,-130,-1400);
selector=smgr.CreateOctTreeTriangleSelector(
q3levelmesh.GetMesh(0),q3node,128);
// not implemented but not necessary
//q3node.TriangleSelector=selector;
}
CameraSceneNode camera = smgr.AddCameraSceneNodeFPS(null,100,300,false);
camera.Position=new Vector3D(-100,50,-150);
Animator anim = smgr.CreateCollisionResponseAnimator(
selector,camera,new Vector3D(30,50,30),
new Vector3D(0,-3,0),new Vector3D(0,50,0),0);
camera.AddAnimator(anim);
device.CursorControl.Visible=false;
// add billboard
BillboardSceneNode bill = smgr.AddBillboardSceneNode(
null,new Dimension2Df(20,20),0);
bill.SetMaterialType(MaterialType.TransparentAddColor);
bill.SetMaterialTexture(0,driver.GetTexture(
path+"particle.bmp"));
bill.SetMaterialFlag(MaterialFlag.Lighting,false);
bill.SetMaterialFlag(MaterialFlag.ZBuffer,false);
Material material = new Material();
material.Texture1= driver.GetTexture(
path+"faerie2.bmp");
material.Lighting=true;
/*AnimatedMeshSceneNode node = null;
AnimatedMesh faerie = smgr.GetMesh(
path+"faerie.md2");
if (faerie!=null)
{
node=smgr.AddAnimatedMeshSceneNode(faerie,null,0);
node.Position=new Vector3D(-70,0,-90);
node.SetMD2Animation(MD2AnimationType.RUN);
node.SetMaterial(0,material);
node=smgr.AddAnimatedMeshSceneNode(faerie,null,0);
node.Position=new Vector3D(-70,0,-30);
node.SetMD2Animation(MD2AnimationType.SALUTE);
node.SetMaterial(0,material);
node=smgr.AddAnimatedMeshSceneNode(faerie,null,0);
node.Position=new Vector3D(-70,0,-60);
node.SetMD2Animation(MD2AnimationType.JUMP);
node.SetMaterial(0,material);
}
material.Texture1=null;
material.Lighting=false; */
//Add a light
smgr.AddLightSceneNode(null,new Vector3D(-60,100,400),
new Colorf(1.0f,1.0f,1.0f,1.0f),600,0);
/*For not making it too complicated, I'm doing picking inside the drawing
loop. We take two pointers for storing the current and the last selected
scene node and start the loop.*/
//SceneNode selectedSceneNode =null;
//SceneNode lastSelectedSceneNode =null;
SceneNode tracer1 = smgr.AddCubeSceneNode(20, null, 0);
SceneNode tracer2 = smgr.AddCubeSceneNode(20, null, 0);
int lastFPS=-1;
counter = 0;
while (device.Run())
{
if (device.WindowActive)
{
device.VideoDriver.BeginScene(true, true, new Color(0, 200, 200, 200));
device.SceneManager.DrawAll();
Line3D line = new Line3D();
line.Start=camera.Position;
line.End=line.Start+
(camera.Target - line.Start).Normalize() * 1000;
tracer1.Position = line.Start;
//Console.WriteLine("here");
driver.Draw3DLine(line, new Color(0, 255, 0, 0));
Vector3D intersection;
Triangle3D tri;
if (smgr.CollisionManager.GetCollisionPoint(
line,selector,out intersection, out tri))
{
Console.WriteLine("intersection : " + intersection);
counter++;
bill.Position=intersection;
tracer2.Position = intersection;
//driver.SetTransform(TransformationState.WORLD, new Matrix4());
//driver.SetMaterial(material);
driver.Draw3DTriangle(tri,new Color(0,255,0,0));
}
/*selectedSceneNode=smgr.CollisionManager.
GetSceneNodeFromCameraBB(camera,0);
if (lastSelectedSceneNode!=null)
lastSelectedSceneNode.SetMaterialFlag(
MaterialFlag.Lighting, true);
if (selectedSceneNode==q3node||
selectedSceneNode==bill)
selectedSceneNode=null;
if(selectedSceneNode!=null)
selectedSceneNode.SetMaterialFlag(
MaterialFlag.Lighting,false);
lastSelectedSceneNode=selectedSceneNode; */
/*That's it, we just have to finish drawing.*/
driver.EndScene();
int fps = device.VideoDriver.FPS;
if (lastFPS != fps)
{
device.WindowCaption = "Irrlicht Engine - Quake 3 Map example [" +
device.VideoDriver.ToString() + "] FPS:" + fps.ToString();
lastFPS = fps;
}
}
}
/*
In the end, delete the Irrlicht device.
*/
// Instead of device->drop, we'll use:
GC.Collect();
}
}
}
// Retrieved from "http://www.irrforge.org/index.php/CS_Tutorial_7"
// This page has been accessed 220 times. This page was last modified 06:51, 20 Jan 2006.
The kid on my avatar wrote:A painless lesson is one without any meaning
The kid on my avatar wrote:A painless lesson is one without any meaning