C#

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Marv

C#

Post by Marv »

well i hope someone can help me this ismy code (in vs c# 2005 beta)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System;
using Irrlicht;
using Irrlicht.Video;
using Irrlicht.Core;
using Irrlicht.Scene;
using io;
using gui;

namespace ascension
{
public partial class Form1 : Form
{
public Form1()
{

InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{ int main()
{
// create device
IrrlichtDevice *device = createDevice(EDT_OPENGL,
dimension2d<s32>(640, 480), 16, false);
if (device == 0)

IVideoDriver driver = device->getVideoDriver();
ISceneManager smgr = device->getSceneManager();
IAnimatedMesh q3levelmesh = smgr->getMesh("level_01.3ds");
ISceneNode q3node = 0;

if (q3levelmesh)
q3node = smgr->addOctTreeSceneNode(q3levelmesh->getMesh(0));
scene::ITriangleSelector* selector = 0;

if (q3node)
{
q3node->setPosition(vector3df(0,-0,0));

selector = smgr->createOctTreeTriangleSelector(
q3levelmesh->getMesh(0), q3node, 128);
q3node->setTriangleSelector(selector);
selector->drop();
}
scene::ICameraSceneNode* camera = camera = smgr->addCameraSceneNodeFPS(0,100.0f,300.0f);
camera->setPosition(vector3df(0,50,0));
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
selector, camera, vector3df(30,50,30),
vector3df(0,-3,0),
vector3df(0,50,0));
camera->addAnimator(anim);

anim->drop();
device->getCursorControl()->setVisible(false);

smgr->addLightSceneNode(0, vector3df(60,100,400),
SColorf(1.0f,1.0f,1.0f,1.0f),
600.0f);

scene::ISceneNode* selectedSceneNode = 0;
scene::ISceneNode* lastSelectedSceneNode = 0;

int lastFPS = -1;

while(device->run()) if (device->isWindowActive())
{
video::IVideoDriver* driver = device->getVideoDriver();
driver->beginScene(true, true, 0);

smgr->drawAll();

driver->endScene();
int fps = driver->getFPS();

if (lastFPS != fps)
{
core::stringw str = L("Ascension [");
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
device->drop();

return 0;
}
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("by OUT ROAD");
}
}
}


<<<<<and it's told me that error




}expected 27 ;11
Expected class,delegate,enum,interface,or struct 97 ;17
Type or namspace definition,or en-of-life expected 102 ;1
Embedded statement cannot be a declaration or labeled statement



<<<<< i spend one month to this program and i can build it so plise help me why it dosn't work ?
and i heard about one thing tha's irrlicht isn't finish for c#,is it true ? is it for that it didn't work ?
LM

Post by LM »

Why use c#?
1st, it looks like you have an extra '{' under 'int main()' unless thats some goofy c# thing.

It wants more info here:
MessageBox.Show("by OUT ROAD");
maybe (gcnew ( MessageBox.Show("by OUT ROAD")); ? if that is a seperate window to open.

The rest, I dunno.
shurijo
Posts: 148
Joined: Sat Feb 21, 2004 3:04 am

Post by shurijo »

That looks like a huge portion is C++ not C# code. If you want to use pointers, you have to declare your code as unsafe. And C# doesn't use -> or :: (AFAIK), they just use the dot notion. There's a few other things there that look like C++, too.

Honestly, it looks like you copied C++ main method and pasted it into the code for the onclick event of a button. You have extra {}s and an int named main that looks like "int main() {" beginning of a C++ function. You also have return 0 in there, which as a event handler you don't return anything.

This stuff is C++, not C#. You can't mix and match languages using copy & paste.

C++ code is everything in between this code block. You need to write this part in C#. This is the same question you asked last week, too.

Code: Select all

 int main()
{
// create device 
...
 }
device->drop();

return 0;
}
Last edited by shurijo on Tue Aug 23, 2005 1:18 am, edited 2 times in total.
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

shurijo wrote:This stuff is C++, not C#. You can't mix and match languages using copy & paste.
Lmfao .. awsome.
shurijo
Posts: 148
Joined: Sat Feb 21, 2004 3:04 am

Post by shurijo »

Go here

http://irrlicht.sourceforge.net/phpBB2/ ... php?t=7020

And download the first 11 C# tutorials for Irrlicht.NET.
Marv

Post by Marv »

yea you're right shujiro it's the same question but i didn't realy understadn want you told me but now i understand it's more clear for me.
Yea it's a code of c++ tutorial wich i past but i think that could work beceause i didn't now how to translate the code of C++ irlicht in C# but i will try to work it answer with your thanks :D
Post Reply