
2008年3月24日
空间分割二叉树BSP(Binary Space Partioning trees)
这在计算机图形学里好像是很经典的检测算法,我这两天一直在想,有两个问题
(1)如果分割平面穿过场景中的某个物体,如何处理
(2)如何使生成的二叉树最接近平衡二叉树
posted @
2008-03-24 23:03 达则兼济天下 阅读(103) |
评论 (0) |
编辑

2007年10月8日
http://www.simulation-argument.com/
http://www.simulation-argument.com/simulation.html
This paper argues that at least one of the following propositions is true: (1) the human species is very likely to go extinct before reaching a posthuman?stage; (2) any posthuman civilization is extremely unlikely to run a significant number of simulations of their evolutionary history (or variations thereof); (3) we are almost certainly living in a computer simulation. It follows that the belief that there is a significant chance that we will one day become posthumans who run ancestor-simulations is false, unless we are currently living in a simulation. A number of other consequences of this result are also discussed.
posted @
2007-10-08 16:50 达则兼济天下 阅读(42) |
评论 (0) |
编辑
This is an example in the Sample Source Code Guide.
Description:
This example demonstrates dragging 3D objects with constraints.
It displays a group of objects. When the user touches one and
holds the stylus button down, the user can move it around the screen.
While the button is down, constraint axes are drawn to allow more
precise control over dragging.
Shows using constraints to allow precise manipulation of objects with the haptic device.
This example also shows
(1)how to track the changes in position and orientation of the haptic device
/*******************************************************************************
Use the current OpenGL viewing transforms to initialize a transform for the
haptic device workspace so that it's properly mapped to world coordinates.
*******************************************************************************/
void updateHapticMapping(void)
{
GLdouble modelview[16];
GLdouble projection[16];
GLint viewport[4];
glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
glGetDoublev(GL_PROJECTION_MATRIX, projection);
glGetIntegerv(GL_VIEWPORT, viewport);
hlMatrixMode(HL_TOUCHWORKSPACE);
hlLoadIdentity();
// Fit haptic workspace to view volume.
hluFitWorkspace(projection);
// Compute cursor scale.
gCursorScale = hluScreenToModelScale(modelview, projection, viewport);
gCursorScale *= CURSOR_SIZE_PIXELS;
}
/******************************************************************************
Displays a cursor using the current haptic device proxy transform and the
mapping between the workspace and world coordinates
******************************************************************************/
void redrawCursor()
{
static const double kCursorRadius = 0.5;
static const int kCursorTess = 15;
HLdouble proxytransform[16];
GLUquadricObj *qobj = 0;
glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_LIGHTING_BIT);
glPushMatrix();
if (!gCursorDisplayList)
{
gCursorDisplayList = glGenLists(1);
glNewList(gCursorDisplayList, GL_COMPILE);
qobj = gluNewQuadric();
gluSphere(qobj, kCursorRadius, kCursorTess, kCursorTess);
gluDeleteQuadric(qobj);
glEndList();
}
// Apply the local position/rotation transform of the haptic device proxy.
hlGetDoublev(HL_PROXY_TRANSFORM, proxytransform);
glMultMatrixd(proxytransform);
// Apply the local cursor scale factor.
glScaled(gCursorScale, gCursorScale, gCursorScale);
glEnable(GL_NORMALIZE);
glEnable(GL_COLOR_MATERIAL);
glColor3f(0.0, 0.5, 1.0);
glCallList(gCursorDisplayList);
glPopMatrix();
glPopAttrib();
}
(2)how to apply those changes to an object in the scene.
/******************************************************************************
Calculates updated object transform for drag object based on changes to
proxy transform.
******************************************************************************/
void updateDragObjectTransform()
{
assert(gCurrentDragObj >= 0 &&
gCurrentDragObj < draggableObjects.size());
// Calculated delta between current proxy pos and proxy pos at start
// of drag.
hduVector3Dd proxyPos;
hlGetDoublev(HL_PROXY_POSITION, proxyPos);
hduVector3Dd dragDeltaTransl = proxyPos - gStartDragProxyPos;
// Same for rotation.
hduMatrix deltaRotMat;
if (gRotate)
{
hduQuaternion proxyRotq;
hlGetDoublev(HL_PROXY_ROTATION, proxyRotq);
hduQuaternion dragDeltaRot = gStartDragProxyRot.inverse() * proxyRotq;
dragDeltaRot.normalize();
dragDeltaRot.toRotationMatrix(deltaRotMat);
// Want to rotate about the proxy position, not the origin,
// so need to translate to/from proxy pos.
hduMatrix toProxy = hduMatrix::createTranslation(-gStartDragProxyPos);
hduMatrix fromProxy = hduMatrix::createTranslation(gStartDragProxyPos);
deltaRotMat = toProxy * deltaRotMat * fromProxy;
}
// Compose rotation and translation deltas.
hduMatrix deltaMat = deltaRotMat * hduMatrix::createTranslation(dragDeltaTransl);
// Apply these deltas to the drag object transform.
draggableObjects[gCurrentDragObj].transform = gStartDragObjTransform * deltaMat;
}
/*******************************************************************************
Draws the objects that can be seen, felt and dragged around.
*******************************************************************************/
void drawDraggableObjects()
{
hlTouchModel(HL_CONTACT);
hlTouchableFace(HL_FRONT);
for (int i = 0; i < draggableObjects.size(); ++i)
{
const DraggableObject& obj = draggableObjects[i];
// Position and orient the object.
glPushMatrix();
glMultMatrixd(obj.transform);
// Draw the object graphically.
glCallList(obj.displayList);
// Draw the object haptically (but not if it is being dragged).
if (i != gCurrentDragObj)
{
hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, obj.shapeId);
glCallList(obj.displayList);
hlEndShape();
}
glPopMatrix();
}
}
It also shows
(1)how to use collision thread events to disable proxy rendering in order to avoid a haptic "kick" when
setting constraints on stylus switch clicks.
posted @
2007-10-08 09:34 达则兼济天下 阅读(123) |
评论 (1) |
编辑

