Question:
how to create 3D simulation using C#? Should I add more application? Tell me step by step.. Thanks before!!?
?
2009-03-31 21:25:02 UTC
the visualization of the simulation is showing operator moving in the warehouse (order picking)..
Four answers:
2009-03-31 22:20:09 UTC
You can take one of two approaches:



1. Download and install Managed DirectX libraries for .NET. This will allow you to write a 3D viewer in C#. You can then load building models stored in .X file format and "walk through" them using keyboard/mouse/joystick.



2. Download and install XNA Studio for .NET. While it is intended as a "game development" tool, there is no reason you can't use it for a 3D "walkthrough" tool. This is a somewhat simplified wrapper for DirectX. It will also allow you to load 3D models/meshes and "walk through" them.



The step-by-step is much too long to describe here. The simplified version is:



- Install Visual Studio Express

- Install XNA Game Studio

- Start a new Windows Game in Visual Studio. This will build the basic framework for the "game"

- Insert the 3D model as part of the project content. If you want to load 3D models files from outside the project you'll have to get familiar with using the Content Manager. It's not difficult, just another piece of the puzzle.

- Set an initial vertex (3D point) within the model where you want your viewer to "start" and a viewing frustrum (viewport) to define which direction the person is viewing, how much they can see, etc.

- Map keystrokes to movement. The W,A,S and D keys (forward, turn left, back, turn right) are common for moving around in 3D worlds. One technique is to move the viewer around within the 3D world, another is to move the world around the viewer, simulating movement. Lookup help on matrix transformations to accomplish either.



If you want to simulate gravity, bumping into walls/floors, you will have to write code for it. Otherwise the viewer will behave like a "ghost", floating around the 3D world, and passing through walls. There are built-in methods in both XNA and DirectX to detect if the viewer has "intersected" a wall or floor of the building model which will tell you if they need to stop moving in the given direction.



There are several good books on both Managed DirectX and XNA Studio. There are also lots of web resources for both, although there's a bit more for XNA.
Sharene
2016-03-03 02:15:06 UTC
Well, you need to know some sort of 3D library. The top two are OpenGL and DirectX. Choose whichever one is easier to you. Alternatively, use some open-source game engine (I don't know of any off the top of my head). These can make it a bit less complicated and can handle stuff like responding to keyboard events instead of coding it yourself. You'll also need some 3D modeling software to create the models of the crane.
adeel
2009-03-31 21:34:40 UTC
* Introduction

* Sample Unmanaged C++ Library

* Retrieve Exported Information from the DLL

* Perform Platform Invoke

* Wrap all Imports in Managed Classes

* Inheritance, Polymorphism, and Virtual Destructor

* Imported Resource Disposal

* Concluding Remarks

* Revision History



1. Introduction



This article has been revised. Check here for updates.



There are many reasons why you would want to reuse unmanaged C/C++ libraries; the most important one is perhaps that you want to use existing tools, utilities, and classes written in unmanaged C/C++. They could be third-party tools or in-house libraries. When choosing an approach to reusing unmanaged libraries, you normally have three options:



1. IJW or It Just Works. This is one of the greatest features that .NET Framework has provided to developers. You just recompile the old code on the new .NET platform. No or little changes are necessary. Don't forget though; it works in the C++ language only.

2. COM. The COM model works on both the unmanaged and managed environments. It's straightforward to perform a COM Invoke on .NET. But, if your unmanaged classes are not COM-ready, you probably won't rewrite all the old code to support COM.

3. P/Invoke or Platform Invoke. This mechanism allows you to import a class as functions at the attribute level. Basically, you import class methods one by one as individual functions, as you do with Win32 APIs.



If your unmanaged C++ libraries are not COM-ready, you can choose between IJW and P/Invloke. Also, you may combine the two approaches in your importing practice. As IJW requires C++ source code, if you don't have the source code, P/Invoke probably is the only option available. Using Win32 API via [DllImport] attributes is a typical example of P/Invoke in .NET development.



This article will discuss how we can use unmanaged C++ classes exported from a DLL. No source code for the unmanaged C++ libraries are required to be present. In particular, I will demonstrate how to wrap up your unmanaged classes into managed ones so that any .NET application can use them directly. I will take a practical approach and omit theoretical discussions where possible. All the samples and source code provided in this article are simple and for tutorial purposes only. In order to use the source code included in the article, you should have Visual Studio 2005 and .NET Framework 2.0 installed. However, the wrapping technique remains the same on VS 2003 and .NET Framework 1.x. The unmanaged DLL has been compiled on Visual C++ 6.0, which is not required if you don't recompile the unmanaged source.

2. Sample Unmanaged C++ Library



Go to Top



The following segment is the definition of a base class "Vehicle" and its derived class "Car":

Collapse



// The following ifdef block is the standard way of creating macros which make exporting

// from a DLL simpler. All files within this DLL are compiled with the CPPWIN32DLL_EXPORTS

// symbol defined on the command line. this symbol should not be defined on any project

// that uses this DLL. This way any other project whose source files include this file see

// CPPWIN32DLL_API functions as being imported from a DLL, whereas this DLL sees symbols

// defined with this macro as being exported.



#ifdef CPPWIN32DLL_EXPORTS

#define CPPWIN32DLL_API __declspec(dllexport)

#else

#define CPPWIN32DLL_API __declspec(dllimport)

#endif



// This class is exported from the CppWin32Dll.dll

class CPPWIN32DLL_API Vehicle

{

public:

Vehicle(char* idx);

// Define the virtual destructor



virtual ~Vehicle();



char* GetId() const;

// Define a virtual method



virtual void Move();



protected:

char* id;

};



class CPPWIN32DLL_API Car : public Vehicle

{

public:

~Car();

// Override this virtual method



void Move();

};



By all means, the two classes are very simple. However, they bear two most important characteristics:



1. The base class contains a virtual destructor.

2. The derived class overrides a virtual method of the base class.



To demonstrate the invoke sequence, I've inserted a printf statement in each method. For your reference, here is the complete source of "CppWin32Dll.cpp":

Collapse



#include "stdafx.h"

#include "CppWin32Dll.h"



BOOL APIENTRY DllMain( HANDLE hModule,

DWORD ul_reason_for_call,

LPVOID lpReserved

)

{

switch (ul_reason_for_call)

{

case DLL_PROCESS_ATTACH:

case DLL_THREAD_ATTACH:

case DLL_THREAD_DETACH:

case DLL_PROCESS_DETACH:

break;

}

return TRUE;

};



// This is the constructor of a class that has been exported.

// see CppWin32Dll.h for the class definition



Vehicle::Vehicle(char* idx) : id(idx)

{

printf("Called Vehicle constructor with ID: %s\n", idx);

};



Vehicle::~Vehicle()
?
2016-05-10 07:18:35 UTC
Incredible 3D Animation Software : http://3dAnimationCartoons.com/?cBMT


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...