`
peizhiinfo
  • 浏览: 1428562 次
文章分类
社区版块
存档分类
最新评论

3DSTATE for Visual basic.Net开发(二)

 
阅读更多

3DSTATEfor Visual basic.Net开发注:转载请说明来源处!


准 备:

熟悉环境

在介绍前我们先来了解一下在接下来的学习中,我们首先要做的一些事情。
1、首先添加3DSTATE.vb到项目中,该文件位于C:/VBNet 3D Developer Studio 6.0 (Student Package)/Engine/Include目录下。
2、定义一个三维世界
Dim LoadWorld As Integer = STATE_engine_load_world("hello.morfit", "", "bitmaps", USER_DEFINED_BEHAVIOR)
这个返回值
LoadWorld会告诉我们是否建立了三维世界,若没有建立则退出系统。代码如下:
If LoadWorld <> OK Then
MsgBox("Error loading world!")
Application.Exit()
End If
3、下面我们需要定义一个摄像机
Dim Camera As UIntPtr
Camera = STATE_camera_get_default_camera()
4、在程序结束时释放内存
STATE_engine_close()
整个程序代码:添加一个Timer
而且该窗体并不含* .Designer.vb,只包含Form1.resx,如下图所示:
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Timer1 As System.Windows.Forms.Timer
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.SuspendLayout()
'
'Timer1
'
Me.Timer1.Interval = 1
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(592, 334)
Me.Name = "Form1"
Me.Text = "Hello, World"
Me.ResumeLayout(False)
End Sub
#End Region
#Region "Fields"
Dim m_AlreadyDone As Boolean = False
#End Region
Protected Overrides Sub OnActivated(ByVal e As System.EventArgs)
If m_AlreadyDone Then
Exit Sub
End If
m_AlreadyDone = True
Dim Path As String = "C:/VBNet 3D Developer Studio 6.0 (Student Package)"
Dim Res As Integer
Res = STATE_engine_load_world("newcubeSTATE.wld", Path & "/Worlds", _
Path & "/Worlds/bitmaps", USER_DEFINED_BEHAVIOR)
If Res <> OK Then
MessageBox.Show("Failed to load world, aborting" & Chr(10) & Chr(13) & "look at error.log to see why.", _
"HelloWorld Demo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Application.Exit()
Exit Sub
End If
'Initialize 3D card.
STATE_3D_card_use(True)
STATE_engine_hide_log_window()
Timer1.Enabled = True
End Sub
Protected Overrides Sub OnClosed(ByVal e As System.EventArgs)
STATE_3D_card_use(False)
'It is important to call this before ending the program
STATE_engine_close()
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim obj As UIntPtr = STATE_object_get_object_using_name("the_cube")
STATE_object_rotate_x(obj, 0.1, WORLD_SPACE)
STATE_object_rotate_y(obj, 0.5, WORLD_SPACE)
STATE_object_rotate_z(obj, 0.5, WORLD_SPACE)
'draw image seen from camera onto screen
STATE_engine_render(Handle, STATE_camera_get_default_camera())
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
或者直接更改Form1窗体中的Form1.Designer.vb文件。
基础知识

1、Handles
所有的对象、摄像机、位图、面等都具有Handles值,这个就像他们各自的ID一样,是程序在调用它们时如何区分他们之间的关键字。
Handle定义的类型为Long,但是当它为NULL值(即Value=0)时会出错。

2、3DSTATE APIs概述
3DSTATE APIs是由一系列功能组成的,每组功能用于三维世界中不同的方面。这些重要的功能主要包括:the camera API, the object API, the engine API, the polygon API, and the bitmap API.
所有的3DSTATE功能都是以单词STATE为前缀,例如
STATE_camera_get_location, STATE_engine_load_world, and STATE_object_set_direction等。

<!--v:3.2-->

三峡大学土木水电学院3S实验室肖泽云

分享到:
评论

相关推荐

    3dstate引擎制作的三维天空流云演示程序

    3dstate引擎制作的 三维天空流云演示 画面极为精致 分辨率为1024*768 200左右的fps

    3D游戏演示源码

    这个演示是我从Visual C++版本转换过来的,用的是3DSTATE 4.0商业引擎!可以免费用于非商业游戏的开发中.包含全部源码、引擎、以及可执行的演示文件。加载了Quake3的一个怪物,一个空旷的田野场景!你可以驱动怪物在...

    dstate:Discordgo的替代状态跟踪器

    dstate是Discordgo中标准状态跟踪器的替代状态跟踪器。 它稍微先进一些,但提供了更多功能,并且更容易避免比赛条件。 并发安全性: 单个角色,语音状态,消息状态从未修改,它们已被完全替换,使它们可以安全地...

    3D OPENGL 源程序

    3dstate demo source code,

    ddt:计算作为(非线性)动态系统的状态和输入变量的函数的时间导数-matlab开发

    函数 ddt(of, n, state,dstate,f,u) 鉴于: of:您想要导数的符号函数(例如 x2) n:n阶导数状态:表示状态名称的列向量,例如 [x1;x2] dstate:状态名称加上前面的ad,例如[dx1; dx2] f:状态导数的符号表达式,...

    proteus元件库中英对照

     DState:单稳态逻辑电平发生器。  DEdge:单边沿信号发生器。  DPulse:单周期数字脉冲发生器。  DClock:数字时钟信号发生器。  DPattern:模式信号发生器。  虚拟示波器(OSCILLOSCOPE)。  逻辑分析...

    Millenium TV Tools-crx插件

    语言:Français 扩展为webtvs millenium.org提供各种工具 [千禧年现在在抽搐上,没有必要这个插件] /!... 参与其发展:https://github.com/dstate/milleniumtv-tools Beta版本:可能有一些错误。

Global site tag (gtag.js) - Google Analytics