2007年10月6日
这个功能比较重要,游戏中的托拽经常要用到,例如,棋类游戏中让棋子走到鼠标指定的位置,还有做模拟城市的游戏中,玩家会将自己选择的建筑物或者植物托拽到某个特定的位置。
In: triggers the process.
True: is activated when the ray intersects an object or a sprite.
False: is activated when the ray doesn't intersect an object.

X: X axis value (Note : this pIn will not be visible if the Use 2D Vector or Use Mouse Coordinates setting is checked.)
Y: Y axis value (Note : this pIn will not be visible if the Use 2D Vector or Use Mouse Coordinates setting is checked.)
Pos: coordinates defined as X and Y axis value (Note : this pIn will only be visible if the Use 2D Vector setting is checked and the Use Mouse Coordinates setting left unchecked.)
Window Relative: Check this parameter if you give coordinates in the render window coordinate system, or leave it uncheck if you give them in the entire screen coordinates (like the values returned by the GetMousePosition behavior). For fullscreen mode, this parameter makes no difference.
Object Picked: The first object in Z order, under the picking.
Intersection Point: exact 3D point coordinates of the intersection point (this point is given in world space coordinates).
Intersection Normal: coordinates of the normal vector on the picked object.
UV Coordinates: coordinates on the 'texel' picked (pixel on the texture).
Distance from The Viewpoint: distance of the exact 3D point from the viewpoint
Face Index: index, on the object, of the picked face
Sprite: picked sprite, if any.
Use 2D Vector: Uncheck to provide coordinates using seperate pIns for X and Y values.
Use Mouse Coordinates: Checked (by default) to use the mouse position to provide coordinates. (Note: Checking this setting hides all pIns)
Local Output: check this if you want Intersection Point and Normal expressed in the picked object referential.
posted @
2007-10-06 21:02 达则兼济天下 阅读(101) |
评论 (0) |
编辑
我想做一个灯光特效,舞台中常用的,让灯光跟随人物的运动,我看到light里有一个set light target,以为用这个设置参数后就可以了,但是试了试没用。好像他的target只能是3D Entity
最后的解决办法是,设置一个3D Frames,让这个参考物体跟随人物运动,在light setup中将target设为此参考物体

让一个装备精良的美女在黑漆漆的野外独自漫步,幸好还有束灯光始终陪着她(这样是不是更容易被敌人发现呢?)
posted @
2007-10-06 17:21 达则兼济天下 阅读(89) |
评论 (0) |
编辑

2007年10月5日
3D Transformations/Animations/Animation Recorder
Play Animation 3D Entity
Play Global Animation
Set Animation Step Entity
Set Global Animation Step
Basic/Add Child
/Rotate
/Rotate Around
/Scale
/Scale Euler Orientation
/Set Local Matrix
/Set Oritation
/Set Parent
/Set Position
/Set Qurternion Orientation
/Set World Matrix
/Translate
Constraint/Billboard
/keep at Constant Distance
/Look At
/Mimic
/Object Keep on Floor
/Object Keep on Floor V2
Curve/Add Control Point
/Curve Flow
/Get Curve Point Properties
/Get Curve Properties
/Position on Curve
/Remove Control Point
/Set Control Point Properties
/Set Curve Properties
Movement/MoveTo
Nodal Path/Active Link
/Active Node
/Character Go To Node
/Create Nodal Path
/Entity Find Nodal Path
/Find Curve Nodal Path
/Find Path
/Update Nodal Path
posted @
2007-10-05 17:09 达则兼济天下 阅读(77) |
评论 (0) |
编辑
对于游戏和动画中最重要的角色提供了下列封装好的BB
character/animation/add animation 给人物加载一个动画,通常前面是Object Loader
animation synchonizer 某个特定时刻发送消息,例如可以用于人物某个动作时加载特定的声音,需要在动画序列中指定你想要得动作,并为消息命名,这个名字将作为switch on message 的参数
create blend animation 2 将两个动画混合加载
exclude from animation 从动画中隐藏参与动画的某个3D实体,即使这个物体不运动
set animation frame 控制动画桢的动作
set animation step
set blended animation factor 设置混合动画的coefficient of interpolation的参数
set bodypart animation frame 设置身体某个部分的动画
share character animation key 一个组中的所有人物共享动画
/basic/get nearest object 找出在一个Object组中,距离人物最近的物体
set floor reference object 使用某个物体标志地面参考
/constraints/charater keep on floor 使一个人物保持在事先定义好的地板上
enhance character keep on floor 使一个人物保持在声明的地板上
/IK/IK postion 控制人物身体从某个部位到某个部位的运动
movement/character controller 用键盘或者游戏手柄控制人物运动,一般与keyboard mapper结合使用
/character curve flow 控制人物随事先定义好的曲线运动
/character go to 控制人物以某个位置为目标运动
/enhanced character curve flow 控制人物随事先定义好的曲线运动
/unlimited control 使用消息响应机制对人物进行控制
posted @
2007-10-05 16:36 达则兼济天下 阅读(180) |
评论 (0) |
编辑

2007年10月2日
今天学会了控制相机在场景中漫游,即以第一视点进入到场景中,并交互
步骤:
(1)新建相机
(2)set as active camera (BB/camera/montage/)
(3) switch on key (BB/controllers/keyboard/)
然后编辑script
我碰到了一个很奇怪的问题,开始怎么都没有反应,后来加了output to console测试后,其他地方也没改,相机移动的效果就出来了,但是控制台并没有得到相应的结果输出。
下一步继续做的:
(1)加入碰撞检测
(2)相机移动的方向改进,现在只是沿着xyz方向动,如果稍微旋转一下有了角度,移动就发生错误了
posted @
2007-10-02 22:26 达则兼济天下 阅读(127) |
评论 (0) |
编辑

2007年9月22日
The Behavioral Engine - CK2
The Behavioral Engine implements behavioral processing and is the central component of Virtools. Also known as CK2 (hence the CK references you often see in the interface, such as CKID, CKClass and so on), the Behavioral Engine is what makes Virtools so flexible.
What does CK2 do? CK2 executes your compositions, processing Scenes and managing all interactions between the User and the elements of your composition. CK2 also processes the elements of your composition that have behaviors applied to them ?that is, the Behavioral Objects.
Once all behaviors have been processed for a given frame, CK2 provides the appropriate information to the render engine (CK2_3D) so that the results of the interactivity can be displayed to the User.
NOTE The Level is always active and is the highest priority element in every frame. All currently inactive elements are ignored in the remaining tasks.
Processing continues in the current frame until all BBs are processed or the link delay is greater than 0.
When all behavioral processing is complete, CK2 provides information to the rendering engine to draw an image on screen, the image is rendered, any link delays that are greater than 0 are reduced by 1, and behavioral processing starts again.
You can watch behavioral processing in action by activating Trace mode in the Schematic. When the composition is played, the sequence of activations and BB processing are highlighted in red in the Schematic.
posted @
2007-09-22 15:47 达则兼济天下 阅读(62) |
评论 (0) |
编辑

2007年9月21日
我被virtools的web发布功能所吸引,当然他还具有很多其它的强大功能。
在初学阶段,我看virtools的User Guide,总觉得有点找不到北的感觉,跟着quick start做的时候,很多选项和按钮都找不到,可能看美国人写的帮助文档和界面习惯了,猛一看法国人写的,还真有点不适应。
不过Quick Start的东西自己又独立做了两遍,有了一点浅显的认识,现在有几个问题还不清楚,留作下一阶段的学些:
(1)怎么生成自己的rsc文件,就是将自己的nmo文件们(当然从3ds转过来的)集合到一个rsc文件里,并各自在自己的目录下?
(2)对于一个物体的话,我想控制他的行为,应该通过脚本或者事件控制,那相机呢
(3)可以直接生成web page,但是如果想嵌入一个网页呢?
(4)怎样在在界面文本输入读取字符
(5)看来脚本很重要了,好好看看有关章节
我不能因为自己没找到感觉,就说人家的guide写得不好,界面不好用,只能是我适应能力太差了
posted @
2007-09-21 23:49 达则兼济天下 阅读(194) |
评论 (2) |
编辑